summaryrefslogtreecommitdiffstats
path: root/libs/hwui
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2011-12-12 18:14:06 -0800
committerRomain Guy <romainguy@google.com>2011-12-12 18:14:06 -0800
commit39d252a6632d057d5077f7eaf1b8ed7a142f3397 (patch)
treec840b4084ba7fb8be54b0d387953cc6a15decbdd /libs/hwui
parentf44e66fcf70aa4a354deca72dfbd3b29c29302be (diff)
downloadframeworks_base-39d252a6632d057d5077f7eaf1b8ed7a142f3397.zip
frameworks_base-39d252a6632d057d5077f7eaf1b8ed7a142f3397.tar.gz
frameworks_base-39d252a6632d057d5077f7eaf1b8ed7a142f3397.tar.bz2
Various OpenGL optimizations
Change-Id: Ib0742c96f10f5f50e7e5148b742c31b6c232d127
Diffstat (limited to 'libs/hwui')
-rw-r--r--libs/hwui/GradientCache.cpp4
-rw-r--r--libs/hwui/LayerCache.cpp4
-rw-r--r--libs/hwui/LayerRenderer.cpp2
-rw-r--r--libs/hwui/OpenGLRenderer.cpp19
-rw-r--r--libs/hwui/TextDropShadowCache.cpp4
-rw-r--r--libs/hwui/Texture.h2
6 files changed, 14 insertions, 21 deletions
diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp
index aacf22a..a88a59a 100644
--- a/libs/hwui/GradientCache.cpp
+++ b/libs/hwui/GradientCache.cpp
@@ -171,8 +171,8 @@ void GradientCache::generateTexture(SkBitmap* bitmap, Texture* texture) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bitmap->rowBytesAsPixels(), texture->height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, bitmap->getPixels());
- texture->setFilter(GL_LINEAR, GL_LINEAR);
- texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
+ texture->setFilter(GL_LINEAR);
+ texture->setWrap(GL_CLAMP_TO_EDGE);
}
}; // namespace uirenderer
diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp
index 5298125..324765b 100644
--- a/libs/hwui/LayerCache.cpp
+++ b/libs/hwui/LayerCache.cpp
@@ -108,8 +108,8 @@ Layer* LayerCache::get(const uint32_t width, const uint32_t height) {
layer->generateTexture();
layer->bindTexture();
- layer->setFilter(GL_NEAREST, GL_NEAREST);
- layer->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, false);
+ layer->setFilter(GL_NEAREST);
+ layer->setWrap(GL_CLAMP_TO_EDGE, false);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
#if DEBUG_LAYERS
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index 3f940bb..c30923f 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -458,6 +458,8 @@ bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
}
error:
+ glEnable(GL_SCISSOR_TEST);
+
#if DEBUG_OPENGL
if (error != GL_NO_ERROR) {
LOGD("GL error while copying layer into bitmap = 0x%x", error);
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index fa17aad..e7eaa50 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -141,13 +141,9 @@ void OpenGLRenderer::setViewport(int width, int height) {
mFirstSnapshot->height = height;
mFirstSnapshot->viewport.set(0, 0, width, height);
- mDirtyClip = false;
-
glDisable(GL_DITHER);
- glViewport(0, 0, width, height);
-
+ glEnable(GL_SCISSOR_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
glEnableVertexAttribArray(Program::kBindingPosition);
}
@@ -161,12 +157,13 @@ void OpenGLRenderer::prepareDirty(float left, float top, float right, float bott
mSnapshot = new Snapshot(mFirstSnapshot,
SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
mSnapshot->fbo = getTargetFbo();
-
mSaveCount = 1;
- glEnable(GL_SCISSOR_TEST);
+ glViewport(0, 0, mWidth, mHeight);
glScissor(left, mSnapshot->height - bottom, right - left, bottom - top);
+
mSnapshot->setClip(left, top, right, bottom);
+ mDirtyClip = false;
if (!opaque) {
glClear(GL_COLOR_BUFFER_BIT);
@@ -214,13 +211,9 @@ void OpenGLRenderer::resume() {
glEnable(GL_SCISSOR_TEST);
dirtyClip();
- glDisable(GL_DITHER);
-
glBindFramebuffer(GL_FRAMEBUFFER, snapshot->fbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
- glEnableVertexAttribArray(Program::kBindingPosition);
-
mCaches.blend = true;
glEnable(GL_BLEND);
glBlendFunc(mCaches.lastSrcMode, mCaches.lastDstMode);
@@ -916,10 +909,8 @@ void OpenGLRenderer::clearLayerRegions() {
setupDrawProgram();
setupDrawPureColorUniforms();
setupDrawModelViewTranslate(0.0f, 0.0f, 0.0f, 0.0f, true);
+ setupDrawVertices(&mesh[0].position[0]);
- mCaches.unbindMeshBuffer();
- glVertexAttribPointer(mCaches.currentProgram->position, 2, GL_FLOAT, GL_FALSE,
- gVertexStride, &mesh[0].position[0]);
glDrawArrays(GL_TRIANGLES, 0, count * 6);
glEnable(GL_SCISSOR_TEST);
diff --git a/libs/hwui/TextDropShadowCache.cpp b/libs/hwui/TextDropShadowCache.cpp
index a3ee63b..bbefec6 100644
--- a/libs/hwui/TextDropShadowCache.cpp
+++ b/libs/hwui/TextDropShadowCache.cpp
@@ -137,8 +137,8 @@ ShadowTexture* TextDropShadowCache::get(SkPaint* paint, const char* text, uint32
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texture->width, texture->height, 0,
GL_ALPHA, GL_UNSIGNED_BYTE, shadow.image);
- texture->setFilter(GL_LINEAR, GL_LINEAR);
- texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
+ texture->setFilter(GL_LINEAR);
+ texture->setWrap(GL_CLAMP_TO_EDGE);
if (size < mMaxSize) {
if (mDebugEnabled) {
diff --git a/libs/hwui/Texture.h b/libs/hwui/Texture.h
index a4aed07..1adf2c7 100644
--- a/libs/hwui/Texture.h
+++ b/libs/hwui/Texture.h
@@ -49,7 +49,7 @@ struct Texture {
GLenum renderTarget = GL_TEXTURE_2D) {
if (firstWrap || force || wrapS != this->wrapS || wrapT != this->wrapT) {
- firstWrap = true;
+ firstWrap = false;
this->wrapS = wrapS;
this->wrapT = wrapT;