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

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

Issue 670453002: Remove image decoder and encoder autoregistration (Closed) Base URL: https://skia.googlesource.com/skia.git@separate-image-decoder-01-skpicture
Patch Set: Created 6 years, 1 month 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 | « src/ports/SkImageDecoder_WIC.h ('k') | src/utils/SkBitmapHasher.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 #include "SkTypes.h" 9 #include "SkImageDecoder_WIC.h"
10
11 // Workaround for: 10 // Workaround for:
12 // http://connect.microsoft.com/VisualStudio/feedback/details/621653/ 11 // http://connect.microsoft.com/VisualStudio/feedback/details/621653/
13 // http://crbug.com/225822 12 // http://crbug.com/225822
14 // In VS2010 both intsafe.h and stdint.h define the following without guards. 13 // In VS2010 both intsafe.h and stdint.h define the following without guards.
15 // SkTypes brought in windows.h and stdint.h and the following defines are 14 // SkTypes brought in windows.h and stdint.h and the following defines are
16 // not used by this file. However, they may be re-introduced by wincodec.h. 15 // not used by this file. However, they may be re-introduced by wincodec.h.
17 #undef INT8_MIN 16 #undef INT8_MIN
18 #undef INT16_MIN 17 #undef INT16_MIN
19 #undef INT32_MIN 18 #undef INT32_MIN
20 #undef INT64_MIN 19 #undef INT64_MIN
21 #undef INT8_MAX 20 #undef INT8_MAX
22 #undef UINT8_MAX 21 #undef UINT8_MAX
23 #undef INT16_MAX 22 #undef INT16_MAX
24 #undef UINT16_MAX 23 #undef UINT16_MAX
25 #undef INT32_MAX 24 #undef INT32_MAX
26 #undef UINT32_MAX 25 #undef UINT32_MAX
27 #undef INT64_MAX 26 #undef INT64_MAX
28 #undef UINT64_MAX 27 #undef UINT64_MAX
29 28
30 #include <wincodec.h> 29 #include <wincodec.h>
31 #include "SkAutoCoInitialize.h" 30 #include "SkAutoCoInitialize.h"
32 #include "SkImageDecoder.h"
33 #include "SkImageEncoder.h"
34 #include "SkIStream.h" 31 #include "SkIStream.h"
35 #include "SkMovie.h"
36 #include "SkStream.h" 32 #include "SkStream.h"
37 #include "SkTScopedComPtr.h" 33 #include "SkTScopedComPtr.h"
38 #include "SkUnPreMultiply.h" 34 #include "SkUnPreMultiply.h"
39 35
40 //All Windows SDKs back to XPSP2 export the CLSID_WICImagingFactory symbol. 36 //All Windows SDKs back to XPSP2 export the CLSID_WICImagingFactory symbol.
41 //In the Windows8 SDK the CLSID_WICImagingFactory symbol is still exported 37 //In the Windows8 SDK the CLSID_WICImagingFactory symbol is still exported
42 //but CLSID_WICImagingFactory is then #defined to CLSID_WICImagingFactory2. 38 //but CLSID_WICImagingFactory is then #defined to CLSID_WICImagingFactory2.
43 //Undo this #define if it has been done so that we link against the symbols 39 //Undo this #define if it has been done so that we link against the symbols
44 //we intended to link against on all SDKs. 40 //we intended to link against on all SDKs.
45 #if defined(CLSID_WICImagingFactory) 41 #if defined(CLSID_WICImagingFactory)
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (SkBitmap::ComputeIsOpaque(*bm)) { 239 if (SkBitmap::ComputeIsOpaque(*bm)) {
244 bm->setAlphaType(kOpaque_SkAlphaType); 240 bm->setAlphaType(kOpaque_SkAlphaType);
245 } 241 }
246 } 242 }
247 243
248 return SUCCEEDED(hr); 244 return SUCCEEDED(hr);
249 } 245 }
250 246
251 ///////////////////////////////////////////////////////////////////////// 247 /////////////////////////////////////////////////////////////////////////
252 248
253 extern SkImageDecoder* image_decoder_from_stream(SkStreamRewindable*); 249 SkImageDecoder* SkCreateImageDecoder_WIC(SkImageDecoder::Format format) {
254 250 SkASSERT(SkImageDecoder::kUnknown_Format != format);
255 SkImageDecoder* SkImageDecoder::Factory(SkStreamRewindable* stream) { 251 return SkNEW(SkImageDecoder_WIC);
256 SkImageDecoder* decoder = image_decoder_from_stream(stream);
257 if (NULL == decoder) {
258 // If no image decoder specific to the stream exists, use SkImageDecoder _WIC.
259 return SkNEW(SkImageDecoder_WIC);
260 } else {
261 return decoder;
262 }
263 } 252 }
264 253
265 ///////////////////////////////////////////////////////////////////////// 254 /////////////////////////////////////////////////////////////////////////
266
267 SkMovie* SkMovie::DecodeStream(SkStreamRewindable* stream) {
268 return NULL;
269 }
270
271 /////////////////////////////////////////////////////////////////////////
272 255
273 class SkImageEncoder_WIC : public SkImageEncoder { 256 class SkImageEncoder_WIC : public SkImageEncoder {
274 public: 257 public:
275 SkImageEncoder_WIC(Type t) : fType(t) {} 258 SkImageEncoder_WIC(Type t) : fType(t) {}
276 259
277 protected: 260 protected:
278 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality); 261 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality);
279 262
280 private: 263 private:
281 Type fType; 264 Type fType;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 413
431 if (SUCCEEDED(hr)) { 414 if (SUCCEEDED(hr)) {
432 hr = piEncoder->Commit(); 415 hr = piEncoder->Commit();
433 } 416 }
434 417
435 return SUCCEEDED(hr); 418 return SUCCEEDED(hr);
436 } 419 }
437 420
438 /////////////////////////////////////////////////////////////////////////////// 421 ///////////////////////////////////////////////////////////////////////////////
439 422
440 static SkImageEncoder* sk_imageencoder_wic_factory(SkImageEncoder::Type t) { 423 SkImageEncoder* SkCreateImageEncoder_WIC(SkImageEncoder::Type t) {
441 switch (t) { 424 switch (t) {
442 case SkImageEncoder::kBMP_Type: 425 case SkImageEncoder::kBMP_Type:
443 case SkImageEncoder::kICO_Type: 426 case SkImageEncoder::kICO_Type:
444 case SkImageEncoder::kJPEG_Type: 427 case SkImageEncoder::kJPEG_Type:
445 case SkImageEncoder::kPNG_Type: 428 case SkImageEncoder::kPNG_Type:
446 break; 429 break;
447 default: 430 default:
448 return NULL; 431 return NULL;
449 } 432 }
450 return SkNEW_ARGS(SkImageEncoder_WIC, (t)); 433 return SkNEW_ARGS(SkImageEncoder_WIC, (t));
451 } 434 }
452 435
453 static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_wic_factory); 436 SkImageDecoder::Format SkDetectFormatImageDecoder_WIC(SkStreamRewindable* stream ) {
454
455 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) {
456 SkImageDecoder::Format format; 437 SkImageDecoder::Format format;
457 SkImageDecoder_WIC codec; 438 SkImageDecoder_WIC codec;
458 if (!codec.decodeStream(stream, NULL, SkImageDecoder_WIC::kDecodeFormat_WICM ode, &format)) { 439 if (!codec.decodeStream(stream, NULL, SkImageDecoder_WIC::kDecodeFormat_WICM ode, &format)) {
459 format = SkImageDecoder::kUnknown_Format; 440 format = SkImageDecoder::kUnknown_Format;
460 } 441 }
461 return format; 442 return format;
462 } 443 }
463
464 static SkImageDecoder_FormatReg gFormatReg(get_format_wic);
OLDNEW
« no previous file with comments | « src/ports/SkImageDecoder_WIC.h ('k') | src/utils/SkBitmapHasher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698