Last Comment Bug 170553 - (opengl) Render using OpenGL
: Render using OpenGL
: highrisk, perf
Product: Core
Classification: Components
Component: Graphics (show other bugs)
: Trunk
: All All
P3 enhancement with 30 votes (vote)
: Future
Assigned To: Nobody; OK to take it and work on it
: Milan Sreckovic [:milan]
Depends on: 290903
Blocks: 85586
  Show dependency treegraph
Reported: 2002-09-24 12:02 PDT by Brian 'netdragon' Bober
Modified: 2014-04-26 03:22 PDT (History)
43 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

braindead opengl on OS X (14.32 KB, patch)
2009-10-27 14:16 PDT, Joe Drew (not getting mail)
no flags Details | Diff | Splinter Review

Description User image Brian 'netdragon' Bober 2002-09-24 12:02:46 PDT
Using directx and/or opengl would make rendering faster on all the oses. We 
could make it option-based so that if someone doesn't have the ability to run 
directx or opengl they could use plain GDI (or linux equiv) rendering.

This is obviously something that is for the way future.
Comment 1 User image Boris Zbarsky [:bz] (still a bit busy) 2002-09-24 13:53:46 PDT
I fail to see how rendering using directX or openGL will be that much faster for
2-d rendering (which is what we are doing).
Comment 2 User image Hixie (not reading bugmail) 2002-11-13 14:39:05 PST
Make it so.
Comment 3 User image Robert O'Callahan (:roc) (email my personal email if necessary) 2002-11-13 14:49:23 PST
There's no need to use DirectX. OpenGL runs fine on Windows, AND it's cross

Things that would work better in OpenGL:
alpha compositing
scaling (bilinear filtering!)
any kind of image drawing, actually (store images in texture memory)
anti-aliased anything

Well, that list pretty much sums up everything that's slow about our current
drawing code :-).
Comment 4 User image ArronM (:paper) 2002-11-13 14:50:38 PST
In theory, video cards are faster at 2D rendering using OpenGL/DirectX because
that has been the "push", the "in thing", the "fad", the "what all perf
comparison charts use to say who's hot".  So the video card manufacturers have
been pouring many manhours into developing the fastest 3D out there, usually at
the expense of speeding up their old 2D routines.

All the cool routines are in 3D mode, even the 2D ones ;)
Comment 5 User image Brian 'netdragon' Bober 2002-12-01 12:23:52 PST
Also GDI (win32) is made for basic rendering of widgets and such, not rich 
multimedia rendering as is now required by browsers. It says that if you do 
any kind of sophisticated multimedia, you should use DirectX (or opengl). 
Mozilla isn't a text-mode application. ;-)
Comment 6 User image Adam D. Moss 2003-01-21 10:08:52 PST
I love OpenGL.  However:

Things that would likely work worse in OpenGL:
. Text rendering (uh-oh)
. Drawing to an offscreen image (double-buffering -- when
  you swap buffers in OpenGL the new backbuffer's contents
  become undefined.  Single-buffering would give flicker.
  Hardware-rendering to an offscreen pixmap is nonstandard.)
. Screen-screen copies (scrolling!)

I think that an OpenGL front-end would be groovy and IS doable,
but there are some real potential design/performance/interoperability
pitfalls to be wary of.
Comment 7 User image Ed Grochowski 2003-01-21 10:36:12 PST
Actually on Windows, I think the simplest change which would help all the issues
decribed in comment #3 would be to use GDI+

Having said that, I dont have benchmarks to know how much performance would
benefit (other than MS docs which say "programmers of new applications should
use GDI+ for all their graphics needs because GDI+ optimizes many of the
capabilities of GDI and also provides additional features"). At least it has
many of the algorithms and features Mozilla needs.

Of course, this doesnt help cross-platform performance or needs.
Comment 8 User image Brian 'netdragon' Bober 2003-01-21 11:46:04 PST
I'd like to mention that its not a good idea to start saying, "We'll fix this 
with the OpenGL fix" for bugs like bug 98971 - on bilinear image scaling. This 
bug isn't a small fix and will require a lot of testing. That's why I'm adding 
the keyword "highrisk"

highrisk: Bugs whose fixes have a high level of risk associated with them, 
typically due to some major architectural changes being required (see 
the 'arch' keyword). Typically these are bugs that were deferred from the 
previous release cycle due to the high level of risk involved, and should 
therefore be fixed as soon as possible in the next cycle. Examples: "need to 
rewrite handling of HTTP headers" or "need to redesign the content sinks".

If believe this bug could be considered a major architectural change since it 
will change the way in which graphics are rendered throughout mozilla.
Comment 9 User image ArronM (:paper) 2003-01-21 13:25:54 PST
GDIPlus is probably not an option as it requires a download from Microsoft if
you are on Win95/98/ME/2k.  I believe WinXP has it.  Some documentation says 2k
has it, but it wasn't on my 2k machine.

Unless of course, it was a build option.
Comment 10 User image Christian :Biesinger (don't email me, ping me on IRC) 2003-01-21 13:38:25 PST
paper: couldn't moz ship with the gdi+ dll?
Comment 11 User image Robert O'Callahan (:roc) (email my personal email if necessary) 2003-01-21 13:55:07 PST
> Things that would likely work worse in OpenGL:
> . Text rendering (uh-oh)

We would rasterize glyphs ourselves and upload as textures. This is basically
what our existing Freetype code already does on X (both the bstell code and the
Xft code) --- except X is slower, of course.

> . Drawing to an offscreen image (double-buffering -- when
>   you swap buffers in OpenGL the new backbuffer's contents
>   become undefined.

Not a problem, we always throw the old buffer away anyway.

> Single-buffering would give flicker.
>   Hardware-rendering to an offscreen pixmap is nonstandard.)

My OpenGL books are at home but I think they describe rendering to an offscreen
pixmap to do lots of tricks. Anyway the real issue is not whether it's standard,
but whether existing cards let us do it, and I'm pretty sure they do.

> . Screen-screen copies (scrolling!)

If OpenGL rendering is fast enough, we would just rerender the entire scrolled
area. We already do this for certain complex pages (e.g., pages with


I totally agree with Brian that OpenGL is not a solution to any short-term
problems. We need to keep improving our existing GFX implementations.


We could detect at runtime if GDI+ is available and use it if it is.
Comment 12 User image Robert O'Callahan (:roc) (email my personal email if necessary) 2003-01-21 14:01:45 PST
BTW Adam, rendering to offscreen pixmaps is necessary to do CSS/SVG transparency
properly as well as for double buffering, and one of my main motivations to use
OpenGL would be to speed up the rendering of exactly that sort of effect. So if
offscreen OpenGL rendering doesn't work well in common cases (say Linux+NVidia)
then I'm suddenly not interested in it anymore.
Comment 13 User image Adam D. Moss 2003-01-21 14:13:53 PST
You're fine with the nVidia drivers on linux and windows.

I think the recommended way to do this on windows is with
the WGL_ARB_pbuffer extension.  There's an equivilent (but
different) extension offered by recent nV drivers on both
platforms but the name escapes me.
Comment 14 User image Robert O'Callahan (:roc) (email my personal email if necessary) 2003-01-21 14:52:38 PST
One thing I should mention here is that on Linux, OpenGL with Direct Rendering
is a much faster path to the graphics hardware than the X protocol and the X
server. If there's a win here, it's probably bigger on Linux than anywhere else.
Comment 15 User image nemo 2003-03-29 14:32:42 PST
I'd like to add my vote for OpenGl for precisely the reason mentioned by Mr.

I started out by asking about Gtk/Qt use of DRI, and when I learned that only
OpenGL used DRI at the moment, searched for this bug.

It'd be nice to be able to scroll over a fixed background without stutteriness.
 Or move a sidebar menu without it jumping around.

Mozilla under linux is a bit of an embarassment in terms of responsiveness. 
People are quick to blame the mozilla code, but I bet it is just the windows
advantage of direct access to graphics card.

*note, I am in *no* way a graphics programmer or have any familiarity with it,
all the above is just the rantings of a user*  :)
Comment 16 User image Adam 2004-12-17 07:49:15 PST
Anything ever come of this?
Comment 17 User image Adam D. Moss 2004-12-17 08:01:30 PST
I think the idea is to switch to Cairo for (most?) rendering, and that gives
gecko a pretty good OpenGL back-end for free.

There don't seem to be any bugs in bugzilla about the Cairo support though,
which is mysterious.   I guess if it's happening then it's happening offline.
Comment 18 User image Robert O'Callahan (:roc) (email my personal email if necessary) 2004-12-20 20:14:45 PST
The Cairo work is happening very slowly right now. It will speed up a lot once I
start working on it in January.
Comment 19 User image Robert O'Callahan (:roc) (email my personal email if necessary) 2005-04-19 13:43:26 PDT
The overall plan here is to get Mozilla working using Cairo for all rendering on
all platforms. Then users with good OpenGL support can use the "Glitz" Cairo
backend to get hardware acceleration. This will require us to do some work on
Cairo itself to make it fast enough, but at least we won't be doing the graphics
layer alone anymore.
Comment 20 User image Mateusz Marek 2008-06-06 11:20:24 PDT
Does this bug still apply or can it be closed since we're using Cairo?
Comment 21 User image Joe Drew (not getting mail) 2009-10-27 14:16:36 PDT
Created attachment 408683 [details] [diff] [review]
braindead opengl on OS X

Here is a patch that Vlad gave me, and I fixed up a little, that takes the output of Firefox's rendering on OS X and, on every draw, creates a texture, uploads it, and draws a textured quad.

Let me be clear: this is proof-of-concept only. It implements hardware deceleration. It is not the way we want to go. But it's at least a starting point.
Comment 22 User image Guilherme Lima 2011-01-14 15:52:38 PST
This should be duped to something??
Comment 23 User image JP Rosevear [:jpr] 2011-10-12 16:53:26 PDT
We have OpenGL layers now, implemented via other bugs.

Note You need to log in before you can comment on or make changes to this bug.