diff options
-rw-r--r-- | libs/hwui/LayerRenderer.cpp | 72 | ||||
-rw-r--r-- | tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java | 2 |
2 files changed, 39 insertions, 35 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); + } } } diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java index 19ee5c7..c857ded 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java @@ -17,7 +17,6 @@ package com.android.test.hwui; import android.animation.AnimatorSet; -import android.animation.ObjectAnimator; import android.app.Activity; import android.graphics.SurfaceTexture; import android.hardware.Camera; @@ -25,7 +24,6 @@ import android.os.Bundle; import android.view.Gravity; import android.view.TextureView; import android.view.View; -import android.view.ViewGroup; import android.widget.Button; import android.widget.FrameLayout; |