aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-09 16:34:47 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-09 16:34:47 +0000
commit9864c24e40448ef64b1fe367eee1d63a872e51b8 (patch)
treee2f4f0f77d9e8176ab572a061e2594dbd8c9e01e /samplecode
parentb6aec0558810f5d3531ff7d530be0a3d148c5639 (diff)
change SkColorTable to be immutable
BUG= R=scroggo@google.com Review URL: https://codereview.chromium.org/25353002 git-svn-id: http://skia.googlecode.com/svn/trunk@11676 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleBlur.cpp10
-rw-r--r--samplecode/SampleDitherBitmap.cpp15
-rw-r--r--samplecode/SampleTinyBitmap.cpp11
3 files changed, 21 insertions, 15 deletions
diff --git a/samplecode/SampleBlur.cpp b/samplecode/SampleBlur.cpp
index e8e9772287..d951d8508b 100644
--- a/samplecode/SampleBlur.cpp
+++ b/samplecode/SampleBlur.cpp
@@ -15,14 +15,14 @@
#include "SkView.h"
static SkBitmap make_bitmap() {
- SkBitmap bm;
- SkColorTable* ctable = new SkColorTable(256);
-
- SkPMColor* c = ctable->lockColors();
+ SkPMColor c[256];
for (int i = 0; i < 256; i++) {
c[i] = SkPackARGB32(255 - i, 0, 0, 0);
}
- ctable->unlockColors(true);
+
+ SkBitmap bm;
+ SkColorTable* ctable = new SkColorTable(c, 256);
+
bm.setConfig(SkBitmap::kIndex8_Config, 256, 256);
bm.allocPixels(ctable);
ctable->unref();
diff --git a/samplecode/SampleDitherBitmap.cpp b/samplecode/SampleDitherBitmap.cpp
index df727c4203..7f29305a51 100644
--- a/samplecode/SampleDitherBitmap.cpp
+++ b/samplecode/SampleDitherBitmap.cpp
@@ -54,14 +54,13 @@ static void test_pathregion() {
}
static SkBitmap make_bitmap() {
- SkBitmap bm;
- SkColorTable* ctable = new SkColorTable(256);
-
- SkPMColor* c = ctable->lockColors();
+ SkPMColor c[256];
for (int i = 0; i < 256; i++) {
c[i] = SkPackARGB32(0xFF, i, 0, 0);
}
- ctable->unlockColors(true);
+ SkColorTable* ctable = new SkColorTable(c, 256, kOpaque_SkAlphaType);
+
+ SkBitmap bm;
bm.setConfig(SkBitmap::kIndex8_Config, 256, 32);
bm.allocPixels(ctable);
ctable->unref();
@@ -102,10 +101,14 @@ 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) {
- ctable->setIsOpaque(isOpaque);
+ if (ctable->isOpaque() != isOpaque) {
+ // how do we change a colortable? don't want to
+ }
}
+#endif
}
static void draw2(SkCanvas* canvas, const SkBitmap& bm) {
diff --git a/samplecode/SampleTinyBitmap.cpp b/samplecode/SampleTinyBitmap.cpp
index 16cbce4adc..42866d07ad 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 = ctable->lockColors();
+ SkPMColor c[N];
for (int i = 0; i < N; i++) {
c[i] = SkPackARGB32(0x80, 0x80, 0, 0);
}
- ctable->unlockColors(true);
+ SkColorTable* ctable = new SkColorTable(c, N);
+
+ SkBitmap bm;
bm.setConfig(SkBitmap::kIndex8_Config, 1, 1);
bm.allocPixels(ctable);
ctable->unref();
@@ -58,10 +58,13 @@ 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) {