Further reduce the number of GL commands sent to the driver
Change-Id: Id922b2a166ea4573b767c27d3195e11c70320b23
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index c30923f..38630b8 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -182,14 +182,15 @@
Layer* LayerRenderer::createLayer(uint32_t width, uint32_t height, bool isOpaque) {
LAYER_RENDERER_LOGD("Requesting new render layer %dx%d", width, height);
- GLuint fbo = Caches::getInstance().fboCache.get();
+ Caches& caches = Caches::getInstance();
+ GLuint fbo = caches.fboCache.get();
if (!fbo) {
LOGW("Could not obtain an FBO");
return NULL;
}
- glActiveTexture(GL_TEXTURE0);
- Layer* layer = Caches::getInstance().layerCache.get(width, height);
+ caches.activeTexture(0);
+ Layer* layer = caches.layerCache.get(width, height);
if (!layer) {
LOGW("Could not obtain a layer");
return NULL;
@@ -220,7 +221,7 @@
fbo, width, height);
glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
- Caches::getInstance().fboCache.put(fbo);
+ caches.fboCache.put(fbo);
layer->deleteTexture();
delete layer;
@@ -274,7 +275,7 @@
layer->region.clear();
layer->setRenderTarget(GL_NONE); // see ::updateTextureLayer()
- glActiveTexture(GL_TEXTURE0);
+ Caches::getInstance().activeTexture(0);
layer->generateTexture();
return layer;
@@ -406,7 +407,7 @@
glGenTextures(1, &texture);
if ((error = glGetError()) != GL_NO_ERROR) goto error;
- glActiveTexture(GL_TEXTURE0);
+ caches.activeTexture(0);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);