Open Bug 571092 Opened 14 years ago Updated 2 years ago

use a cached buffer for pbuffer->thebes conversion

Categories

(Core :: Graphics, defect)

defect

Tracking

()

People

(Reporter: vlad, Unassigned)

Details

Attachments

(1 file)

For pbuffer contexts, if we need to render into anything other than via a GL canvas layer, we have to pull out a gfxImageSurface.  Right now, we end up creating a new gfxImageSurface each time for this.  Instead, we can do better and cache that, including potentially creating a faster surface type (e.g. a DIB-backed gfxWindowsSurface).

This patch also gives the ContextFormat to the GLContext to keep around, for future getting and/or decision making.
Attachment #450210 - Flags: review?(bas.schouten)
Comment on attachment 450210 [details] [diff] [review]
optimize pbuffer contexts some

I think a lot of this will need to be reworked to optimize it when using Direct2D or a D3D layer manager, in those cases we could probably/hopefully do something more clever (i.e. directly ReadPixels into a D3D texture, or even OpenCL for interop where available!). But this looks good to me for now.

># HG changeset patch
># Parent af2bc8c327a4c0aae082b639ccaaf36c30ca6a8e
>
>diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp
>--- a/content/canvas/src/WebGLContext.cpp
>+++ b/content/canvas/src/WebGLContext.cpp
>@@ -300,22 +300,21 @@ WebGLContext::GetCanvasLayer(LayerManage
> 
>   mD3DManager->SetShaderMode(LayerManagerD3D9::RGBLAYER);
> 
>-  if (!mGLBufferIsPremultiplied) {
>+  if (false /*!mGLBufferIsPremultiplied*/) {
>     device()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
>   }

We should probably still use this rather than premultiplying in software if we can do it in layers!

>@@ -241,10 +252,52 @@ public:
>         }
>     }
> 
>+    already_AddRefed<gfxASurface> GetPBufferThebesSurface()
>+    {
>+        if (mPBuffer)
>+            return nsnull;
>+
>+        if (!mImageSurface) {
>+            mWindowsSurface = new gfxWindowsSurface(mSize,
>+                                                    gfxASurface::ImageFormatARGB32);
>+

I wonder if there's a lot of value in having this as a windows surface..  but I guess it does no harm either.
Attachment #450210 - Flags: review?(bas.schouten) → review+
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: