diff options
author | 2013-10-09 16:49:45 +0000 | |
---|---|---|
committer | 2013-10-09 16:49:45 +0000 | |
commit | 48d9ff5b3475ad4b345fae35e1ce36b34069691b (patch) | |
tree | 031139bad8087d5953e8494c8f593da5ecbefcdd /samplecode | |
parent | 9864c24e40448ef64b1fe367eee1d63a872e51b8 (diff) |
Revert "change SkColorTable to be immutable"
This reverts commit 1c0ff422868b3badf5ffe0790a5d051d1896e2f7.
BUG=
Review URL: https://codereview.chromium.org/26709002
git-svn-id: http://skia.googlecode.com/svn/trunk@11677 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleBlur.cpp | 10 | ||||
-rw-r--r-- | samplecode/SampleDitherBitmap.cpp | 15 | ||||
-rw-r--r-- | samplecode/SampleTinyBitmap.cpp | 11 |
3 files changed, 15 insertions, 21 deletions
diff --git a/samplecode/SampleBlur.cpp b/samplecode/SampleBlur.cpp index d951d8508b..e8e9772287 100644 --- a/samplecode/SampleBlur.cpp +++ b/samplecode/SampleBlur.cpp @@ -15,14 +15,14 @@ #include "SkView.h" static SkBitmap make_bitmap() { - SkPMColor c[256]; + SkBitmap bm; + SkColorTable* ctable = new SkColorTable(256); + + SkPMColor* c = ctable->lockColors(); for (int i = 0; i < 256; i++) { c[i] = SkPackARGB32(255 - i, 0, 0, 0); } - - SkBitmap bm; - SkColorTable* ctable = new SkColorTable(c, 256); - + ctable->unlockColors(true); bm.setConfig(SkBitmap::kIndex8_Config, 256, 256); bm.allocPixels(ctable); ctable->unref(); diff --git a/samplecode/SampleDitherBitmap.cpp b/samplecode/SampleDitherBitmap.cpp index 7f29305a51..df727c4203 100644 --- a/samplecode/SampleDitherBitmap.cpp +++ b/samplecode/SampleDitherBitmap.cpp @@ -54,13 +54,14 @@ static void test_pathregion() { } static SkBitmap make_bitmap() { - SkPMColor c[256]; + SkBitmap bm; + SkColorTable* ctable = new SkColorTable(256); + + SkPMColor* c = ctable->lockColors(); for (int i = 0; i < 256; i++) { c[i] = SkPackARGB32(0xFF, i, 0, 0); } - SkColorTable* ctable = new SkColorTable(c, 256, kOpaque_SkAlphaType); - - SkBitmap bm; + ctable->unlockColors(true); bm.setConfig(SkBitmap::kIndex8_Config, 256, 32); bm.allocPixels(ctable); ctable->unref(); @@ -101,14 +102,10 @@ protected: static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) { SkAutoLockPixels alp(*bm); // needed for ctable bm->setIsOpaque(isOpaque); -#if 0 SkColorTable* ctable = bm->getColorTable(); if (ctable) { - if (ctable->isOpaque() != isOpaque) { - // how do we change a colortable? don't want to - } + ctable->setIsOpaque(isOpaque); } -#endif } static void draw2(SkCanvas* canvas, const SkBitmap& bm) { diff --git a/samplecode/SampleTinyBitmap.cpp b/samplecode/SampleTinyBitmap.cpp index 42866d07ad..16cbce4adc 100644 --- a/samplecode/SampleTinyBitmap.cpp +++ b/samplecode/SampleTinyBitmap.cpp @@ -13,15 +13,15 @@ #include "SkUtils.h" static SkBitmap make_bitmap() { + SkBitmap bm; const int N = 1; + SkColorTable* ctable = new SkColorTable(N); - SkPMColor c[N]; + SkPMColor* c = ctable->lockColors(); for (int i = 0; i < N; i++) { c[i] = SkPackARGB32(0x80, 0x80, 0, 0); } - SkColorTable* ctable = new SkColorTable(c, N); - - SkBitmap bm; + ctable->unlockColors(true); bm.setConfig(SkBitmap::kIndex8_Config, 1, 1); bm.allocPixels(ctable); ctable->unref(); @@ -58,13 +58,10 @@ protected: static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) { SkAutoLockPixels alp(*bm); // needed for ctable bm->setIsOpaque(isOpaque); -#if 0 - // TODO - I think we just want to not allow this anymore SkColorTable* ctable = bm->getColorTable(); if (ctable) { ctable->setIsOpaque(isOpaque); } -#endif } virtual void onDrawContent(SkCanvas* canvas) { |