From 586cae3ac69c0c667fbf8a954edbd399f620a717 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Fri, 13 Jul 2012 15:28:31 -0700 Subject: Improve rendering speed by disabling scissor tests This change improves execution of display lists, particularly on tiled renderers. The goal is to disable the scissor test as often as possible. Drawing commands are rarely clipped by View bounds so most of them can be drawn without doing a scissor test. The speed improvements scale with the number of views and drawing commands. Change-Id: Ibd9b5e051a3e4300562463805acc4fd744ba6266 --- libs/hwui/Caches.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'libs/hwui/Caches.cpp') diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index f2108203b9ba..214cc9255d0f 100644 --- a/libs/hwui/Caches.cpp +++ b/libs/hwui/Caches.cpp @@ -74,6 +74,7 @@ void Caches::init() { mTexCoordsArrayEnabled = false; + scissorEnabled = false; mScissorX = mScissorY = mScissorWidth = mScissorHeight = 0; glActiveTexture(gTextureUnits[0]); @@ -352,7 +353,9 @@ void Caches::activeTexture(GLuint textureUnit) { } void Caches::setScissor(GLint x, GLint y, GLint width, GLint height) { - if (x != mScissorX || y != mScissorY || width != mScissorWidth || height != mScissorHeight) { + if (scissorEnabled && (x != mScissorX || y != mScissorY || + width != mScissorWidth || height != mScissorHeight)) { + glScissor(x, y, width, height); mScissorX = x; @@ -362,6 +365,28 @@ void Caches::setScissor(GLint x, GLint y, GLint width, GLint height) { } } +void Caches::enableScissor() { + if (!scissorEnabled) { + glEnable(GL_SCISSOR_TEST); + scissorEnabled = true; + } +} + +void Caches::disableScissor() { + if (scissorEnabled) { + glDisable(GL_SCISSOR_TEST); + scissorEnabled = false; + } +} + +void Caches::setScissorEnabled(bool enabled) { + if (scissorEnabled != enabled) { + if (enabled) glEnable(GL_SCISSOR_TEST); + else glDisable(GL_SCISSOR_TEST); + scissorEnabled = enabled; + } +} + void Caches::resetScissor() { mScissorX = mScissorY = mScissorWidth = mScissorHeight = 0; } -- cgit v1.2.3-59-g8ed1b