summaryrefslogtreecommitdiffstats
path: root/libs/hwui/Dither.cpp
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2013-04-08 19:45:40 -0700
committerRomain Guy <romainguy@google.com>2013-04-09 10:12:47 -0700
commit032d47af737d803e841ab79f38ac9068a46c9aeb (patch)
treec3428ff4c80f1274cd4a1ada4567ab1ed940c1b5 /libs/hwui/Dither.cpp
parent50b9eb1c7375a87525d44a036337a8ba18eba55b (diff)
downloadframeworks_base-032d47af737d803e841ab79f38ac9068a46c9aeb.zip
frameworks_base-032d47af737d803e841ab79f38ac9068a46c9aeb.tar.gz
frameworks_base-032d47af737d803e841ab79f38ac9068a46c9aeb.tar.bz2
Change the dither texture's swizzling
This is a more elegant way to sample from a float alpha texture. Instead of sampling from the red channel in the fragment shader we can set the alpha channel swizzle to redirect it to the red channel. This lets us sample from the alpha channel in the fragment shader and get the correct value. Change-Id: I95bbf7a82964e1bf42c0fee1b782b6bdbbcef618
Diffstat (limited to 'libs/hwui/Dither.cpp')
-rw-r--r--libs/hwui/Dither.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libs/hwui/Dither.cpp b/libs/hwui/Dither.cpp
index 9bc5c14..51f1e39 100644
--- a/libs/hwui/Dither.cpp
+++ b/libs/hwui/Dither.cpp
@@ -38,6 +38,10 @@ void Dither::bindDitherTexture() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
if (useFloatTexture) {
+ // We use a R16F texture, let's remap the alpha channel to the
+ // red channel to avoid changing the shader sampling code on GL ES 3.0+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED);
+
float dither = 1.0f / (255.0f * DITHER_KERNEL_SIZE * DITHER_KERNEL_SIZE);
const GLfloat pattern[] = {
0 * dither, 8 * dither, 2 * dither, 10 * dither,