summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2010-01-19 17:54:27 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-01-19 17:54:27 -0800
commit52a014492c10d825ec26b2179bd8369bf78363ef (patch)
tree9f709b4f3c467fc6544da1cac709b5eafcfd971a
parent2d51bff2b6597804307d8883a071ff18adc2644a (diff)
parente20e3b41db0bc8bb68f40e8a60b351933028ffd6 (diff)
downloadframeworks_base-52a014492c10d825ec26b2179bd8369bf78363ef.zip
frameworks_base-52a014492c10d825ec26b2179bd8369bf78363ef.tar.gz
frameworks_base-52a014492c10d825ec26b2179bd8369bf78363ef.tar.bz2
Merge "Fix RS mipmap generation for 8 bit alpha textures."
-rw-r--r--libs/rs/rsAllocation.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index b4ec1a2..1ae2317 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -366,6 +366,25 @@ static void mip8888(const Adapter2D &out, const Adapter2D &in)
}
}
+static void mip8(const Adapter2D &out, const Adapter2D &in)
+{
+ uint32_t w = out.getDimX();
+ uint32_t h = out.getDimY();
+
+ for (uint32_t y=0; y < h; y++) {
+ uint8_t *oPtr = static_cast<uint8_t *>(out.getElement(0, y));
+ const uint8_t *i1 = static_cast<uint8_t *>(in.getElement(0, y*2));
+ const uint8_t *i2 = static_cast<uint8_t *>(in.getElement(0, y*2+1));
+
+ for (uint32_t x=0; x < w; x++) {
+ *oPtr = (uint8_t)(((uint32_t)i1[0] + i1[1] + i2[0] + i2[1]) * 0.25f);
+ oPtr ++;
+ i1 += 2;
+ i2 += 2;
+ }
+ }
+}
+
static void mip(const Adapter2D &out, const Adapter2D &in)
{
switch(out.getBaseType()->getElement()->getSizeBits()) {
@@ -375,6 +394,9 @@ static void mip(const Adapter2D &out, const Adapter2D &in)
case 16:
mip565(out, in);
break;
+ case 8:
+ mip8(out, in);
+ break;
}