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

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

Issue 23477009: Change SkImageDecoders to take an SkStreamRewindable. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Only switch to SkStreamRewindable when necessary. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/ports/SkImageDecoder_CG.cpp ('k') | src/ports/SkImageDecoder_empty.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 /* 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 // Note: we don't need to premultiply here since we specified PBGRA 224 // Note: we don't need to premultiply here since we specified PBGRA
225 bm->computeAndSetOpaquePredicate(); 225 bm->computeAndSetOpaquePredicate();
226 } 226 }
227 227
228 return SUCCEEDED(hr); 228 return SUCCEEDED(hr);
229 } 229 }
230 230
231 ///////////////////////////////////////////////////////////////////////// 231 /////////////////////////////////////////////////////////////////////////
232 232
233 extern SkImageDecoder* image_decoder_from_stream(SkStream*); 233 extern SkImageDecoder* image_decoder_from_stream(SkStreamRewindable*);
234 234
235 SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) { 235 SkImageDecoder* SkImageDecoder::Factory(SkStreamRewindable* stream) {
236 SkImageDecoder* decoder = image_decoder_from_stream(stream); 236 SkImageDecoder* decoder = image_decoder_from_stream(stream);
237 if (NULL == decoder) { 237 if (NULL == decoder) {
238 // If no image decoder specific to the stream exists, use SkImageDecoder _WIC. 238 // If no image decoder specific to the stream exists, use SkImageDecoder _WIC.
239 return SkNEW(SkImageDecoder_WIC); 239 return SkNEW(SkImageDecoder_WIC);
240 } else { 240 } else {
241 return decoder; 241 return decoder;
242 } 242 }
243 } 243 }
244 244
245 ///////////////////////////////////////////////////////////////////////// 245 /////////////////////////////////////////////////////////////////////////
246 246
247 SkMovie* SkMovie::DecodeStream(SkStream* stream) { 247 SkMovie* SkMovie::DecodeStream(SkStreamRewindable* stream) {
248 return NULL; 248 return NULL;
249 } 249 }
250 250
251 ///////////////////////////////////////////////////////////////////////// 251 /////////////////////////////////////////////////////////////////////////
252 252
253 class SkImageEncoder_WIC : public SkImageEncoder { 253 class SkImageEncoder_WIC : public SkImageEncoder {
254 public: 254 public:
255 SkImageEncoder_WIC(Type t) : fType(t) {} 255 SkImageEncoder_WIC(Type t) : fType(t) {}
256 256
257 protected: 257 protected:
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 if (SUCCEEDED(hr)) { 411 if (SUCCEEDED(hr)) {
412 hr = piEncoder->Commit(); 412 hr = piEncoder->Commit();
413 } 413 }
414 414
415 return SUCCEEDED(hr); 415 return SUCCEEDED(hr);
416 } 416 }
417 417
418 /////////////////////////////////////////////////////////////////////////////// 418 ///////////////////////////////////////////////////////////////////////////////
419 419
420 #include "SkTRegistry.h"
421
422 static SkImageEncoder* sk_imageencoder_wic_factory(SkImageEncoder::Type t) { 420 static SkImageEncoder* sk_imageencoder_wic_factory(SkImageEncoder::Type t) {
423 switch (t) { 421 switch (t) {
424 case SkImageEncoder::kBMP_Type: 422 case SkImageEncoder::kBMP_Type:
425 case SkImageEncoder::kICO_Type: 423 case SkImageEncoder::kICO_Type:
426 case SkImageEncoder::kJPEG_Type: 424 case SkImageEncoder::kJPEG_Type:
427 case SkImageEncoder::kPNG_Type: 425 case SkImageEncoder::kPNG_Type:
428 break; 426 break;
429 default: 427 default:
430 return NULL; 428 return NULL;
431 } 429 }
432 return SkNEW_ARGS(SkImageEncoder_WIC, (t)); 430 return SkNEW_ARGS(SkImageEncoder_WIC, (t));
433 } 431 }
434 432
435 static SkTRegistry<SkImageEncoder*(*)(SkImageEncoder::Type)> gEReg(sk_imageencod er_wic_factory); 433 static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_wic_factory);
436 434
437 static SkImageDecoder::Format get_format_wic(SkStream* stream) { 435 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) {
438 SkImageDecoder::Format format; 436 SkImageDecoder::Format format;
439 SkImageDecoder_WIC codec; 437 SkImageDecoder_WIC codec;
440 if (!codec.decodeStream(stream, NULL, SkImageDecoder_WIC::kDecodeFormat_WICM ode, &format)) { 438 if (!codec.decodeStream(stream, NULL, SkImageDecoder_WIC::kDecodeFormat_WICM ode, &format)) {
441 format = SkImageDecoder::kUnknown_Format; 439 format = SkImageDecoder::kUnknown_Format;
442 } 440 }
443 return format; 441 return format;
444 } 442 }
445 443
446 static SkTRegistry<SkImageDecoder::Format(*)(SkStream*)> gFormatReg(get_format_w ic); 444 static SkImageDecoder_FormatReg gFormatReg(get_format_wic);
OLDNEW
« no previous file with comments | « src/ports/SkImageDecoder_CG.cpp ('k') | src/ports/SkImageDecoder_empty.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698