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

Side by Side Diff: src/android/SkBitmapRegionDecoder.cpp

Issue 1809733002: detach -> release (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: (C) Created 4 years, 9 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 | « samplecode/SamplePictFile.cpp ('k') | src/codec/SkAndroidCodec.cpp » ('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 "SkBitmapRegionCodec.h" 9 #include "SkBitmapRegionCodec.h"
10 #include "SkBitmapRegionDecoder.h" 10 #include "SkBitmapRegionDecoder.h"
11 #include "SkAndroidCodec.h" 11 #include "SkAndroidCodec.h"
12 #include "SkCodec.h" 12 #include "SkCodec.h"
13 #include "SkCodecPriv.h" 13 #include "SkCodecPriv.h"
14 #include "SkImageDecoder.h" 14 #include "SkImageDecoder.h"
15 15
16 SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create( 16 SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
17 SkData* data, Strategy strategy) { 17 SkData* data, Strategy strategy) {
18 return SkBitmapRegionDecoder::Create(new SkMemoryStream(data), 18 return SkBitmapRegionDecoder::Create(new SkMemoryStream(data),
19 strategy); 19 strategy);
20 } 20 }
21 21
22 SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create( 22 SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
23 SkStreamRewindable* stream, Strategy strategy) { 23 SkStreamRewindable* stream, Strategy strategy) {
24 SkAutoTDelete<SkStreamRewindable> streamDeleter(stream); 24 SkAutoTDelete<SkStreamRewindable> streamDeleter(stream);
25 switch (strategy) { 25 switch (strategy) {
26 case kCanvas_Strategy: { 26 case kCanvas_Strategy: {
27 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.de tach())); 27 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.re lease()));
28 if (nullptr == codec) { 28 if (nullptr == codec) {
29 SkCodecPrintf("Error: Failed to create decoder.\n"); 29 SkCodecPrintf("Error: Failed to create decoder.\n");
30 return nullptr; 30 return nullptr;
31 } 31 }
32 32
33 SkEncodedFormat format = codec->getEncodedFormat(); 33 SkEncodedFormat format = codec->getEncodedFormat();
34 switch (format) { 34 switch (format) {
35 case SkEncodedFormat::kJPEG_SkEncodedFormat: 35 case SkEncodedFormat::kJPEG_SkEncodedFormat:
36 case SkEncodedFormat::kPNG_SkEncodedFormat: 36 case SkEncodedFormat::kPNG_SkEncodedFormat:
37 break; 37 break;
38 default: 38 default:
39 // FIXME: Support webp using a special case. Webp does not support 39 // FIXME: Support webp using a special case. Webp does not support
40 // scanline decoding. 40 // scanline decoding.
41 return nullptr; 41 return nullptr;
42 } 42 }
43 43
44 // If the image is a jpeg or a png, the scanline ordering should alw ays be 44 // If the image is a jpeg or a png, the scanline ordering should alw ays be
45 // kTopDown or kNone. It is relevant to check because this implemen tation 45 // kTopDown or kNone. It is relevant to check because this implemen tation
46 // only supports these two scanline orderings. 46 // only supports these two scanline orderings.
47 SkASSERT(SkCodec::kTopDown_SkScanlineOrder == codec->getScanlineOrde r() || 47 SkASSERT(SkCodec::kTopDown_SkScanlineOrder == codec->getScanlineOrde r() ||
48 SkCodec::kNone_SkScanlineOrder == codec->getScanlineOrder()) ; 48 SkCodec::kNone_SkScanlineOrder == codec->getScanlineOrder()) ;
49 49
50 return new SkBitmapRegionCanvas(codec.detach()); 50 return new SkBitmapRegionCanvas(codec.release());
51 } 51 }
52 case kAndroidCodec_Strategy: { 52 case kAndroidCodec_Strategy: {
53 SkAutoTDelete<SkAndroidCodec> codec = 53 SkAutoTDelete<SkAndroidCodec> codec =
54 SkAndroidCodec::NewFromStream(streamDeleter.detach()); 54 SkAndroidCodec::NewFromStream(streamDeleter.release());
55 if (nullptr == codec) { 55 if (nullptr == codec) {
56 SkCodecPrintf("Error: Failed to create codec.\n"); 56 SkCodecPrintf("Error: Failed to create codec.\n");
57 return NULL; 57 return NULL;
58 } 58 }
59 59
60 SkEncodedFormat format = codec->getEncodedFormat(); 60 SkEncodedFormat format = codec->getEncodedFormat();
61 switch (format) { 61 switch (format) {
62 case SkEncodedFormat::kJPEG_SkEncodedFormat: 62 case SkEncodedFormat::kJPEG_SkEncodedFormat:
63 case SkEncodedFormat::kPNG_SkEncodedFormat: 63 case SkEncodedFormat::kPNG_SkEncodedFormat:
64 case SkEncodedFormat::kWEBP_SkEncodedFormat: 64 case SkEncodedFormat::kWEBP_SkEncodedFormat:
65 break; 65 break;
66 default: 66 default:
67 return nullptr; 67 return nullptr;
68 } 68 }
69 69
70 return new SkBitmapRegionCodec(codec.detach()); 70 return new SkBitmapRegionCodec(codec.release());
71 } 71 }
72 default: 72 default:
73 SkASSERT(false); 73 SkASSERT(false);
74 return nullptr; 74 return nullptr;
75 } 75 }
76 } 76 }
OLDNEW
« no previous file with comments | « samplecode/SamplePictFile.cpp ('k') | src/codec/SkAndroidCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698