summaryrefslogtreecommitdiff
path: root/libs/hwui/Dither.cpp
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2015-01-29 09:45:09 -0800
committer Chris Craik <ccraik@google.com> 2015-01-30 10:49:05 -0800
commit44eb2c00861098dd3e2950d923646814b4cc57c2 (patch)
tree2d232b14b931137cc7ebb3b012c3ce4530fa5cf4 /libs/hwui/Dither.cpp
parent1b68ce327aa37ee0c4e9580d75cb6781337c4312 (diff)
Refactor blending and texture gl state
Change-Id: Ia6b3c8b2afd3dfcee7f3ce401d846b789612054a
Diffstat (limited to 'libs/hwui/Dither.cpp')
-rw-r--r--libs/hwui/Dither.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/libs/hwui/Dither.cpp b/libs/hwui/Dither.cpp
index 12d9389276c9..d637ec14d390 100644
--- a/libs/hwui/Dither.cpp
+++ b/libs/hwui/Dither.cpp
@@ -24,7 +24,10 @@ namespace uirenderer {
// Lifecycle
///////////////////////////////////////////////////////////////////////////////
-Dither::Dither(): mCaches(nullptr), mInitialized(false), mDitherTexture(0) {
+Dither::Dither(Caches& caches)
+ : mCaches(caches)
+ , mInitialized(false)
+ , mDitherTexture(0) {
}
void Dither::bindDitherTexture() {
@@ -32,7 +35,7 @@ void Dither::bindDitherTexture() {
bool useFloatTexture = Extensions::getInstance().hasFloatTextures();
glGenTextures(1, &mDitherTexture);
- mCaches->bindTexture(mDitherTexture);
+ mCaches.textureState().bindTexture(mDitherTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -71,13 +74,13 @@ void Dither::bindDitherTexture() {
mInitialized = true;
} else {
- mCaches->bindTexture(mDitherTexture);
+ mCaches.textureState().bindTexture(mDitherTexture);
}
}
void Dither::clear() {
if (mInitialized) {
- mCaches->deleteTexture(mDitherTexture);
+ mCaches.textureState().deleteTexture(mDitherTexture);
mInitialized = false;
}
}
@@ -87,10 +90,8 @@ void Dither::clear() {
///////////////////////////////////////////////////////////////////////////////
void Dither::setupProgram(Program* program, GLuint* textureUnit) {
- if (!mCaches) mCaches = &Caches::getInstance();
-
GLuint textureSlot = (*textureUnit)++;
- mCaches->activeTexture(textureSlot);
+ mCaches.textureState().activateTexture(textureSlot);
bindDitherTexture();