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

Side by Side Diff: tools/SkBitmapRegionDecoderInterface.cpp

Issue 1395383002: SkBitmapRegionDecoder clean-up (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments 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 unified diff | Download patch
« no previous file with comments | « tools/SkBitmapRegionDecoderInterface.h ('k') | tools/SkBitmapRegionSampler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapRegionCanvas.h" 8 #include "SkBitmapRegionCanvas.h"
9 #include "SkBitmapRegionDecoderInterface.h" 9 #include "SkBitmapRegionDecoderInterface.h"
10 #include "SkBitmapRegionSampler.h" 10 #include "SkBitmapRegionSampler.h"
11 #include "SkCodec.h" 11 #include "SkCodec.h"
12 #include "SkCodecPriv.h"
12 #include "SkImageDecoder.h" 13 #include "SkImageDecoder.h"
13 14
14 SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi onDecoder( 15 SkBitmapRegionDecoderInterface* SkBitmapRegionDecoderInterface::CreateBitmapRegi onDecoder(
15 SkStreamRewindable* stream, Strategy strategy) { 16 SkStreamRewindable* stream, Strategy strategy) {
16 SkAutoTDelete<SkStreamRewindable> streamDeleter(stream); 17 SkAutoTDelete<SkStreamRewindable> streamDeleter(stream);
17 switch (strategy) { 18 switch (strategy) {
18 case kOriginal_Strategy: { 19 case kOriginal_Strategy: {
19 SkImageDecoder* decoder = SkImageDecoder::Factory(stream); 20 SkImageDecoder* decoder = SkImageDecoder::Factory(stream);
20 int width, height; 21 int width, height;
21 if (nullptr == decoder) { 22 if (nullptr == decoder) {
22 SkDebugf("Error: Could not create image decoder.\n"); 23 SkCodecPrintf("Error: Could not create image decoder.\n");
23 return nullptr; 24 return nullptr;
24 } 25 }
25 if (!decoder->buildTileIndex(streamDeleter.detach(), &width, &height )) { 26 if (!decoder->buildTileIndex(streamDeleter.detach(), &width, &height )) {
26 SkDebugf("Error: Could not build tile index.\n"); 27 SkCodecPrintf("Error: Could not build tile index.\n");
27 delete decoder; 28 delete decoder;
28 return nullptr; 29 return nullptr;
29 } 30 }
30 return new SkBitmapRegionSampler(decoder, width, height); 31 return new SkBitmapRegionSampler(decoder, width, height);
31 } 32 }
32 case kCanvas_Strategy: { 33 case kCanvas_Strategy: {
33 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.de tach())); 34 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.de tach()));
34 if (nullptr == codec) { 35 if (nullptr == codec) {
35 SkDebugf("Error: Failed to create decoder.\n"); 36 SkCodecPrintf("Error: Failed to create decoder.\n");
36 return nullptr; 37 return nullptr;
37 } 38 }
38 switch (codec->getScanlineOrder()) { 39 switch (codec->getScanlineOrder()) {
39 case SkCodec::kTopDown_SkScanlineOrder: 40 case SkCodec::kTopDown_SkScanlineOrder:
40 case SkCodec::kNone_SkScanlineOrder: 41 case SkCodec::kNone_SkScanlineOrder:
41 break; 42 break;
42 default: 43 default:
43 SkDebugf("Error: Scanline ordering not supported.\n"); 44 SkCodecPrintf("Error: Scanline ordering not supported.\n");
44 return nullptr; 45 return nullptr;
45 } 46 }
46 return new SkBitmapRegionCanvas(codec.detach()); 47 return new SkBitmapRegionCanvas(codec.detach());
47 } 48 }
48 default: 49 default:
49 SkASSERT(false); 50 SkASSERT(false);
50 return nullptr; 51 return nullptr;
51 } 52 }
52 } 53 }
OLDNEW
« 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