Introduction
Since bug 715768, Windows 7 and Vista have been rendering through a Thebes wrapper to the Direct2D backend of our new 2D API. Unfortunately, that means most of the benefit from our better API is lost to the wrapper.
Therefore, we should start writing code that uses the API directly, conditioned on a gfxContext actually wrapping a DrawTarget.
Relevant code:
- mozilla::gfx::DrawTarget, defined in gfx/2d/2D.h
- The remainder of the 2D API is also defined in 2D.h. Read DrawTarget to find out what you can do, and then find the structures you need in 2D.h.
- mozilla::gfx::Factory, defined in gfx/2d/2D.h, will let you create objects appropriate to the system's default backend, or whatever backend you want.
Of special note: backend-specific types (e.g. DrawTargetCairo) are not exposed to consumer code. You can query a backend for its type, but you cannot downcast it.
Overview of what is involved
See Looking for a good first place to contribute to Gecko gfx? for a good summary of the kind of changes involved and tips on how to get started.
Conversion opportunities
Project | Bug(s) | File(s) touched | Description |
---|---|---|---|
Retain gradients | bug 761393 | nsCSSRendering.cpp, among others (which?) | Realizing gradients can be extremely expensive, due to the way they're implemented in Direct2D (and possibly also Skia).
|
gfxDrawable conversion | bug 767132 | gfx/thebes/gfxDrawable.cpp | We currently draw images (and similar things) using gfxDrawable, which only knows how to use Thebes. We should be smart enough to detect when a gfxContext is a wrapper around a DrawTarget, and call the DrawTarget functions directly to avoid wrapper overhead. |
Borders | bug 767135 | nsCSSRendering.cpp | Drawing borders accurately is very complex, and often involves gradients and other things to be correct. We need to rewrite our border rendering code to use DrawTargets and retain the appropriate objects so we can get greater performance. |