Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1354)

Unified Diff: bench/BitmapBench.cpp

Issue 26572006: Revert "Revert "change SkColorTable to be immutable"" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | bench/RepeatTileBench.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/BitmapBench.cpp
diff --git a/bench/BitmapBench.cpp b/bench/BitmapBench.cpp
index 9b3a6a29dd082cf236a4259c8c743312e27b947e..982c917c02691319bc9a4b911c625b88d0f50066 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);
}
« no previous file with comments | « no previous file | bench/RepeatTileBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698