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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkBitmapRegionCanvas.h"
9 #include "SkBitmapRegionDecoder.h"
10 #include "SkBitmapRegionSampler.h"
11 #include "SkScanlineDecoder.h"
12 #include "SkImageDecoder.h"
13
14 SkBitmapRegionDecoder* SkBitmapRegionDecoder::CreateBitmapRegionDecoder(
15 SkStreamRewindable* stream, Strategy strategy) {
16 switch (strategy) {
17 case kOriginal_Strategy: {
18 SkImageDecoder* decoder = SkImageDecoder::Factory(stream);
19 int width, height;
20 if (nullptr == decoder) {
21 SkDebugf("Error: Could not create image decoder.\n");
22 return nullptr;
23 }
24 if (!decoder->buildTileIndex(stream, &width, &height)) {
25 SkDebugf("Error: Could not build tile index.\n");
26 SkDELETE(decoder);
scroggo 2015/09/02 21:32:24 nit: delete
msarett 2015/09/03 19:20:52 Done.
27 return nullptr;
28 }
29 return SkNEW_ARGS(SkBitmapRegionSampler, (decoder, width, height));
scroggo 2015/09/02 21:32:24 nit: new
msarett 2015/09/03 19:20:52 Done.
30 }
31 case kCanvas_Strategy: {
32 SkScanlineDecoder* decoder = SkScanlineDecoder::NewFromStream(stream );
33 if (nullptr == decoder) {
34 SkDebugf("Error: Failed to create decoder.\n");
35 return nullptr;
36 }
37 return SkNEW_ARGS(SkBitmapRegionCanvas, (decoder));
scroggo 2015/09/02 21:32:24 nit: new
msarett 2015/09/03 19:20:52 Done.
38 }
39 default:
40 SkASSERT(false);
41 return nullptr;
42 }
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698