|
@@ -17,6 +17,8 @@
|
|
|
#include "base/strings/string_util.h"
|
|
|
#include "native_mate/object_template_builder.h"
|
|
|
#include "net/base/data_url.h"
|
|
|
+#include "third_party/skia/include/core/SkBitmap.h"
|
|
|
+#include "third_party/skia/include/core/SkImageInfo.h"
|
|
|
#include "third_party/skia/include/core/SkPixelRef.h"
|
|
|
#include "ui/base/layout.h"
|
|
|
#include "ui/base/webui/web_ui_util.h"
|
|
@@ -93,9 +95,20 @@ bool AddImageSkiaRep(gfx::ImageSkia* image,
|
|
|
std::unique_ptr<SkBitmap> decoded(new SkBitmap());
|
|
|
|
|
|
// Try PNG first.
|
|
|
- if (!gfx::PNGCodec::Decode(data, size, decoded.get()))
|
|
|
+ if (!gfx::PNGCodec::Decode(data, size, decoded.get())) {
|
|
|
// Try JPEG.
|
|
|
decoded = gfx::JPEGCodec::Decode(data, size);
|
|
|
+ if (decoded) {
|
|
|
+ // `JPEGCodec::Decode()` doesn't tell `SkBitmap` instance it creates
|
|
|
+ // that all of its pixels are opaque, that's why the bitmap gets
|
|
|
+ // an alpha type `kPremul_SkAlphaType` instead of `kOpaque_SkAlphaType`.
|
|
|
+ // Let's fix it here.
|
|
|
+ // TODO(alexeykuzmin): This workaround should be removed
|
|
|
+ // when the `JPEGCodec::Decode()` code is fixed.
|
|
|
+ // See https://github.com/electron/electron/issues/11294.
|
|
|
+ decoded->setAlphaType(SkAlphaType::kOpaque_SkAlphaType);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (!decoded) {
|
|
|
// Try Bitmap
|