diff options
Diffstat (limited to 'libs/hwui/LayerRenderer.cpp')
| -rw-r--r-- | libs/hwui/LayerRenderer.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index e38b479..e2d9ea3 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -294,8 +294,8 @@ void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t he if (renderTarget != layer->getRenderTarget()) { layer->setRenderTarget(renderTarget); layer->bindTexture(); - layer->setFilter(GL_NEAREST, GL_NEAREST, false, true); - layer->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, false, true); + layer->setFilter(GL_NEAREST, false, true); + layer->setWrap(GL_CLAMP_TO_EDGE, false, true); } } } @@ -305,8 +305,10 @@ void LayerRenderer::destroyLayer(Layer* layer) { LAYER_RENDERER_LOGD("Recycling layer, %dx%d fbo = %d", layer->getWidth(), layer->getHeight(), layer->getFbo()); - if (layer->getFbo()) { - Caches::getInstance().fboCache.put(layer->getFbo()); + GLuint fbo = layer->getFbo(); + if (fbo) { + flushLayer(layer); + Caches::getInstance().fboCache.put(fbo); } if (!Caches::getInstance().layerCache.put(layer)) { @@ -331,6 +333,26 @@ void LayerRenderer::destroyLayerDeferred(Layer* layer) { } } +void LayerRenderer::flushLayer(Layer* layer) { +#ifdef GL_EXT_discard_framebuffer + GLuint fbo = layer->getFbo(); + if (layer && fbo) { + // If possible, discard any enqueud operations on deferred + // rendering architectures + if (Caches::getInstance().extensions.hasDiscardFramebuffer()) { + GLuint previousFbo; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &previousFbo); + + GLenum attachments = GL_COLOR_ATTACHMENT0; + if (fbo != previousFbo) glBindFramebuffer(GL_FRAMEBUFFER, fbo); + glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, &attachments); + + if (fbo != previousFbo) glBindFramebuffer(GL_FRAMEBUFFER, previousFbo); + } + } +#endif +} + bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) { Caches& caches = Caches::getInstance(); if (layer && layer->isTextureLayer() && bitmap->width() <= caches.maxTextureSize && |
