diff options
author | Romain Guy <romainguy@google.com> | 2012-03-02 13:37:47 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-03-02 13:37:47 -0800 |
commit | 2bf68f063b0077ddef6ebfe54f2ae5e063c2c229 (patch) | |
tree | da02b6113cb29371fb1e7321ffaf567bdf0fca8a /libs/hwui | |
parent | d8f45c16a896d76d06550a91d78e8c5a3a57275a (diff) | |
download | frameworks_base-2bf68f063b0077ddef6ebfe54f2ae5e063c2c229.zip frameworks_base-2bf68f063b0077ddef6ebfe54f2ae5e063c2c229.tar.gz frameworks_base-2bf68f063b0077ddef6ebfe54f2ae5e063c2c229.tar.bz2 |
Deferred layer updates
Change-Id: I83d9e564fe274db658dcee9e0cc5bbf9223ebb49
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/Layer.h | 24 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 18 |
2 files changed, 42 insertions, 0 deletions
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index ee6ef1a..f243177 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -37,6 +37,10 @@ namespace uirenderer { // Layers /////////////////////////////////////////////////////////////////////////////// +// Forward declarations +class OpenGLRenderer; +class DisplayList; + /** * A layer has dimensions and is backed by an OpenGL texture or FBO. */ @@ -51,6 +55,9 @@ struct Layer { texture.width = layerWidth; texture.height = layerHeight; colorFilter = NULL; + deferredUpdateScheduled = false; + renderer = NULL; + displayList = NULL; } ~Layer() { @@ -77,6 +84,15 @@ struct Layer { regionRect.translate(layer.left, layer.top); } + void updateDeferred(OpenGLRenderer* renderer, DisplayList* displayList, + int left, int top, int right, int bottom) { + this->renderer = renderer; + this->displayList = displayList; + const Rect r(left, top, right, bottom); + dirtyRect.unionWith(r); + deferredUpdateScheduled = true; + } + inline uint32_t getWidth() { return texture.width; } @@ -234,6 +250,14 @@ struct Layer { uint16_t* meshIndices; GLsizei meshElementCount; + /** + * Used for deferred updates. + */ + bool deferredUpdateScheduled; + OpenGLRenderer* renderer; + DisplayList* displayList; + Rect dirtyRect; + private: /** * Name of the FBO used to render the layer. If the name is 0 diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index e3148e8..339ae0a 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2364,6 +2364,24 @@ void OpenGLRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) { return; } + if (layer->deferredUpdateScheduled && layer->renderer && layer->displayList) { + OpenGLRenderer* renderer = layer->renderer; + Rect& dirty = layer->dirtyRect; + + interrupt(); + renderer->setViewport(layer->layer.getWidth(), layer->layer.getHeight()); + renderer->prepareDirty(dirty.left, dirty.top, dirty.right, dirty.bottom, !layer->isBlend()); + renderer->drawDisplayList(layer->displayList, layer->getWidth(), layer->getHeight(), + dirty, DisplayList::kReplayFlag_ClipChildren); + renderer->finish(); + resume(); + + dirty.setEmpty(); + layer->deferredUpdateScheduled = false; + layer->renderer = NULL; + layer->displayList = NULL; + } + mCaches.activeTexture(0); int alpha; |