Skip navigation.

Log in | Sign up

Opera Core Concerns

Official blog for Core developers at Opera

Vega - Opera's vector graphics library

, , , ,

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.

Presto 2.1.1 Web standards supportCarakan

Comments

Tamil 4. February 2009, 09:41

:up:

Sterkrig 4. February 2009, 10:23

In the core version we are currently developing, Presto 2.3 ...


So Presto 2.2 has been feature-frozen? Only bugfixing etc?

malsumis 4. February 2009, 11:11

Would it be possible to feature-test a video card and enable partial hardware acceleration with just a subset of functions? This would be especially useful for older cards that do not support pixel or vertex shading.

Aux 4. February 2009, 12:21

Oh, by the way. Do you plan to include 3D canvas in Opera 10? I'm currently working in some startup and we will need it (: And may I speak with your technical guys about Canvas and SVG implementation and performance from JS perspective?

brunitoc 4. February 2009, 12:36

WOW !:yikes: "The final reason is that it enables us to easily add advanced graphical effects to our UI and to web pages."

Cant wait to see that !!!!

:up:

Turin 4. February 2009, 13:13

Good post. Which is expected to have faster performance OpenGL or DirectX? I would hope that the optimizing is for OpenGL.

serious 4. February 2009, 13:17

why is there a D3D and OpenGL backend? Why not only use OpenGL on all platforms?

Aux 4. February 2009, 13:36

@serious: because some device vendors create buggy OpenGL drivers for Windows...

Jurgi 4. February 2009, 14:11

I've got some doubts, of course… Will VEGA work on Intel 945GM chips? As tomsguide says:

The graphics core of the 945GM is […] DirectX 9 compatible, but not entirely DirectX 9 compliant.


Precise, maybe, but not clear for me…

Aux 4. February 2009, 14:26

945GM is fine for Vista's Aero, so I think all the basics are inside and only advanced shares left out, but I did not any official data so...

Jurgi 4. February 2009, 16:02

✔ I suppose, that VEGA do not need more than Aero, so it should work fine. Thanks for info.

MadAtWork 4. February 2009, 16:30

Fun fact: Opera's SVG library is known as Balrog in Japan.

serious 4. February 2009, 16:38

@Aux: In what way? haven't had any real issues here w/ OGL games. Have a link for me maybe? :wink:

Chas4 4. February 2009, 17:21

:up:

_Grey_ 4. February 2009, 17:53

@tim: Do svg transforms work on cards if it works on 9.5 products? Since you're removing platform code, I guess it will not.

Well, too bad. Shader 1 card. Also what will you do on devices? Do all of them have better graphics cards than I have? P: Or is SVG not supported on mobiles anyway.

sms985 4. February 2009, 18:05

@brunito_c: Cant wait to see that !!!!
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!

KuraFire 4. February 2009, 18:30

What happens when retrieving CSS3 B&B properties via the DOM when Vega is not enabled due to insufficient hardware? Also, what will the DOM properties' names be? Is opera going to stick to the -o- prefix in CSS first and if so, will a DOM property become something like this:

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.

Chas4 4. February 2009, 18:52

Off-topic comments by various people removed by moderator. Please stay on topic.

timjoh 5. February 2009, 08:51

@malsumis: we can do that, the problem is that many pages using filters (SVG, canvas, text shadow) are actually slower in hardware without shaders than in software.

@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 5. February 2009, 12:16

@malsumis: we can do that, the problem is that many pages using filters (SVG, canvas, text shadow) are actually slower in hardware without shaders than in software.


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 ?

Hades32 5. February 2009, 14:42

This sounds great, but when you finally switch to Vega for all rendering I see a problem:
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 5. February 2009, 14:43

GF2 does not support shaders. Well, bump mapping is a kind of shader, but I mean in the way DX treats them. So it should be software rendering for such GPU.

Sterkrig 5. February 2009, 21:38

Originally posted by Hades32:

I absolutely HATE like text looks in Linux or OS X


Does it look somehow differently?

malsumis 5. February 2009, 22:25

@Aux : Actually GeForce 2 supports a primitive form of pixel shading known as Nvidia Shader Rasterizer(which actually didn't get any real use, and was unsupported in DirectX AFAIK). Anyways, you didn't follow the context, so this post is just to correct you ;P

serious 6. February 2009, 07:35

@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.


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 :wink:

Aux 6. February 2009, 15:37

@malsumis: my words were I mean in the way DX treats them, so I was correct. Yep, nVidia rasterizer was there and just like you said was unsupported in DirectX. (:

Hades32 7. February 2009, 11:06

Originally posted by Sterkrig:

Does it look somehow differently?


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...

Sterkrig 7. February 2009, 13:33

Originally posted by Hades32:

Just download Safari for Windows


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 9. February 2009, 09:34

@Hades32: Make sure you have subpixel rendering enabled and set filtering to slight. It also pays off to use the bytecode interpreter instead of the autohinter.

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 9. February 2009, 10:10

@The Fiddler: it is possible to use subpixel rendering even in plain software quite fast. The guy who introduced that feature to freetype initialy did it in software only and it was great!

Hades32 15. April 2009, 13:27

The final reason is that it enables us to easily add advanced graphical effects to our UI and to web pages.


Means that you will shift the WHOLE UI to Vega? That would be great! :D

Elephant454 6. September 2009, 21:37

Homer: Doh! I like the Simpsons!

f-blog 16. October 2009, 09:52

Oh, how much graphics memory than our graphics cards should have? :smile:
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. :smile:
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 3. November 2009, 09:02

i hope that can using opencl and directx 11 in future

andreidbz 20. November 2009, 09:35

When we'll see a beta with VEGA support? If it's in the works from 2007-2008 then you must have a build ready for testing. Also, Google Wave does not work in Opera right now. In vega will work ?

Old-Nick 23. November 2009, 09:30

Originally posted by andreidbz:

Google Wave does not work in Opera right now. In vega will work ?


How do they(Wave & Vega) connected to each other?

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.