summaryrefslogtreecommitdiff
path: root/libs/hwui/Caches.cpp
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2012-07-13 15:31:30 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2012-07-13 15:31:30 -0700
commitc9cf9e5459c05f05b29ec81b0e83e154816f7595 (patch)
tree54e271e1a95109f9e6ce7c88f1edd63b3248dff9 /libs/hwui/Caches.cpp
parentbb033ea3620a2c30f85a91986aa09a37960c8366 (diff)
parent586cae3ac69c0c667fbf8a954edbd399f620a717 (diff)
Merge "Improve rendering speed by disabling scissor tests"
Diffstat (limited to 'libs/hwui/Caches.cpp')
-rw-r--r--libs/hwui/Caches.cpp27
1 files changed, 26 insertions, 1 deletions
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;
}