diff options
author | Romain Guy <romainguy@google.com> | 2011-06-24 17:53:53 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2011-06-24 17:53:53 -0700 |
commit | 4a5a71518a71a44dbccb3af9a08b82056ea748b3 (patch) | |
tree | d04dafb488a7bfde32e153980a6831c84f93833e /libs/hwui | |
parent | 80429c458506485904715180d10584092a5cd082 (diff) | |
download | frameworks_base-4a5a71518a71a44dbccb3af9a08b82056ea748b3.zip frameworks_base-4a5a71518a71a44dbccb3af9a08b82056ea748b3.tar.gz frameworks_base-4a5a71518a71a44dbccb3af9a08b82056ea748b3.tar.bz2 |
Don't set texture parameters on every frame.
Change-Id: Iec368405ad6a4ccfd569a0b3b4d681871a770396
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/LayerRenderer.cpp | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index b9ef33a..e034a86 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -166,30 +166,6 @@ void LayerRenderer::generateMesh() { // Layers management /////////////////////////////////////////////////////////////////////////////// -Layer* LayerRenderer::createTextureLayer(bool isOpaque) { - LAYER_RENDERER_LOGD("Creating new texture layer"); - - Layer* layer = new Layer(0, 0); - layer->isCacheable = false; - layer->isTextureLayer = true; - layer->blend = !isOpaque; - layer->empty = true; - layer->fbo = 0; - layer->colorFilter = NULL; - layer->fbo = 0; - layer->layer.set(0.0f, 0.0f, 0.0f, 0.0f); - layer->texCoords.set(0.0f, 1.0f, 0.0f, 1.0f); - layer->alpha = 255; - layer->mode = SkXfermode::kSrcOver_Mode; - layer->colorFilter = NULL; - layer->region.clear(); - - glActiveTexture(GL_TEXTURE0); - glGenTextures(1, &layer->texture); - - return layer; -} - Layer* LayerRenderer::createLayer(uint32_t width, uint32_t height, bool isOpaque) { LAYER_RENDERER_LOGD("Creating new layer %dx%d", width, height); @@ -269,6 +245,41 @@ bool LayerRenderer::resizeLayer(Layer* layer, uint32_t width, uint32_t height) { return true; } +static void setTextureParameters(Layer* layer) { + glBindTexture(layer->renderTarget, layer->texture); + + glTexParameteri(layer->renderTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(layer->renderTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexParameteri(layer->renderTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(layer->renderTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + +Layer* LayerRenderer::createTextureLayer(bool isOpaque) { + LAYER_RENDERER_LOGD("Creating new texture layer"); + + Layer* layer = new Layer(0, 0); + layer->isCacheable = false; + layer->isTextureLayer = true; + layer->blend = !isOpaque; + layer->empty = true; + layer->fbo = 0; + layer->colorFilter = NULL; + layer->fbo = 0; + layer->layer.set(0.0f, 0.0f, 0.0f, 0.0f); + layer->texCoords.set(0.0f, 1.0f, 0.0f, 1.0f); + layer->alpha = 255; + layer->mode = SkXfermode::kSrcOver_Mode; + layer->colorFilter = NULL; + layer->region.clear(); + layer->renderTarget = GL_NONE; // see ::updateTextureLayer() + + glActiveTexture(GL_TEXTURE0); + glGenTextures(1, &layer->texture); + + return layer; +} + void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t height, bool isOpaque, GLenum renderTarget, float* transform) { if (layer) { @@ -279,16 +290,11 @@ void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t he layer->region.set(width, height); layer->regionRect.set(0.0f, 0.0f, width, height); layer->texTransform.load(transform); - layer->renderTarget = renderTarget; - // TODO: This should be done only when the render target has changed - glBindTexture(layer->renderTarget, layer->texture); - - glTexParameteri(layer->renderTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(layer->renderTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glTexParameteri(layer->renderTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(layer->renderTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (renderTarget != layer->renderTarget) { + layer->renderTarget = renderTarget; + setTextureParameters(layer); + } } } |