aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-29 15:57:20 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-29 15:57:20 +0000
commit00f8d6c75d22ce8f95f932c5b101354b196fa0df (patch)
tree7ff413f0df54836620b2ba58c524d62ce7d033ff
parent2246e325b8710389d8f718843356e410f683dd25 (diff)
Revert "Revert of add colortable support to imagegenerator (https://codereview.chromium.org/304443003/)"
Fix is to add colortable param to installPixels() This reverts commit 924205aaf2e0c3c65dda13e0eaccde3e7b2a5c40. BUG=skia: R=scroggo@google.com, reed@chromium.org Author: reed@google.com Review URL: https://codereview.chromium.org/300263005 git-svn-id: http://skia.googlecode.com/svn/trunk@14958 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--gm/peekpixels.cpp3
-rw-r--r--gyp/images.gyp1
-rw-r--r--gyp/skia_for_chromium_defines.gypi1
-rw-r--r--include/core/SkBitmap.h17
-rw-r--r--include/core/SkImageGenerator.h37
-rw-r--r--samplecode/SampleHairline.cpp3
-rw-r--r--samplecode/SampleXfermodesBlur.cpp5
-rw-r--r--src/core/SkBitmap.cpp8
-rw-r--r--src/core/SkCanvas.cpp3
-rw-r--r--src/effects/SkBlurMaskFilter.cpp2
-rw-r--r--src/image/SkImage_Raster.cpp3
-rw-r--r--src/images/SkDecodingImageGenerator.cpp75
-rw-r--r--src/images/SkImageGenerator.cpp72
-rw-r--r--src/lazy/SkDiscardablePixelRef.cpp19
-rw-r--r--src/lazy/SkDiscardablePixelRef.h5
-rw-r--r--src/utils/SkCanvasStateUtils.cpp3
-rw-r--r--tests/AAClipTest.cpp2
-rw-r--r--tests/BitmapGetColorTest.cpp2
-rw-r--r--tests/CachedDecodingPixelRefTest.cpp10
-rw-r--r--tests/DeferredCanvasTest.cpp2
-rw-r--r--tests/DrawBitmapRectTest.cpp12
-rw-r--r--tests/DrawPathTest.cpp3
-rw-r--r--tests/SurfaceTest.cpp2
23 files changed, 197 insertions, 93 deletions
diff --git a/gm/peekpixels.cpp b/gm/peekpixels.cpp
index 484e4e03b4..01a60c124f 100644
--- a/gm/peekpixels.cpp
+++ b/gm/peekpixels.cpp
@@ -46,8 +46,7 @@ protected:
SkImageInfo info;
size_t rowBytes;
const void* addr = surfCanvas->peekPixels(&info, &rowBytes);
- if (addr && bitmap.installPixels(info, const_cast<void*>(addr),
- rowBytes, NULL, NULL)) {
+ if (addr && bitmap.installPixels(info, const_cast<void*>(addr), rowBytes)) {
canvas->drawBitmap(bitmap, 0, 0, NULL);
}
}
diff --git a/gyp/images.gyp b/gyp/images.gyp
index 0062f24f1d..18a18be7e1 100644
--- a/gyp/images.gyp
+++ b/gyp/images.gyp
@@ -71,6 +71,7 @@
'../src/images/SkImageEncoder.cpp',
'../src/images/SkImageEncoder_Factory.cpp',
'../src/images/SkImageEncoder_argb.cpp',
+ '../src/images/SkImageGenerator.cpp',
'../src/images/SkImageRef.cpp',
'../src/images/SkImageRefPool.cpp',
'../src/images/SkImageRefPool.h',
diff --git a/gyp/skia_for_chromium_defines.gypi b/gyp/skia_for_chromium_defines.gypi
index f2698988e2..52608e7dc3 100644
--- a/gyp/skia_for_chromium_defines.gypi
+++ b/gyp/skia_for_chromium_defines.gypi
@@ -17,6 +17,7 @@
'SK_SUPPORT_LEGACY_ASIMAGEINFO',
'SK_SUPPORT_LEGACY_N32_NAME',
'SK_IGNORE_CORRECT_HIGH_QUALITY_IMAGE_SCALE',
+ 'SK_SUPPORT_LEGACY_IMAGEGENERATORAPI',
],
},
}
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index ef59e31f52..b487285d93 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -313,13 +313,20 @@ public:
/**
* Install a pixelref that wraps the specified pixels and rowBytes, and
* optional ReleaseProc and context. When the pixels are no longer
- * referenced, if ReleaseProc is not null, it will be called with the
+ * referenced, if releaseProc is not null, it will be called with the
* pixels and context as parameters.
* On failure, the bitmap will be set to empty and return false.
*/
- bool installPixels(const SkImageInfo&, void* pixels, size_t rowBytes,
- void (*ReleaseProc)(void* addr, void* context),
- void* context);
+ bool installPixels(const SkImageInfo&, void* pixels, size_t rowBytes, SkColorTable*,
+ void (*releaseProc)(void* addr, void* context), void* context);
+
+#ifdef SK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS
+ bool installPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ void (*releaseProc)(void* addr, void* context),
+ void* context) {
+ return this->installPixels(info, pixels, rowBytes, NULL, releaseProc, context);
+ }
+#endif
/**
* Call installPixels with no ReleaseProc specified. This means that the
@@ -327,7 +334,7 @@ public:
* of the created bitmap (and its pixelRef).
*/
bool installPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
- return this->installPixels(info, pixels, rowBytes, NULL, NULL);
+ return this->installPixels(info, pixels, rowBytes, NULL, NULL, NULL);
}
/**
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index 76e856b387..86cd7f0c10 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -9,6 +9,7 @@
#define SkImageGenerator_DEFINED
#include "SkImageInfo.h"
+#include "SkColor.h"
class SkBitmap;
class SkData;
@@ -53,6 +54,13 @@ public:
*/
virtual ~SkImageGenerator() { }
+#ifdef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI
+ virtual bool refEncodedData() { return this->onRefEncodedData(); }
+ virtual bool getInfo(SkImageInfo* info) { return this->onGetInfo(info); }
+ virtual bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
+ return this->onGetPixels(info, pixels, rowBytes, NULL, NULL);
+ }
+#else
/**
* Return a ref to the encoded (i.e. compressed) representation,
* of this data.
@@ -60,7 +68,7 @@ public:
* If non-NULL is returned, the caller is responsible for calling
* unref() on the data when it is finished.
*/
- virtual SkData* refEncodedData() { return NULL; }
+ SkData* refEncodedData() { return this->onRefEncodedData(); }
/**
* Return some information about the image, allowing the owner of
@@ -71,7 +79,7 @@ public:
*
* @return false if anything goes wrong.
*/
- virtual bool getInfo(SkImageInfo* info) = 0;
+ bool getInfo(SkImageInfo* info);
/**
* Decode into the given pixels, a block of memory of size at
@@ -89,12 +97,31 @@ public:
* different output-configs, which the implementation can
* decide to support or not.
*
+ * If info is kIndex8_SkColorType, then the caller must provide storage for up to 256
+ * SkPMColor values in ctable. On success the generator must copy N colors into that storage,
+ * (where N is the logical number of table entries) and set ctableCount to N.
+ *
+ * If info is not kIndex8_SkColorType, then the last two parameters may be NULL. If ctableCount
+ * is not null, it will be set to 0.
+ *
* @return false if anything goes wrong or if the image info is
* unsupported.
*/
- virtual bool getPixels(const SkImageInfo& info,
- void* pixels,
- size_t rowBytes) = 0;
+ bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ SkPMColor ctable[], int* ctableCount);
+
+ /**
+ * Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType.
+ */
+ bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
+#endif
+
+protected:
+ virtual SkData* onRefEncodedData();
+ virtual bool onGetInfo(SkImageInfo* info);
+ virtual bool onGetPixels(const SkImageInfo& info,
+ void* pixels, size_t rowBytes,
+ SkPMColor ctable[], int* ctableCount);
};
#endif // SkImageGenerator_DEFINED
diff --git a/samplecode/SampleHairline.cpp b/samplecode/SampleHairline.cpp
index 85ecc03b0b..807a319e80 100644
--- a/samplecode/SampleHairline.cpp
+++ b/samplecode/SampleHairline.cpp
@@ -230,8 +230,7 @@ protected:
bm.eraseColor(SK_ColorTRANSPARENT);
bm2.installPixels(SkImageInfo::MakeN32Premul(WIDTH, HEIGHT),
- bm.getAddr32(MARGIN, MARGIN), bm.rowBytes(),
- NULL, NULL);
+ bm.getAddr32(MARGIN, MARGIN), bm.rowBytes());
SkCanvas c2(bm2);
SkPaint paint;
diff --git a/samplecode/SampleXfermodesBlur.cpp b/samplecode/SampleXfermodesBlur.cpp
index bb9c272bf8..fff4bed0a4 100644
--- a/samplecode/SampleXfermodesBlur.cpp
+++ b/samplecode/SampleXfermodesBlur.cpp
@@ -75,9 +75,8 @@ public:
const static int W = 64;
const static int H = 64;
XfermodesBlurView() {
- fBG.installPixels(SkImageInfo::Make(2, 2, kARGB_4444_SkColorType,
- kPremul_SkAlphaType),
- gBG, 4, NULL, NULL);
+ fBG.installPixels(SkImageInfo::Make(2, 2, kARGB_4444_SkColorType, kPremul_SkAlphaType),
+ gBG, 4);
}
protected:
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index a89ca35f0d..0bfcb6fbed 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -442,16 +442,14 @@ bool SkBitmap::allocPixels(const SkImageInfo& info, SkPixelRefFactory* factory,
return true;
}
-bool SkBitmap::installPixels(const SkImageInfo& info, void* pixels, size_t rb,
- void (*releaseProc)(void* addr, void* context),
- void* context) {
+bool SkBitmap::installPixels(const SkImageInfo& info, void* pixels, size_t rb, SkColorTable* ct,
+ void (*releaseProc)(void* addr, void* context), void* context) {
if (!this->setConfig(info, rb)) {
this->reset();
return false;
}
- SkPixelRef* pr = SkMallocPixelRef::NewWithProc(info, rb, NULL, pixels,
- releaseProc, context);
+ SkPixelRef* pr = SkMallocPixelRef::NewWithProc(info, rb, ct, pixels, releaseProc, context);
if (!pr) {
this->reset();
return false;
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 65002125a3..7e10504fbd 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1114,8 +1114,7 @@ SkAutoROCanvasPixels::SkAutoROCanvasPixels(SkCanvas* canvas) {
bool SkAutoROCanvasPixels::asROBitmap(SkBitmap* bitmap) const {
if (fAddr) {
- return bitmap->installPixels(fInfo, const_cast<void*>(fAddr), fRowBytes,
- NULL, NULL);
+ return bitmap->installPixels(fInfo, const_cast<void*>(fAddr), fRowBytes);
} else {
bitmap->reset();
return false;
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index b0af040784..aaf423524c 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -242,7 +242,7 @@ static bool draw_rects_into_mask(const SkRect rects[], int count, SkMask* mask)
mask->fBounds.height(),
kAlpha_8_SkColorType,
kPremul_SkAlphaType),
- mask->fImage, mask->fRowBytes, NULL, NULL);
+ mask->fImage, mask->fRowBytes);
SkCanvas canvas(bitmap);
canvas.translate(-SkIntToScalar(mask->fBounds.left()),
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 7a8091c8af..3be7d84b7f 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -94,8 +94,9 @@ SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes)
{
data->ref();
void* addr = const_cast<void*>(data->data());
+ SkColorTable* ctable = NULL;
- fBitmap.installPixels(info, addr, rowBytes, release_data, data);
+ fBitmap.installPixels(info, addr, rowBytes, ctable, release_data, data);
fBitmap.setImmutable();
fBitmap.lockPixels();
}
diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
index b3924a7daa..2493d89b38 100644
--- a/src/images/SkDecodingImageGenerator.cpp
+++ b/src/images/SkDecodingImageGenerator.cpp
@@ -23,12 +23,6 @@ bool equal_modulo_alpha(const SkImageInfo& a, const SkImageInfo& b) {
class DecodingImageGenerator : public SkImageGenerator {
public:
virtual ~DecodingImageGenerator();
- virtual SkData* refEncodedData() SK_OVERRIDE;
- // This implementaion of getInfo() always returns true.
- virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE;
- virtual bool getPixels(const SkImageInfo& info,
- void* pixels,
- size_t rowBytes) SK_OVERRIDE;
SkData* fData;
SkStreamRewindable* fStream;
@@ -41,6 +35,18 @@ public:
const SkImageInfo& info,
int sampleSize,
bool ditherImage);
+
+protected:
+ virtual SkData* onRefEncodedData() SK_OVERRIDE;
+ virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE {
+ *info = fInfo;
+ return true;
+ }
+ virtual bool onGetPixels(const SkImageInfo& info,
+ void* pixels, size_t rowBytes,
+ SkPMColor ctable[], int* ctableCount) SK_OVERRIDE;
+
+private:
typedef SkImageGenerator INHERITED;
};
@@ -69,7 +75,7 @@ public:
// TODO(halcanary): verify that all callers of this function
// will respect new RowBytes. Will be moot once rowbytes belongs
// to PixelRef.
- bm->installPixels(fInfo, fTarget, fRowBytes, NULL, NULL);
+ bm->installPixels(fInfo, fTarget, fRowBytes, ct, NULL, NULL);
fTarget = NULL; // never alloc same pixels twice!
return true;
@@ -123,14 +129,7 @@ DecodingImageGenerator::~DecodingImageGenerator() {
fStream->unref();
}
-bool DecodingImageGenerator::getInfo(SkImageInfo* info) {
- if (info != NULL) {
- *info = fInfo;
- }
- return true;
-}
-
-SkData* DecodingImageGenerator::refEncodedData() {
+SkData* DecodingImageGenerator::onRefEncodedData() {
// This functionality is used in `gm --serialize`
// Does not encode options.
if (fData != NULL) {
@@ -151,22 +150,15 @@ SkData* DecodingImageGenerator::refEncodedData() {
return SkSafeRef(fData);
}
-bool DecodingImageGenerator::getPixels(const SkImageInfo& info,
- void* pixels,
- size_t rowBytes) {
- if (NULL == pixels) {
- return false;
- }
+bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
+ void* pixels, size_t rowBytes,
+ SkPMColor ctableEntries[], int* ctableCount) {
if (fInfo != info) {
// The caller has specified a different info. This is an
// error for this kind of SkImageGenerator. Use the Options
// to change the settings.
return false;
}
- if (info.minRowBytes() > rowBytes) {
- // The caller has specified a bad rowBytes.
- return false;
- }
SkAssertResult(fStream->rewind());
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
@@ -202,6 +194,20 @@ bool DecodingImageGenerator::getPixels(const SkImageInfo& info,
} else {
SkASSERT(check_alpha(info.alphaType(), bitmap.alphaType()));
}
+
+ if (kIndex_8_SkColorType == info.colorType()) {
+ if (kIndex_8_SkColorType != bitmap.colorType()) {
+ return false; // they asked for Index8, but we didn't receive that from decoder
+ }
+ SkColorTable* ctable = bitmap.getColorTable();
+ if (NULL == ctable) {
+ return false;
+ }
+ const int count = ctable->count();
+ memcpy(ctableEntries, ctable->lockColors(), count * sizeof(SkPMColor));
+ ctable->unlockColors();
+ *ctableCount = count;
+ }
return true;
}
@@ -214,11 +220,6 @@ SkImageGenerator* CreateDecodingImageGenerator(
const SkDecodingImageGenerator::Options& opts) {
SkASSERT(stream);
SkAutoTUnref<SkStreamRewindable> autoStream(stream); // always unref this.
- if (opts.fUseRequestedColorType &&
- (kIndex_8_SkColorType == opts.fRequestedColorType)) {
- // We do not support indexed color with SkImageGenerators,
- return NULL;
- }
SkAssertResult(autoStream->rewind());
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(autoStream));
if (NULL == decoder.get()) {
@@ -227,24 +228,16 @@ SkImageGenerator* CreateDecodingImageGenerator(
SkBitmap bitmap;
decoder->setSampleSize(opts.fSampleSize);
decoder->setRequireUnpremultipliedColors(opts.fRequireUnpremul);
- if (!decoder->decode(stream, &bitmap,
- SkImageDecoder::kDecodeBounds_Mode)) {
+ if (!decoder->decode(stream, &bitmap, SkImageDecoder::kDecodeBounds_Mode)) {
return NULL;
}
- if (bitmap.config() == SkBitmap::kNo_Config) {
+ if (kUnknown_SkColorType == bitmap.colorType()) {
return NULL;
}
SkImageInfo info = bitmap.info();
- if (!opts.fUseRequestedColorType) {
- // Use default
- if (kIndex_8_SkColorType == bitmap.colorType()) {
- // We don't support kIndex8 because we don't support
- // colortables in this workflow.
- info.fColorType = kN32_SkColorType;
- }
- } else {
+ if (opts.fUseRequestedColorType && (opts.fRequestedColorType != info.colorType())) {
if (!bitmap.canCopyTo(opts.fRequestedColorType)) {
SkASSERT(bitmap.colorType() != opts.fRequestedColorType);
return NULL; // Can not translate to needed config.
diff --git a/src/images/SkImageGenerator.cpp b/src/images/SkImageGenerator.cpp
new file mode 100644
index 0000000000..daa55a3a4d
--- /dev/null
+++ b/src/images/SkImageGenerator.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkImageGenerator.h"
+
+#ifndef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI
+bool SkImageGenerator::getInfo(SkImageInfo* info) {
+ SkImageInfo dummy;
+ if (NULL == info) {
+ info = &dummy;
+ }
+ return this->onGetInfo(info);
+}
+
+bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ SkPMColor ctable[], int* ctableCount) {
+ if (kUnknown_SkColorType == info.colorType()) {
+ return false;
+ }
+ if (NULL == pixels) {
+ return false;
+ }
+ if (rowBytes < info.minRowBytes()) {
+ return false;
+ }
+
+ if (kIndex_8_SkColorType == info.colorType()) {
+ if (NULL == ctable || NULL == ctableCount) {
+ return false;
+ }
+ } else {
+ if (ctableCount) {
+ *ctableCount = 0;
+ }
+ ctableCount = NULL;
+ ctable = NULL;
+ }
+
+ bool success = this->onGetPixels(info, pixels, rowBytes, ctable, ctableCount);
+
+ if (success && ctableCount) {
+ SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
+ }
+ return success;
+}
+
+bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
+ SkASSERT(kIndex_8_SkColorType != info.colorType());
+ if (kIndex_8_SkColorType == info.colorType()) {
+ return false;
+ }
+ return this->getPixels(info, pixels, rowBytes, NULL, NULL);
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+SkData* SkImageGenerator::onRefEncodedData() {
+ return NULL;
+}
+
+bool SkImageGenerator::onGetInfo(SkImageInfo*) {
+ return false;
+}
+
+bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*, int*) {
+ return false;
+}
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index ccf812ce6f..b0bbd27e3a 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -60,15 +60,30 @@ bool SkDiscardablePixelRef::onNewLockPixels(LockRec* rec) {
}
void* pixels = fDiscardableMemory->data();
- if (!fGenerator->getPixels(this->info(), pixels, fRowBytes)) {
+ const SkImageInfo& info = this->info();
+ SkPMColor colors[256];
+ int colorCount = 0;
+
+ if (!fGenerator->getPixels(info, pixels, fRowBytes, colors, &colorCount)) {
fDiscardableMemory->unlock();
SkDELETE(fDiscardableMemory);
fDiscardableMemory = NULL;
return false;
}
+ // Note: our ctable is not purgable, as it is not stored in the discardablememory block.
+ // This is because SkColorTable is refcntable, and therefore our caller could hold onto it
+ // beyond the scope of a lock/unlock. If we change the API/lifecycle for SkColorTable, we
+ // could move it into the block, but then again perhaps it is small enough that this doesn't
+ // really matter.
+ if (colorCount > 0) {
+ fCTable.reset(SkNEW_ARGS(SkColorTable, (colors, colorCount)));
+ } else {
+ fCTable.reset(NULL);
+ }
+
rec->fPixels = pixels;
- rec->fColorTable = NULL;
+ rec->fColorTable = fCTable.get();
rec->fRowBytes = fRowBytes;
return true;
}
diff --git a/src/lazy/SkDiscardablePixelRef.h b/src/lazy/SkDiscardablePixelRef.h
index e5e1c9f0e1..52a1d6ce37 100644
--- a/src/lazy/SkDiscardablePixelRef.h
+++ b/src/lazy/SkDiscardablePixelRef.h
@@ -17,10 +17,6 @@
* A PixelRef backed by SkDiscardableMemory, with the ability to
* re-generate the pixels (via a SkImageGenerator) if the DM is
* purged.
- *
- * Since SkColorTable is reference-counted, we do not support indexed
- * color with this class; there would be no way for the discardable
- * memory system to unref the color table.
*/
class SkDiscardablePixelRef : public SkPixelRef {
public:
@@ -46,6 +42,7 @@ private:
// PixelRef, since the SkBitmap doesn't expect them to change.
SkDiscardableMemory* fDiscardableMemory;
+ SkAutoTUnref<SkColorTable> fCTable;
/* Takes ownership of SkImageGenerator. */
SkDiscardablePixelRef(const SkImageInfo&, SkImageGenerator*,
diff --git a/src/utils/SkCanvasStateUtils.cpp b/src/utils/SkCanvasStateUtils.cpp
index 64f62dd8b1..eaee61b5e8 100644
--- a/src/utils/SkCanvasStateUtils.cpp
+++ b/src/utils/SkCanvasStateUtils.cpp
@@ -291,8 +291,7 @@ static SkCanvas* create_canvas_from_canvas_layer(const SkCanvasLayerState& layer
bitmap.installPixels(SkImageInfo::Make(layerState.width, layerState.height,
colorType, kPremul_SkAlphaType),
- layerState.raster.pixels, layerState.raster.rowBytes,
- NULL, NULL);
+ layerState.raster.pixels, layerState.raster.rowBytes);
SkASSERT(!bitmap.empty());
SkASSERT(!bitmap.isNull());
diff --git a/tests/AAClipTest.cpp b/tests/AAClipTest.cpp
index cadd1806cf..26c1ec1d0e 100644
--- a/tests/AAClipTest.cpp
+++ b/tests/AAClipTest.cpp
@@ -76,7 +76,7 @@ static void copyToMask(const SkRegion& rgn, SkMask* mask) {
kAlpha_8_SkColorType,
kPremul_SkAlphaType);
SkBitmap bitmap;
- bitmap.installPixels(info, mask->fImage, mask->fRowBytes, NULL, NULL);
+ bitmap.installPixels(info, mask->fImage, mask->fRowBytes);
// canvas expects its coordinate system to always be 0,0 in the top/left
// so we translate the rgn to match that before drawing into the mask.
diff --git a/tests/BitmapGetColorTest.cpp b/tests/BitmapGetColorTest.cpp
index bf6ebcb5cf..bf3ba67ecb 100644
--- a/tests/BitmapGetColorTest.cpp
+++ b/tests/BitmapGetColorTest.cpp
@@ -37,7 +37,7 @@ DEF_TEST(GetColor, reporter) {
kPremul_SkAlphaType);
SkBitmap bm;
uint32_t storage[4];
- bm.installPixels(info, storage, info.minRowBytes(), NULL, NULL);
+ bm.installPixels(info, storage, info.minRowBytes());
bm.eraseColor(initColor);
bm.eraseArea(area, gRec[i].fInColor);
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index 10e33ba841..eff77e215d 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -183,7 +183,9 @@ public:
SkASSERT((fType <= kLast_TestType) && (fType >= 0));
}
virtual ~TestImageGenerator() { }
- virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE {
+
+protected:
+ virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE {
REPORTER_ASSERT(fReporter, NULL != info);
if ((NULL == info) || (kFailGetInfo_TestType == fType)) {
return false;
@@ -194,9 +196,9 @@ public:
info->fAlphaType = kOpaque_SkAlphaType;
return true;
}
- virtual bool getPixels(const SkImageInfo& info,
- void* pixels,
- size_t rowBytes) SK_OVERRIDE {
+
+ virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ SkPMColor ctable[], int* ctableCount) SK_OVERRIDE {
REPORTER_ASSERT(fReporter, pixels != NULL);
size_t minRowBytes
= static_cast<size_t>(info.fWidth * info.bytesPerPixel());
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index 9ffb790507..747b23b9ab 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -40,7 +40,7 @@ static SkSurface* createSurface(SkColor color) {
static SkPMColor read_pixel(SkSurface* surface, int x, int y) {
SkPMColor pixel = 0;
SkBitmap bitmap;
- bitmap.installPixels(SkImageInfo::MakeN32Premul(1, 1), &pixel, 4, NULL, NULL);
+ bitmap.installPixels(SkImageInfo::MakeN32Premul(1, 1), &pixel, 4);
SkCanvas canvas(bitmap);
SkPaint paint;
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp
index f294ae7e6e..aa69de4bd4 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -22,20 +22,16 @@ class FailureImageGenerator : public SkImageGenerator {
public:
FailureImageGenerator() { }
virtual ~FailureImageGenerator() { }
- virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE {
+
+protected:
+ virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE {
info->fWidth = 100;
info->fHeight = 100;
info->fColorType = kN32_SkColorType;
info->fAlphaType = kPremul_SkAlphaType;
return true;
}
- virtual bool getPixels(const SkImageInfo& info,
- void* pixels,
- size_t rowBytes) SK_OVERRIDE {
- // this will deliberately return false if they are asking us
- // to decode into pixels.
- return false;
- }
+ // default onGetPixels() returns false, which is what we want.
};
// crbug.com/295895
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index dbafa40be2..2af4224c9c 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -15,8 +15,7 @@
static void test_big_aa_rect(skiatest::Reporter* reporter) {
SkBitmap output;
SkPMColor pixel[1];
- output.installPixels(SkImageInfo::MakeN32Premul(1, 1),
- pixel, 4, NULL, NULL);
+ output.installPixels(SkImageInfo::MakeN32Premul(1, 1), pixel, 4);
SkSurface* surf = SkSurface::NewRasterPMColor(300, 33300);
SkCanvas* canvas = surf->getCanvas();
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 7d5607ce43..3f61f89abe 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -101,7 +101,7 @@ static SkImage* createImage(ImageType imageType, GrContext* context,
return NULL; // TODO
case kCodec_ImageType: {
SkBitmap bitmap;
- bitmap.installPixels(info, addr, rowBytes, NULL, NULL);
+ bitmap.installPixels(info, addr, rowBytes);
SkAutoTUnref<SkData> src(
SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type,
100));