From 50259b5af5771743cd96d2bd060991029c42582b Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Tue, 25 Jan 2011 21:45:17 +1300 Subject: [PATCH] Bug 626962. Implement empty transactions for GL. r=bas,a=blocking --- gfx/layers/Layers.h | 6 ++---- gfx/layers/opengl/LayerManagerOGL.cpp | 15 +++++++++++---- gfx/layers/opengl/LayerManagerOGL.h | 1 + gfx/layers/opengl/ThebesLayerOGL.cpp | 20 ++++++++++++-------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 128c0eae656a..a31428b5779a 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -301,10 +301,8 @@ public: * returns false, and the caller must proceed with a normal layer tree * update and EndTransaction. */ - virtual bool EndEmptyTransaction() - { - return false; - } + virtual bool EndEmptyTransaction() = 0; + /** * Function called to draw the contents of each ThebesLayer. * aRegionToDraw contains the region that needs to be drawn. diff --git a/gfx/layers/opengl/LayerManagerOGL.cpp b/gfx/layers/opengl/LayerManagerOGL.cpp index 3f0166c07849..21f33c723883 100644 --- a/gfx/layers/opengl/LayerManagerOGL.cpp +++ b/gfx/layers/opengl/LayerManagerOGL.cpp @@ -392,6 +392,16 @@ LayerManagerOGL::BeginTransactionWithTarget(gfxContext *aTarget) mTarget = aTarget; } +bool +LayerManagerOGL::EndEmptyTransaction() +{ + if (!mRoot) + return false; + + EndTransaction(nsnull, nsnull); + return true; +} + void LayerManagerOGL::EndTransaction(DrawThebesLayerCallback aCallback, void* aCallbackData) @@ -413,10 +423,7 @@ LayerManagerOGL::EndTransaction(DrawThebesLayerCallback aCallback, mThebesLayerCallback = aCallback; mThebesLayerCallbackData = aCallbackData; - // NULL callback means "non-painting transaction" - if (aCallback) { - Render(); - } + Render(); mThebesLayerCallback = nsnull; mThebesLayerCallbackData = nsnull; diff --git a/gfx/layers/opengl/LayerManagerOGL.h b/gfx/layers/opengl/LayerManagerOGL.h index 3f2d2c74c58a..15d2da39642f 100644 --- a/gfx/layers/opengl/LayerManagerOGL.h +++ b/gfx/layers/opengl/LayerManagerOGL.h @@ -136,6 +136,7 @@ public: void EndConstruction(); + virtual bool EndEmptyTransaction(); virtual void EndTransaction(DrawThebesLayerCallback aCallback, void* aCallbackData); diff --git a/gfx/layers/opengl/ThebesLayerOGL.cpp b/gfx/layers/opengl/ThebesLayerOGL.cpp index f2038b53c060..a923540f09a9 100644 --- a/gfx/layers/opengl/ThebesLayerOGL.cpp +++ b/gfx/layers/opengl/ThebesLayerOGL.cpp @@ -693,14 +693,18 @@ ThebesLayerOGL::RenderLayer(int aPreviousFrameBuffer, LayerManager::DrawThebesLayerCallback callback = mOGLManager->GetThebesLayerCallback(); - void* callbackData = mOGLManager->GetThebesLayerCallbackData(); - callback(this, state.mContext, state.mRegionToDraw, - state.mRegionToInvalidate, callbackData); - // Everything that's visible has been validated. Do this instead of - // OR-ing with aRegionToDraw, since that can lead to a very complex region - // here (OR doesn't automatically simplify to the simplest possible - // representation of a region.) - mValidRegion.Or(mValidRegion, mVisibleRegion); + if (!callback) { + NS_ERROR("GL should never need to update ThebesLayers in an empty transaction"); + } else { + void* callbackData = mOGLManager->GetThebesLayerCallbackData(); + callback(this, state.mContext, state.mRegionToDraw, + state.mRegionToInvalidate, callbackData); + // Everything that's visible has been validated. Do this instead of + // OR-ing with aRegionToDraw, since that can lead to a very complex region + // here (OR doesn't automatically simplify to the simplest possible + // representation of a region.) + mValidRegion.Or(mValidRegion, mVisibleRegion); + } } DEBUG_GL_ERROR_CHECK(gl());