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

Unified Diff: tools/SkBitmapRegionDecoderInterface.cpp

Issue 1425833002: Add NewFromStream and getEncodedFormat to BitmapRegionDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@brd-design
Patch Set: Created 5 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 | « tools/SkBitmapRegionDecoderInterface.h ('k') | tools/SkBitmapRegionSampler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/SkBitmapRegionDecoderInterface.cpp
diff --git a/tools/SkBitmapRegionDecoderInterface.cpp b/tools/SkBitmapRegionDecoderInterface.cpp
index ec6327e565c99158261248c857a84ca1fbdaa821..59415383d3669876c257f68e36d8c9e55398f0fe 100644
--- a/tools/SkBitmapRegionDecoderInterface.cpp
+++ b/tools/SkBitmapRegionDecoderInterface.cpp
@@ -16,16 +16,22 @@
SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(
SkData* data, Strategy strategy) {
+ return SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(new SkMemoryStream(data),
+ strategy);
+}
+
+SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(
+ SkStreamRewindable* stream, Strategy strategy) {
+ SkAutoTDelete<SkStreamRewindable> streamDeleter(stream);
switch (strategy) {
case kOriginal_Strategy: {
- SkAutoTDelete<SkStreamRewindable> stream(new SkMemoryStream(data));
- SkImageDecoder* decoder = SkImageDecoder::Factory(stream);
+ SkImageDecoder* decoder = SkImageDecoder::Factory(streamDeleter);
int width, height;
if (nullptr == decoder) {
SkCodecPrintf("Error: Could not create image decoder.\n");
return nullptr;
}
- if (!decoder->buildTileIndex(stream.detach(), &width, &height)) {
+ if (!decoder->buildTileIndex(streamDeleter.detach(), &width, &height)) {
SkCodecPrintf("Error: Could not build tile index.\n");
delete decoder;
return nullptr;
@@ -33,7 +39,7 @@ SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi
return new SkBitmapRegionSampler(decoder, width, height);
}
case kCanvas_Strategy: {
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.detach()));
if (nullptr == codec) {
SkCodecPrintf("Error: Failed to create decoder.\n");
return nullptr;
@@ -49,7 +55,8 @@ SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi
return new SkBitmapRegionCanvas(codec.detach());
}
case kAndroidCodec_Strategy: {
- SkAutoTDelete<SkAndroidCodec> codec = SkAndroidCodec::NewFromData(data);
+ SkAutoTDelete<SkAndroidCodec> codec =
+ SkAndroidCodec::NewFromStream(streamDeleter.detach());
if (NULL == codec) {
SkCodecPrintf("Error: Failed to create codec.\n");
return NULL;
« no previous file with comments | « tools/SkBitmapRegionDecoderInterface.h ('k') | tools/SkBitmapRegionSampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698