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

Unified Diff: tools/SkBitmapRegionDecoderInterface.cpp

Issue 1402863002: Implementation of SkBitmapRegionDecoder using SkAndroidCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@split1
Patch Set: Add AndroidCodec strategy to benchmark 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/SkCodecTools.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 835ed9aa56426cbda09b49b19e814a91e7f21514..ec6327e565c99158261248c857a84ca1fbdaa821 100644
--- a/tools/SkBitmapRegionDecoderInterface.cpp
+++ b/tools/SkBitmapRegionDecoderInterface.cpp
@@ -6,24 +6,26 @@
*/
#include "SkBitmapRegionCanvas.h"
+#include "SkBitmapRegionCodec.h"
#include "SkBitmapRegionDecoderInterface.h"
#include "SkBitmapRegionSampler.h"
+#include "SkAndroidCodec.h"
#include "SkCodec.h"
#include "SkCodecPriv.h"
#include "SkImageDecoder.h"
SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(
- SkStreamRewindable* stream, Strategy strategy) {
- SkAutoTDelete<SkStreamRewindable> streamDeleter(stream);
+ SkData* data, Strategy strategy) {
switch (strategy) {
case kOriginal_Strategy: {
+ SkAutoTDelete<SkStreamRewindable> stream(new SkMemoryStream(data));
SkImageDecoder* decoder = SkImageDecoder::Factory(stream);
int width, height;
if (nullptr == decoder) {
SkCodecPrintf("Error: Could not create image decoder.\n");
return nullptr;
}
- if (!decoder->buildTileIndex(streamDeleter.detach(), &width, &height)) {
+ if (!decoder->buildTileIndex(stream.detach(), &width, &height)) {
SkCodecPrintf("Error: Could not build tile index.\n");
delete decoder;
return nullptr;
@@ -31,7 +33,7 @@ SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi
return new SkBitmapRegionSampler(decoder, width, height);
}
case kCanvas_Strategy: {
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.detach()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
if (nullptr == codec) {
SkCodecPrintf("Error: Failed to create decoder.\n");
return nullptr;
@@ -46,6 +48,14 @@ SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi
}
return new SkBitmapRegionCanvas(codec.detach());
}
+ case kAndroidCodec_Strategy: {
+ SkAutoTDelete<SkAndroidCodec> codec = SkAndroidCodec::NewFromData(data);
+ if (NULL == codec) {
+ SkCodecPrintf("Error: Failed to create codec.\n");
+ return NULL;
+ }
+ return new SkBitmapRegionCodec(codec.detach());
+ }
default:
SkASSERT(false);
return nullptr;
« no previous file with comments | « tools/SkBitmapRegionDecoderInterface.h ('k') | tools/SkCodecTools.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698