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

Side by Side Diff: src/images/SkImageDecoder.cpp

Issue 331433003: hide SkImageDecoder::Chooser (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 8
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 12 matching lines...) Expand all
23 23
24 void SkImageDecoder::SetDeviceConfig(SkBitmap::Config config) 24 void SkImageDecoder::SetDeviceConfig(SkBitmap::Config config)
25 { 25 {
26 gDeviceConfig = config; 26 gDeviceConfig = config;
27 } 27 }
28 28
29 /////////////////////////////////////////////////////////////////////////////// 29 ///////////////////////////////////////////////////////////////////////////////
30 30
31 SkImageDecoder::SkImageDecoder() 31 SkImageDecoder::SkImageDecoder()
32 : fPeeker(NULL) 32 : fPeeker(NULL)
33 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
33 , fChooser(NULL) 34 , fChooser(NULL)
35 #endif
34 , fAllocator(NULL) 36 , fAllocator(NULL)
35 , fSampleSize(1) 37 , fSampleSize(1)
36 , fDefaultPref(SkBitmap::kNo_Config) 38 , fDefaultPref(SkBitmap::kNo_Config)
37 , fDitherImage(true) 39 , fDitherImage(true)
38 , fUsePrefTable(false) 40 , fUsePrefTable(false)
39 , fSkipWritingZeroes(false) 41 , fSkipWritingZeroes(false)
40 , fPreferQualityOverSpeed(false) 42 , fPreferQualityOverSpeed(false)
41 , fRequireUnpremultipliedColors(false) { 43 , fRequireUnpremultipliedColors(false) {
42 } 44 }
43 45
44 SkImageDecoder::~SkImageDecoder() { 46 SkImageDecoder::~SkImageDecoder() {
45 SkSafeUnref(fPeeker); 47 SkSafeUnref(fPeeker);
48 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
46 SkSafeUnref(fChooser); 49 SkSafeUnref(fChooser);
50 #endif
47 SkSafeUnref(fAllocator); 51 SkSafeUnref(fAllocator);
48 } 52 }
49 53
50 void SkImageDecoder::copyFieldsToOther(SkImageDecoder* other) { 54 void SkImageDecoder::copyFieldsToOther(SkImageDecoder* other) {
51 if (NULL == other) { 55 if (NULL == other) {
52 return; 56 return;
53 } 57 }
54 other->setPeeker(fPeeker); 58 other->setPeeker(fPeeker);
59 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
55 other->setChooser(fChooser); 60 other->setChooser(fChooser);
61 #endif
56 other->setAllocator(fAllocator); 62 other->setAllocator(fAllocator);
57 other->setSampleSize(fSampleSize); 63 other->setSampleSize(fSampleSize);
58 if (fUsePrefTable) { 64 if (fUsePrefTable) {
59 other->setPrefConfigTable(fPrefTable); 65 other->setPrefConfigTable(fPrefTable);
60 } else { 66 } else {
61 other->fDefaultPref = fDefaultPref; 67 other->fDefaultPref = fDefaultPref;
62 } 68 }
63 other->setDitherImage(fDitherImage); 69 other->setDitherImage(fDitherImage);
64 other->setSkipWritingZeroes(fSkipWritingZeroes); 70 other->setSkipWritingZeroes(fSkipWritingZeroes);
65 other->setPreferQualityOverSpeed(fPreferQualityOverSpeed); 71 other->setPreferQualityOverSpeed(fPreferQualityOverSpeed);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 SkDEBUGFAIL("Invalid format type!"); 106 SkDEBUGFAIL("Invalid format type!");
101 } 107 }
102 return "Unknown Format"; 108 return "Unknown Format";
103 } 109 }
104 110
105 SkImageDecoder::Peeker* SkImageDecoder::setPeeker(Peeker* peeker) { 111 SkImageDecoder::Peeker* SkImageDecoder::setPeeker(Peeker* peeker) {
106 SkRefCnt_SafeAssign(fPeeker, peeker); 112 SkRefCnt_SafeAssign(fPeeker, peeker);
107 return peeker; 113 return peeker;
108 } 114 }
109 115
116 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
110 SkImageDecoder::Chooser* SkImageDecoder::setChooser(Chooser* chooser) { 117 SkImageDecoder::Chooser* SkImageDecoder::setChooser(Chooser* chooser) {
111 SkRefCnt_SafeAssign(fChooser, chooser); 118 SkRefCnt_SafeAssign(fChooser, chooser);
112 return chooser; 119 return chooser;
113 } 120 }
121 #endif
114 122
115 SkBitmap::Allocator* SkImageDecoder::setAllocator(SkBitmap::Allocator* alloc) { 123 SkBitmap::Allocator* SkImageDecoder::setAllocator(SkBitmap::Allocator* alloc) {
116 SkRefCnt_SafeAssign(fAllocator, alloc); 124 SkRefCnt_SafeAssign(fAllocator, alloc);
117 return alloc; 125 return alloc;
118 } 126 }
119 127
120 void SkImageDecoder::setSampleSize(int size) { 128 void SkImageDecoder::setSampleSize(int size) {
121 if (size < 1) { 129 if (size < 1) {
122 size = 1; 130 size = 1;
123 } 131 }
124 fSampleSize = size; 132 fSampleSize = size;
125 } 133 }
126 134
135 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
127 // TODO: change Chooser virtual to take colorType, so we can stop calling SkColo rTypeToBitmapConfig 136 // TODO: change Chooser virtual to take colorType, so we can stop calling SkColo rTypeToBitmapConfig
128 // 137 //
129 bool SkImageDecoder::chooseFromOneChoice(SkColorType colorType, int width, int h eight) const { 138 bool SkImageDecoder::chooseFromOneChoice(SkColorType colorType, int width, int h eight) const {
130 Chooser* chooser = fChooser; 139 Chooser* chooser = fChooser;
131 140
132 if (NULL == chooser) { // no chooser, we just say YES to decoding :) 141 if (NULL == chooser) { // no chooser, we just say YES to decoding :)
133 return true; 142 return true;
134 } 143 }
135 chooser->begin(1); 144 chooser->begin(1);
136 chooser->inspect(0, SkColorTypeToBitmapConfig(colorType), width, height); 145 chooser->inspect(0, SkColorTypeToBitmapConfig(colorType), width, height);
137 return chooser->choose() == 0; 146 return chooser->choose() == 0;
138 } 147 }
148 #endif
139 149
140 bool SkImageDecoder::allocPixelRef(SkBitmap* bitmap, 150 bool SkImageDecoder::allocPixelRef(SkBitmap* bitmap,
141 SkColorTable* ctable) const { 151 SkColorTable* ctable) const {
142 return bitmap->allocPixels(fAllocator, ctable); 152 return bitmap->allocPixels(fAllocator, ctable);
143 } 153 }
144 154
145 /////////////////////////////////////////////////////////////////////////////// 155 ///////////////////////////////////////////////////////////////////////////////
146 156
147 void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) { 157 void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) {
148 fUsePrefTable = true; 158 fUsePrefTable = true;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 if (kUnknown_Format == *format) { 315 if (kUnknown_Format == *format) {
306 if (stream->rewind()) { 316 if (stream->rewind()) {
307 *format = GetStreamFormat(stream); 317 *format = GetStreamFormat(stream);
308 } 318 }
309 } 319 }
310 } 320 }
311 delete codec; 321 delete codec;
312 } 322 }
313 return success; 323 return success;
314 } 324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698