aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-10 14:44:56 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-10 14:44:56 +0000
commit0a6151d66cc32d91eca037c91e557158cf8a2be2 (patch)
tree7fe96285f9fee5c8804bbbc60dd0395b983511a0 /bench
parentb006fe7e2f6178ce076a5e2c76b4540d3d27ca98 (diff)
Revert "Revert "change SkColorTable to be immutable""
This reverts commit b8162cb840f4cb6002ef68d5ac775c6a122c52a9. Fixed was call-sites in benches that used the (now gone) setIsOpaque api. R=scroggo@google.com Review URL: https://codereview.chromium.org/26572006 git-svn-id: http://skia.googlecode.com/svn/trunk@11695 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r--bench/BitmapBench.cpp14
-rw-r--r--bench/RepeatTileBench.cpp12
2 files changed, 13 insertions, 13 deletions
diff --git a/bench/BitmapBench.cpp b/bench/BitmapBench.cpp
index 9b3a6a29dd..982c917c02 100644
--- a/bench/BitmapBench.cpp
+++ b/bench/BitmapBench.cpp
@@ -33,9 +33,9 @@ static uint8_t compute666Index(SkPMColor c) {
return convByteTo6(r) * 36 + convByteTo6(g) * 6 + convByteTo6(b);
}
-static void convertToIndex666(const SkBitmap& src, SkBitmap* dst) {
- SkColorTable* ctable = new SkColorTable(216);
- SkPMColor* colors = ctable->lockColors();
+static void convertToIndex666(const SkBitmap& src, SkBitmap* dst, bool isOpaque) {
+ SkPMColor storage[216];
+ SkPMColor* colors = storage;
// rrr ggg bbb
for (int r = 0; r < 6; r++) {
int rr = conv6ToByte(r);
@@ -47,7 +47,8 @@ static void convertToIndex666(const SkBitmap& src, SkBitmap* dst) {
}
}
}
- ctable->unlockColors(true);
+ SkColorTable* ctable = new SkColorTable(storage, 216,
+ isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
dst->setConfig(SkBitmap::kIndex8_Config, src.width(), src.height());
dst->allocPixels(ctable);
ctable->unref();
@@ -120,14 +121,11 @@ protected:
onDrawIntoBitmap(bm);
if (SkBitmap::kIndex8_Config == fConfig) {
- convertToIndex666(bm, &fBitmap);
+ convertToIndex666(bm, &fBitmap, fIsOpaque);
} else {
fBitmap = bm;
}
- if (fBitmap.getColorTable()) {
- fBitmap.getColorTable()->setIsOpaque(fIsOpaque);
- }
fBitmap.setIsOpaque(fIsOpaque);
fBitmap.setIsVolatile(fIsVolatile);
}
diff --git a/bench/RepeatTileBench.cpp b/bench/RepeatTileBench.cpp
index c311c4af6c..612a149d6d 100644
--- a/bench/RepeatTileBench.cpp
+++ b/bench/RepeatTileBench.cpp
@@ -52,9 +52,10 @@ static uint8_t compute_666_index(SkPMColor c) {
return conv_byte_to_6(r) * 36 + conv_byte_to_6(g) * 6 + conv_byte_to_6(b);
}
-static void convert_to_index666(const SkBitmap& src, SkBitmap* dst) {
- SkColorTable* ctable = new SkColorTable(216);
- SkPMColor* colors = ctable->lockColors();
+static void convert_to_index666(const SkBitmap& src, SkBitmap* dst,
+ bool isOpaque) {
+ SkPMColor storage[216];
+ SkPMColor* colors = storage;
// rrr ggg bbb
for (int r = 0; r < 6; r++) {
int rr = conv_6_to_byte(r);
@@ -66,7 +67,8 @@ static void convert_to_index666(const SkBitmap& src, SkBitmap* dst) {
}
}
}
- ctable->unlockColors(true);
+ SkAlphaType aType = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
+ SkColorTable* ctable = new SkColorTable(storage, 216, aType);
dst->setConfig(SkBitmap::kIndex8_Config, src.width(), src.height());
dst->allocPixels(ctable);
ctable->unref();
@@ -119,7 +121,7 @@ protected:
if (SkBitmap::kIndex8_Config == fConfig) {
SkBitmap tmp;
- convert_to_index666(fBitmap, &tmp);
+ convert_to_index666(fBitmap, &tmp, fIsOpaque);
fBitmap = tmp;
}