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

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

Issue 1791583002: Remove uses of SkImageDecoder from gms (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bug in WIC encoder 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 | « gm/tiledscaledbitmap.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 #include "SkTypes.h" 9 #include "SkTypes.h"
10 10
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 hr = piBitmapFrameEncode->Initialize(piPropertybag.get()); 397 hr = piBitmapFrameEncode->Initialize(piPropertybag.get());
398 } 398 }
399 399
400 //Set the size of the frame. 400 //Set the size of the frame.
401 const UINT width = bitmap->width(); 401 const UINT width = bitmap->width();
402 const UINT height = bitmap->height(); 402 const UINT height = bitmap->height();
403 if (SUCCEEDED(hr)) { 403 if (SUCCEEDED(hr)) {
404 hr = piBitmapFrameEncode->SetSize(width, height); 404 hr = piBitmapFrameEncode->SetSize(width, height);
405 } 405 }
406 406
407 //Set the pixel format of the frame. 407 //Set the pixel format of the frame. If native encoded format cannot match BGRA,
408 //it will choose the closest pixel format that it supports.
408 const WICPixelFormatGUID formatDesired = GUID_WICPixelFormat32bppBGRA; 409 const WICPixelFormatGUID formatDesired = GUID_WICPixelFormat32bppBGRA;
409 WICPixelFormatGUID formatGUID = formatDesired; 410 WICPixelFormatGUID formatGUID = formatDesired;
410 if (SUCCEEDED(hr)) { 411 if (SUCCEEDED(hr)) {
411 hr = piBitmapFrameEncode->SetPixelFormat(&formatGUID); 412 hr = piBitmapFrameEncode->SetPixelFormat(&formatGUID);
412 } 413 }
413 if (SUCCEEDED(hr)) {
msarett 2016/03/18 16:41:32 This code block causes the WIC encoder to fail for
414 //Be sure the image format is the one requested.
415 hr = IsEqualGUID(formatGUID, formatDesired) ? S_OK : E_FAIL;
416 }
417 414
418 //Write the pixels into the frame. 415 //Write the pixels into the frame.
419 if (SUCCEEDED(hr)) { 416 if (SUCCEEDED(hr)) {
420 SkAutoLockPixels alp(*bitmap); 417 SkAutoLockPixels alp(*bitmap);
421 const UINT stride = (UINT) bitmap->rowBytes(); 418 const UINT stride = (UINT) bitmap->rowBytes();
422 hr = piBitmapFrameEncode->WritePixels( 419 hr = piBitmapFrameEncode->WritePixels(
423 height 420 height
424 , stride 421 , stride
425 , stride * height 422 , stride * height
426 , reinterpret_cast<BYTE*>(bitmap->getPixels())); 423 , reinterpret_cast<BYTE*>(bitmap->getPixels()));
427 } 424 }
428 425
429 if (SUCCEEDED(hr)) { 426 if (SUCCEEDED(hr)) {
430 hr = piBitmapFrameEncode->Commit(); 427 hr = piBitmapFrameEncode->Commit();
431 } 428 }
432 429
433 if (SUCCEEDED(hr)) { 430 if (SUCCEEDED(hr)) {
434 hr = piEncoder->Commit(); 431 hr = piEncoder->Commit();
435 } 432 }
436 433
437 return SUCCEEDED(hr); 434 return SUCCEEDED(hr);
438 } 435 }
439 436
440 /////////////////////////////////////////////////////////////////////////////// 437 ///////////////////////////////////////////////////////////////////////////////
441 438 /*
scroggo 2016/03/18 17:23:12 This will disable the encoders on Windows. Is that
442 static SkImageEncoder* sk_imageencoder_wic_factory(SkImageEncoder::Type t) { 439 static SkImageEncoder* sk_imageencoder_wic_factory(SkImageEncoder::Type t) {
443 switch (t) { 440 switch (t) {
444 case SkImageEncoder::kBMP_Type: 441 case SkImageEncoder::kBMP_Type:
445 case SkImageEncoder::kICO_Type: 442 case SkImageEncoder::kICO_Type:
446 case SkImageEncoder::kJPEG_Type: 443 case SkImageEncoder::kJPEG_Type:
447 case SkImageEncoder::kPNG_Type: 444 case SkImageEncoder::kPNG_Type:
448 break; 445 break;
449 default: 446 default:
450 return nullptr; 447 return nullptr;
451 } 448 }
452 return new SkImageEncoder_WIC(t); 449 return new SkImageEncoder_WIC(t);
453 } 450 }
454 451
455 static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_wic_factory); 452 static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_wic_factory);*/
456 453
457 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) { 454 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) {
458 SkImageDecoder::Format format; 455 SkImageDecoder::Format format;
459 SkImageDecoder_WIC codec; 456 SkImageDecoder_WIC codec;
460 if (!codec.decodeStream(stream, nullptr, SkImageDecoder_WIC::kDecodeFormat_W ICMode, &format)) { 457 if (!codec.decodeStream(stream, nullptr, SkImageDecoder_WIC::kDecodeFormat_W ICMode, &format)) {
461 format = SkImageDecoder::kUnknown_Format; 458 format = SkImageDecoder::kUnknown_Format;
462 } 459 }
463 return format; 460 return format;
464 } 461 }
465 462
466 static SkImageDecoder_FormatReg gFormatReg(get_format_wic); 463 static SkImageDecoder_FormatReg gFormatReg(get_format_wic);
467 464
468 #endif // defined(SK_BUILD_FOR_WIN32) 465 #endif // defined(SK_BUILD_FOR_WIN32)
OLDNEW
« no previous file with comments | « gm/tiledscaledbitmap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698