aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@chromium.org>2015-07-30 07:47:45 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-30 07:47:45 -0700
commitef004e1b49ce6ad488ea4444c0eb896ef37c1242 (patch)
treecc06764b4fc7d508c2a1a13a0cba8ed334aa010b
parent6cb3cbe8e67db5fb94ba7d98f60833229b008544 (diff)
Remove SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
Now that Chrome no longer depends on it, remove dead code. Review URL: https://codereview.chromium.org/1263013002
-rw-r--r--include/core/SkImageGenerator.h81
-rw-r--r--src/core/SkImageGenerator.cpp22
-rw-r--r--src/images/SkDecodingImageGenerator.cpp46
-rw-r--r--src/ports/SkImageGenerator_skia.cpp21
-rw-r--r--tests/CachedDecodingPixelRefTest.cpp18
5 files changed, 0 insertions, 188 deletions
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index c133476d5b..46aea7b81e 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -15,8 +15,6 @@ class SkBitmap;
class SkData;
class SkImageGenerator;
-//#define SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
-
/**
* Takes ownership of SkImageGenerator. If this method fails for
* whatever reason, it will return false and immediatetely delete
@@ -69,79 +67,6 @@ public:
*/
const SkImageInfo& getInfo() const { return fInfo; }
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- /**
- * Used to describe the result of a call to getPixels().
- *
- * Result is the union of possible results from subclasses.
- */
- enum Result {
- /**
- * General return value for success.
- */
- kSuccess,
- /**
- * The input is incomplete. A partial image was generated.
- */
- kIncompleteInput,
- /**
- * The generator cannot convert to match the request, ignoring
- * dimensions.
- */
- kInvalidConversion,
- /**
- * The generator cannot scale to requested size.
- */
- kInvalidScale,
- /**
- * Parameters (besides info) are invalid. e.g. NULL pixels, rowBytes
- * too small, etc.
- */
- kInvalidParameters,
- /**
- * The input did not contain a valid image.
- */
- kInvalidInput,
- /**
- * Fulfilling this request requires rewinding the input, which is not
- * supported for this input.
- */
- kCouldNotRewind,
- /**
- * This method is not implemented by this generator.
- */
- kUnimplemented,
- };
-
- /**
- * Whether or not the memory passed to getPixels is zero initialized.
- */
- enum ZeroInitialized {
- /**
- * The memory passed to getPixels is zero initialized. The SkCodec
- * may take advantage of this by skipping writing zeroes.
- */
- kYes_ZeroInitialized,
- /**
- * The memory passed to getPixels has not been initialized to zero,
- * so the SkCodec must write all zeroes to memory.
- *
- * This is the default. It will be used if no Options struct is used.
- */
- kNo_ZeroInitialized,
- };
-
- /**
- * Additional options to pass to getPixels.
- */
- struct Options {
- Options()
- : fZeroInitialized(kNo_ZeroInitialized) {}
-
- ZeroInitialized fZeroInitialized;
- };
-#endif
-
/**
* Decode into the given pixels, a block of memory of size at
* least (info.fHeight - 1) * rowBytes + (info.fWidth *
@@ -206,14 +131,8 @@ protected:
virtual SkData* onRefEncodedData();
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- virtual Result onGetPixels(const SkImageInfo& info,
- void* pixels, size_t rowBytes, const Options&,
- SkPMColor ctable[], int* ctableCount);
-#else
virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
SkPMColor ctable[], int* ctableCount);
-#endif
virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]);
virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
SkYUVColorSpace* colorSpace);
diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp
index 8c9ff6a035..82b42d7a97 100644
--- a/src/core/SkImageGenerator.cpp
+++ b/src/core/SkImageGenerator.cpp
@@ -31,25 +31,11 @@ bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r
ctable = NULL;
}
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- // Default options.
- Options options;
- const Result result = this->onGetPixels(info, pixels, rowBytes, options, ctable, ctableCount);
-
- if (kIncompleteInput != result && kSuccess != result) {
- return false;
- }
- if (ctableCount) {
- SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
- }
- return true;
-#else
const bool success = this->onGetPixels(info, pixels, rowBytes, ctable, ctableCount);
if (success && ctableCount) {
SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
}
return success;
-#endif
}
bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
@@ -118,18 +104,10 @@ SkData* SkImageGenerator::onRefEncodedData() {
return NULL;
}
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
-SkImageGenerator::Result SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst,
- size_t rb, const Options& options,
- SkPMColor* colors, int* colorCount) {
- return kUnimplemented;
-}
-#else
bool SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst, size_t rb,
SkPMColor* colors, int* colorCount) {
return false;
}
-#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
index 6b2f73b2e4..b4af220d71 100644
--- a/src/images/SkDecodingImageGenerator.cpp
+++ b/src/images/SkDecodingImageGenerator.cpp
@@ -38,14 +38,8 @@ public:
protected:
SkData* onRefEncodedData() override;
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- Result onGetPixels(const SkImageInfo& info,
- void* pixels, size_t rowBytes, const Options&,
- SkPMColor ctable[], int* ctableCount) override;
-#else
bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
SkPMColor ctable[], int* ctableCount) override;
-#endif
bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
SkYUVColorSpace* colorSpace) override;
@@ -149,36 +143,19 @@ SkData* DecodingImageGenerator::onRefEncodedData() {
return SkSafeRef(fData);
}
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
-SkImageGenerator::Result DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
- void* pixels, size_t rowBytes, const Options& options, SkPMColor ctableEntries[],
- int* ctableCount) {
-#else
bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
SkPMColor ctableEntries[], int* ctableCount) {
-#endif
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.
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- if (info.dimensions() != fInfo.dimensions()) {
- return kInvalidScale;
- }
- return kInvalidConversion;
-#else
return false;
-#endif
}
SkAssertResult(fStream->rewind());
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
if (NULL == decoder.get()) {
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- return kInvalidInput;
-#else
return false;
-#endif
}
decoder->setDitherImage(fDitherImage);
decoder->setSampleSize(fSampleSize);
@@ -191,11 +168,7 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels,
SkImageDecoder::kDecodePixels_Mode);
decoder->setAllocator(NULL);
if (SkImageDecoder::kFailure == decodeResult) {
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- return kInvalidInput;
-#else
return false;
-#endif
}
if (allocator.isReady()) { // Did not use pixels!
SkBitmap bm;
@@ -204,11 +177,7 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels,
if (!copySuccess || allocator.isReady()) {
SkDEBUGFAIL("bitmap.copyTo(requestedConfig) failed.");
// Earlier we checked canCopyto(); we expect consistency.
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- return kInvalidConversion;
-#else
return false;
-#endif
}
SkASSERT(check_alpha(info.alphaType(), bm.alphaType()));
} else {
@@ -218,32 +187,17 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels,
if (kIndex_8_SkColorType == info.colorType()) {
if (kIndex_8_SkColorType != bitmap.colorType()) {
// they asked for Index8, but we didn't receive that from decoder
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- return kInvalidConversion;
-#else
return false;
-#endif
}
SkColorTable* ctable = bitmap.getColorTable();
if (NULL == ctable) {
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- return kInvalidConversion;
-#else
return false;
-#endif
}
const int count = ctable->count();
memcpy(ctableEntries, ctable->readColors(), count * sizeof(SkPMColor));
*ctableCount = count;
}
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- if (SkImageDecoder::kPartialSuccess == decodeResult) {
- return kIncompleteInput;
- }
- return kSuccess;
-#else
return true;
-#endif
}
bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3],
diff --git a/src/ports/SkImageGenerator_skia.cpp b/src/ports/SkImageGenerator_skia.cpp
index 1dbc9a5f33..72480b8f68 100644
--- a/src/ports/SkImageGenerator_skia.cpp
+++ b/src/ports/SkImageGenerator_skia.cpp
@@ -46,14 +46,8 @@ protected:
SkData* onRefEncodedData() override {
return SkRef(fData.get());
}
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- Result onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
- const Options&,
- SkPMColor ctableEntries[], int* ctableCount) override {
-#else
bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
SkPMColor ctableEntries[], int* ctableCount) override {
-#endif
SkMemoryStream stream(fData->data(), fData->size(), false);
SkAutoTUnref<BareMemoryAllocator> allocator(SkNEW_ARGS(BareMemoryAllocator,
(info, pixels, rowBytes)));
@@ -64,11 +58,7 @@ protected:
const SkImageDecoder::Result result = fDecoder->decode(&stream, &bm, info.colorType(),
SkImageDecoder::kDecodePixels_Mode);
if (SkImageDecoder::kFailure == result) {
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- return kInvalidInput;
-#else
return false;
-#endif
}
SkASSERT(info.colorType() == bm.info().colorType());
@@ -78,24 +68,13 @@ protected:
SkColorTable* ctable = bm.getColorTable();
if (NULL == ctable) {
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- return kInvalidConversion;
-#else
return false;
-#endif
}
const int count = ctable->count();
memcpy(ctableEntries, ctable->readColors(), count * sizeof(SkPMColor));
*ctableCount = count;
}
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- if (SkImageDecoder::kPartialSuccess == result) {
- return kIncompleteInput;
- }
- return kSuccess;
-#else
return true;
-#endif
}
bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index 78adc34d5a..0e9b18e1cf 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -182,29 +182,15 @@ protected:
kOpaque_SkAlphaType);
}
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- Result onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
- const Options&,
- SkPMColor ctable[], int* ctableCount) override {
-#else
bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
SkPMColor ctable[], int* ctableCount) override {
-#endif
REPORTER_ASSERT(fReporter, pixels != NULL);
REPORTER_ASSERT(fReporter, rowBytes >= info.minRowBytes());
if (fType != kSucceedGetPixels_TestType) {
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- return kUnimplemented;
-#else
return false;
-#endif
}
if (info.colorType() != kN32_SkColorType) {
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- return kInvalidConversion;
-#else
return false;
-#endif
}
char* bytePtr = static_cast<char*>(pixels);
for (int y = 0; y < info.height(); ++y) {
@@ -212,11 +198,7 @@ protected:
TestImageGenerator::Color(), info.width());
bytePtr += rowBytes;
}
-#ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
- return kSuccess;
-#else
return true;
-#endif
}
private: