Vega - Opera's vector graphics library
By Tim Johanssontimjoh. Wednesday, February 4, 2009 9:39:41 AM
In my previous post here at Core concerns I wrote a bit about hardware acceleration of Opera's vector graphics library. In this post I will go into some more details about our vector graphics library.
The history of Vega
Vega was created shortly after we started working on SVG support. When we added SVG support in Opera we needed a vector graphics library. We looked into what was available to use and met our requirements (fast, low memory usage and works on platforms ranging from phones to TVs and desktop computers). We did not find and good match for our needs, so we decided to write our own.
Shortly after we created Vega we added <canvas> support, which also uses Vega.
The most recent addition to Vega is the ability to use a hardware accelerated back-end. The back-ends we are using at the moment are OpenGL and Direct3D.
HTML rendering
In the core version we are currently developing, Presto 2.3, we have made it possible to use Vega for all rendering in Opera. This means that we can replace the platform specific code for rendering with Vega. In the future it might be mandatory to use Vega for rendering, but in Presto 2.3 it is still possible to use the old rendering back-ends.
There are three reasons for doing this. The first reason is that the new CSS3 background and borders standard is much easier to implement using a vector graphics library. Presto 2.3 adds partial support for CSS3 backgrounds and borders, but only when using Vega for rendering.
The second reason is to support hardware acceleration of our vector graphics. In order to be able to render SVG and <canvas> in hardware we must also be able to directly draw the rendered vector graphics to the screen since reading back the rendered image from the graphics card is usually slower than rendering in software.
The final reason is that it enables us to easily add advanced graphical effects to our UI and to web pages.
Hardware requirements
The hardware back-end of Vega will unfortunately not work on all graphics cards. The good news is that we detect at runtime if your graphics card is supported or not and fallback to the software back-end of Vega if the graphics card is not supported. This means that everything will work regardless of your graphics cards capabilities.
The first requirement of you graphics card is that it has fast stencil buffers. If you are on a desktop computer that will not be a problem, but on some mobile phones that will be a problem. The reason for this requirement is that we use the stencil buffer for rendering some complex shapes instead of tessellating them and render triangles.
Since some web standards (for example opacity, SVG and <canvas>) require us to render to an off-screen buffer which is composited onto the screen we also require some kind of render to texture to be able to use Vega hardware back-end. This means a DirectX 9 compatible graphics card, or support for the framebuffer object (FBO) extension in OpenGL. It would be possible to do the same thing with pbuffers in OpenGL, but we need to do many render target switches and with pbuffers that is too slow.
The final requirement is pixel shaders 2.0, or fragment shaders 2.0 as it is called in OpenGL. We also require GLSL support on OpenGL. The shaders are required for filters. Filters is a part of SVG which performs an operation such as blur or color transforms on an image. Filters are also used in <canvas> and to support text shadows and box shadows in HTML.
For a PC user these requirements are met by any DirectX 9 compatible graphics card. So with the correct drivers you should be able to use the hardware back-end of Vega if you have a DirectX 9 compatible graphics card.
Update 2009-02-05:
I was not very clear about the multiple back-ends of Vega. If the graphics card is not capable of running the hardware back-end of Vega the software back-end will be used as a fallback and all features will still work. No features depends on hardware acceleration. All of them, including CSS3 backgrounds and borders, will work in the software back-end of Vega which does not depend on hardware accelerated graphics.

Tamil # Wednesday, February 4, 2009 9:41:59 AM
Шуйский Николай [krigstask, Ŝtérkrìg]Sterkrig # Wednesday, February 4, 2009 10:23:12 AM
So Presto 2.2 has been feature-frozen? Only bugfixing etc?
malsumis # Wednesday, February 4, 2009 11:11:32 AM
Aux # Wednesday, February 4, 2009 12:21:12 PM
Bruno Casanobrunitoc # Wednesday, February 4, 2009 12:36:11 PM
Cant wait to see that !!!!
Turin # Wednesday, February 4, 2009 1:13:33 PM
serious # Wednesday, February 4, 2009 1:17:31 PM
Aux # Wednesday, February 4, 2009 1:36:33 PM
Artur „Jurgi” JurgawkaJurgi # Wednesday, February 4, 2009 2:11:51 PM
Precise, maybe, but not clear for me…
Aux # Wednesday, February 4, 2009 2:26:22 PM
Artur „Jurgi” JurgawkaJurgi # Wednesday, February 4, 2009 4:02:31 PM
MadAtWork # Wednesday, February 4, 2009 4:30:50 PM
serious # Wednesday, February 4, 2009 4:38:10 PM
Charles SchlossChas4 # Wednesday, February 4, 2009 5:21:36 PM
_Grey_ # Wednesday, February 4, 2009 5:53:30 PM
Well, too bad. Shader 1 card. Also what will you do on devices? Do all of them have better graphics cards than I have?
sms985 # Wednesday, February 4, 2009 6:05:01 PM
take a look here:
http://my.opera.com/core/blog/2008/06/05/engineering-seminar
I was hoping to see this in Opera 10 already, anyway we'll have to wait for Presto 2.3... Opera 10.5?
very exciting stuff!! bravo!
Faruk AtesKuraFire # Wednesday, February 4, 2009 6:30:04 PM
elem.style.operaBorderTopLeftRadius
or this?
elem.style.oBorderTopLeftRadius
If the browser doesn't support it at times when using the software renderer, those properties should behave accordingly (whatever name they're using) and return "undefined" whether they're set in the CSS or not. Otherwise, it'll be impossible to do client-side detecting of whether those properties will be rendered by the browser if set (or toggled) in the code.
Charles SchlossChas4 # Wednesday, February 4, 2009 6:52:54 PM
Tim Johanssontimjoh # Thursday, February 5, 2009 8:51:10 AM
@Turin: we will optimize both as much as possible, which is faster will vary between graphics cards and drivers.
@serious: OpenGL is usually not supported in the drivers shipped with windows. If you don't update your drivers it is common that D3D works but not GL. It is also difficult to get OpenGL running on some laptops with integrated graphics.
@_Grey_, KuraFire: nothing will depend on hardware acceleration, there is a software fallback which supports the same features.
malsumis # Thursday, February 5, 2009 12:16:40 PM
thanks for an honest answer. Is that the case even for old computers with a slow ~600mhz cpu and, lets say, and Geforce 2/radeon 256 series GPU ?
Martin RauscherHades32 # Thursday, February 5, 2009 2:42:44 PM
What about text rendering?
I absolutely HATE like text looks in Linux or OS X (and therefore in Safari under Windows, too).
But if you use DirectX or OpenGL I don't think you will be able to use ClearType...
How are you going to handle this issue?
Aux # Thursday, February 5, 2009 2:43:28 PM
Шуйский Николай [krigstask, Ŝtérkrìg]Sterkrig # Thursday, February 5, 2009 9:38:14 PM
Originally posted by Hades32:
Does it look somehow differently?
malsumis # Thursday, February 5, 2009 10:25:59 PM
serious # Friday, February 6, 2009 7:35:06 AM
aw ... did I ever say I hate windows? (and yes, I use it, but only to play some games, work gets done in ubuntu)
ah, well, I'm sure opera's dev guys know what works best. I'd just have liked a openGL solution for everywhere
Aux # Friday, February 6, 2009 3:37:39 PM
Martin RauscherHades32 # Saturday, February 7, 2009 11:06:11 AM
Originally posted by Sterkrig:
Well, I can't say for Opera. But all text rendered around the system is rendered by the OS dependent font rendering software which uses different ways to soften text.
And YES it DOES look differently. Just download Safari for Windows to get a glimpse of what it would look like under OS X...
Шуйский Николай [krigstask, Ŝtérkrìg]Sterkrig # Saturday, February 7, 2009 1:33:38 PM
Originally posted by Hades32:
Well, there's minor differences, but I never bothered about them, moreover, I'm not sure I can determine OSes by font screenshots in "blind" test.
Fiddler3791 # Monday, February 9, 2009 9:34:32 AM
With these changes, text quality is easily superior compared to Windows *or* MacOS.
Caveat: KDE and all Qt4 based apps ignore the slight filtering directive and look awful. Qt3 and Qt4.5 (unreleased) don't suffer from this bug.
Caveat 2: Some distributions ship with older, lower quality subpixel renderers (e.g. Fedora, openSUSE and archlinux). You can find updated xft and freetype packages, with massively improved quality: they usually go by the -lcd or -ubuntu nomer.
Edit: It is possible to use subpixel rendering with OpenGL or DirectX, even without shaders. Don't worry, cleartype et al should still work with the hardware accelerated Vega.
Aux # Monday, February 9, 2009 10:10:53 AM
Martin RauscherHades32 # Wednesday, April 15, 2009 1:27:19 PM
Means that you will shift the WHOLE UI to Vega? That would be great!
Elephant454 # Sunday, September 6, 2009 9:37:08 PM
Ferhad Fidanf-blog # Friday, October 16, 2009 9:52:51 AM
DirectX 9 or Open GL 2.0 are very high standarts for users like me. I don't use my computer to play games. Then DX 8 and Open GL 1.4 supporting graphics card is fine for me. Hey until five months I was using onboard SIS651 chipset for my graphics.
I hope your application wouldn't be DX10 style (if all the DX10 features supported use it), instead would be DX9 style (check which functions work and use them, for functions that don't work use software render...).
xeon0541 # Tuesday, November 3, 2009 9:02:07 AM
andreidbz # Friday, November 20, 2009 9:35:56 AM
Old-Nick # Monday, November 23, 2009 9:30:20 AM
Originally posted by andreidbz:
How do they(Wave & Vega) connected to each other?
Vladqasalater # Tuesday, December 22, 2009 2:51:34 PM
ΩJr.OmegaJunior # Tuesday, December 22, 2009 5:23:50 PM
Kristofferstoffix # Tuesday, December 22, 2009 5:45:55 PM
It would be great if it could, now that
it is going to be used for all the graphics
rendering.
pinfeng # Wednesday, March 3, 2010 9:47:19 AM
Originally posted by Ferhad Fidan:
I also use an older but perfectly 2D strong GeForce 2 MX 400 at home. Page rendering---and especially scrolling---works very well and smooth up to Opera 10.10.
However, the new VEGA engine in 10.50 is likely disabled due to my 3D-weak graphics card (only supporting DX7 or 8). This can be felt seriously... page rendering and scrolling are much slower now than it used to be in Opera 10.10.
Therefore, also the question from my side: Wouldn't it be more beneficial for the entire user community to have selective hardware acceleration for the different features?
Because my graphics card isn't able to handle more sophisticated 3D stuff like shadows or so, VEGA is turned off. But for features like normal page scrolling, for which my graphics card seems fast enough, there is then no way to take use of hardware acceleration...
tomassplatch # Wednesday, March 3, 2010 10:23:43 AM
pinfeng # Thursday, March 4, 2010 9:48:04 AM
In the current discussion surrounding release 10.50 and VEGA, upcoming hardware acceleration is seen as such a hype and new thing. This gives the impression that in previous versions there has not been any hardware acceleration.
But this I couldn't go along with... Page rendering and scrolling (the second important action in browsing) in 10.10 is really fast and smooth
Can this be confirmed by the development team?
Purdi # Thursday, March 4, 2010 9:57:34 AM
Originally posted by pinfeng:
Obviously not, since they have shown previews of it, which means that it has never been implemented in a public version.
Шуйский Николай [krigstask, Ŝtérkrìg]Sterkrig # Thursday, March 4, 2010 10:55:42 AM
There's hardware acceleration provided by OS and its graphic system.
pinfeng # Thursday, March 4, 2010 2:15:43 PM
So, then it is even more impressive how smooth rendering & scrolling worked in 10.10 on my AthlonXP 1600+ with DX7 graphics card! Opera had really the edge over FF, IE, and the like
Unfortunately, VEGA isn't that forbear with older systems...
Bella Martensbellamartens # Wednesday, June 23, 2010 11:10:19 AM
Kai OckendorfOckendorf # Thursday, June 24, 2010 7:30:36 AM
Georg Maiergeorgmaier # Sunday, August 15, 2010 12:26:16 PM
VioLance # Wednesday, August 18, 2010 2:57:27 PM
nidheeshrnidheeshroosevelt # Sunday, December 26, 2010 4:51:58 PM