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

Unified Diff: src/utils/SkBitmapRegionDecoder.cpp

Issue 1288963002: Provides multiple implementations of Android's SkBitmapRegionDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments Created 5 years, 3 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
Index: src/utils/SkBitmapRegionDecoder.cpp
diff --git a/src/utils/SkBitmapRegionDecoder.cpp b/src/utils/SkBitmapRegionDecoder.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2a93cd2508836885b3879bb278b9b70f4a7a0354
--- /dev/null
+++ b/src/utils/SkBitmapRegionDecoder.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBitmapRegionCanvas.h"
+#include "SkBitmapRegionDecoder.h"
+#include "SkBitmapRegionSampler.h"
+#include "SkScanlineDecoder.h"
+#include "SkImageDecoder.h"
+
+SkBitmapRegionDecoder* SkBitmapRegionDecoder::CreateBitmapRegionDecoder(
+ SkStreamRewindable* stream, Strategy strategy) {
+ switch (strategy) {
+ case kOriginal_Strategy: {
+ SkImageDecoder* decoder = SkImageDecoder::Factory(stream);
+ int width, height;
+ if (nullptr == decoder) {
+ SkDebugf("Error: Could not create image decoder.\n");
+ return nullptr;
+ }
+ if (!decoder->buildTileIndex(stream, &width, &height)) {
+ SkDebugf("Error: Could not build tile index.\n");
+ SkDELETE(decoder);
scroggo 2015/09/02 21:32:24 nit: delete
msarett 2015/09/03 19:20:52 Done.
+ return nullptr;
+ }
+ return SkNEW_ARGS(SkBitmapRegionSampler, (decoder, width, height));
scroggo 2015/09/02 21:32:24 nit: new
msarett 2015/09/03 19:20:52 Done.
+ }
+ case kCanvas_Strategy: {
+ SkScanlineDecoder* decoder = SkScanlineDecoder::NewFromStream(stream);
+ if (nullptr == decoder) {
+ SkDebugf("Error: Failed to create decoder.\n");
+ return nullptr;
+ }
+ return SkNEW_ARGS(SkBitmapRegionCanvas, (decoder));
scroggo 2015/09/02 21:32:24 nit: new
msarett 2015/09/03 19:20:52 Done.
+ }
+ default:
+ SkASSERT(false);
+ return nullptr;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698