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

Side by Side Diff: src/ports/SkImageDecoder_WIC.cpp

Issue 14298010: Updates to images project. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Name changes Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/ports/SkImageDecoder_CG.cpp ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #define WIN32_LEAN_AND_MEAN 10 #define WIN32_LEAN_AND_MEAN
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 // Note: we don't need to premultiply here since we specified PBGRA 148 // Note: we don't need to premultiply here since we specified PBGRA
149 bm->computeAndSetOpaquePredicate(); 149 bm->computeAndSetOpaquePredicate();
150 } 150 }
151 151
152 return SUCCEEDED(hr); 152 return SUCCEEDED(hr);
153 } 153 }
154 154
155 ///////////////////////////////////////////////////////////////////////// 155 /////////////////////////////////////////////////////////////////////////
156 156
157 extern SkImageDecoder* image_decoder_from_stream(SkStream*);
158
157 SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) { 159 SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) {
158 return SkNEW(SkImageDecoder_WIC); 160 SkImageDecoder* decoder = image_decoder_from_stream(stream);
161 if (NULL == decoder) {
162 // If no image decoder specific to the stream exists, use SkImageDecoder _WIC.
163 return SkNEW(SkImageDecoder_WIC);
164 } else {
165 return decoder;
166 }
159 } 167 }
160 168
161 ///////////////////////////////////////////////////////////////////////// 169 /////////////////////////////////////////////////////////////////////////
162 170
163 SkMovie* SkMovie::DecodeStream(SkStream* stream) { 171 SkMovie* SkMovie::DecodeStream(SkStream* stream) {
164 return NULL; 172 return NULL;
165 } 173 }
166 174
167 ///////////////////////////////////////////////////////////////////////// 175 /////////////////////////////////////////////////////////////////////////
168 176
169 class SkImageEncoder_WIC : public SkImageEncoder { 177 class SkImageEncoder_WIC : public SkImageEncoder {
170 public: 178 public:
171 SkImageEncoder_WIC(Type t) : fType(t) {} 179 SkImageEncoder_WIC(Type t) : fType(t) {}
172 180
173 protected: 181 protected:
174 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality); 182 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality);
175 183
176 private: 184 private:
177 Type fType; 185 Type fType;
178 }; 186 };
179 187
180 bool SkImageEncoder_WIC::onEncode(SkWStream* stream 188 bool SkImageEncoder_WIC::onEncode(SkWStream* stream
181 , const SkBitmap& bitmapOrig 189 , const SkBitmap& bitmapOrig
182 , int quality) 190 , int quality)
183 { 191 {
184 GUID type; 192 GUID type;
185 switch (fType) { 193 switch (fType) {
194 case kBMP_Type:
195 type = GUID_ContainerFormatBmp;
196 break;
197 case kGIF_Type:
198 type = GUID_ContainerFormatGif;
199 break;
200 case kICO_Type:
201 type = GUID_ContainerFormatIco;
202 break;
186 case kJPEG_Type: 203 case kJPEG_Type:
187 type = GUID_ContainerFormatJpeg; 204 type = GUID_ContainerFormatJpeg;
188 break; 205 break;
189 case kPNG_Type: 206 case kPNG_Type:
190 type = GUID_ContainerFormatPng; 207 type = GUID_ContainerFormatPng;
191 break; 208 break;
192 default: 209 default:
193 return false; 210 return false;
194 } 211 }
195 212
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 hr = piBitmapFrameEncode->Commit(); 334 hr = piBitmapFrameEncode->Commit();
318 } 335 }
319 336
320 if (SUCCEEDED(hr)) { 337 if (SUCCEEDED(hr)) {
321 hr = piEncoder->Commit(); 338 hr = piEncoder->Commit();
322 } 339 }
323 340
324 return SUCCEEDED(hr); 341 return SUCCEEDED(hr);
325 } 342 }
326 343
327 SkImageEncoder* SkImageEncoder::Create(Type t) { 344 ///////////////////////////////////////////////////////////////////////////////
345
346 #include "SkTRegistry.h"
347
348 static SkImageEncoder* sk_imageencoder_wic_factory(SkImageEncoder::Type t) {
328 switch (t) { 349 switch (t) {
329 case kJPEG_Type: 350 case SkImageEncoder::kBMP_Type:
330 case kPNG_Type: 351 case SkImageEncoder::kGIF_Type:
352 case SkImageEncoder::kICO_Type:
353 case SkImageEncoder::kJPEG_Type:
354 case SkImageEncoder::kPNG_Type:
331 break; 355 break;
332 default: 356 default:
333 return NULL; 357 return NULL;
334 } 358 }
335 return SkNEW_ARGS(SkImageEncoder_WIC, (t)); 359 return SkNEW_ARGS(SkImageEncoder_WIC, (t));
336 } 360 }
361
362 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_imageencoder_ wic_factory);
OLDNEW
« no previous file with comments | « src/ports/SkImageDecoder_CG.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698