aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/astcbitmap.cpp2
-rw-r--r--gm/avoidxfermode.cpp13
-rw-r--r--gm/cmykjpeg.cpp70
-rw-r--r--gm/copyTo4444.cpp5
-rw-r--r--gm/downsamplebitmap.cpp21
-rw-r--r--gm/etc1bitmap.cpp2
-rw-r--r--gm/factory.cpp1
-rw-r--r--gm/filterbitmap.cpp32
-rw-r--r--gm/filterindiabox.cpp21
-rw-r--r--gm/pixelxorxfermode.cpp13
-rw-r--r--gm/showmiplevels.cpp1
-rw-r--r--gm/tiledscaledbitmap.cpp1
-rw-r--r--src/ports/SkImageDecoder_WIC.cpp7
13 files changed, 28 insertions, 161 deletions
diff --git a/gm/astcbitmap.cpp b/gm/astcbitmap.cpp
index 181cfa4019..ca8a4f47f2 100644
--- a/gm/astcbitmap.cpp
+++ b/gm/astcbitmap.cpp
@@ -10,8 +10,8 @@
#include "Resources.h"
#include "SkCanvas.h"
#include "SkData.h"
+#include "SkImage.h"
#include "SkImageGenerator.h"
-#include "SkImageDecoder.h"
#include "SkOSFile.h"
#include "SkTextureCompressor.h"
diff --git a/gm/avoidxfermode.cpp b/gm/avoidxfermode.cpp
index a015b6bbe7..d224b4e2d0 100644
--- a/gm/avoidxfermode.cpp
+++ b/gm/avoidxfermode.cpp
@@ -8,7 +8,6 @@
#include "gm.h"
#include "Resources.h"
-#include "SkImageDecoder.h"
#include "SkAvoidXfermode.h"
#include "SkStream.h"
@@ -24,17 +23,7 @@ protected:
SkISize onISize() override { return SkISize::Make(128, 128); }
void onOnceBeforeDraw() override {
- SkImageDecoder* codec = nullptr;
- SkString resourcePath = GetResourcePath("color_wheel.png");
- SkFILEStream stream(resourcePath.c_str());
- if (stream.isValid()) {
- codec = SkImageDecoder::Factory(&stream);
- }
- if (codec) {
- stream.rewind();
- codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- delete codec;
- } else {
+ if (!GetResourceAsBitmap("color_wheel.png", &fBM)) {
fBM.allocN32Pixels(1, 1);
fBM.eraseARGB(255, 255, 0 , 0); // red == bad
}
diff --git a/gm/cmykjpeg.cpp b/gm/cmykjpeg.cpp
deleted file mode 100644
index d4fb2faa1c..0000000000
--- a/gm/cmykjpeg.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gm.h"
-
-#include "Resources.h"
-#include "SkCanvas.h"
-#include "SkImageDecoder.h"
-#include "SkStream.h"
-
-namespace skiagm {
-
-/** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB
- conversion so this tests Skia's internal processing
-*/
-class CMYKJpegGM : public GM {
-public:
- CMYKJpegGM() {}
-
-protected:
- void onOnceBeforeDraw() override {
- // parameters to the "decode" call
- bool dither = false;
-
- SkString jpgFilename = GetResourcePath("CMYK.jpg");
- SkFILEStream stream(jpgFilename.c_str());
- if (!stream.isValid()) {
- SkDebugf("Could not find CMYK.jpg, please set --resourcePath correctly.\n");
- return;
- }
-
- SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
- if (codec) {
- stream.rewind();
- codec->setDitherImage(dither);
- codec->decode(&stream, &fBitmap, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- delete codec;
- }
- }
-
- virtual SkString onShortName() override {
- return SkString("cmykjpeg");
- }
-
- virtual SkISize onISize() override {
- return SkISize::Make(640, 480);
- }
-
- virtual void onDraw(SkCanvas* canvas) override {
-
- canvas->translate(20*SK_Scalar1, 20*SK_Scalar1);
- canvas->drawBitmap(fBitmap, 0, 0);
- }
-
-private:
- SkBitmap fBitmap;
-
- typedef GM INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static GM* MyFactory(void*) { return new CMYKJpegGM; }
-static GMRegistry reg(MyFactory);
-
-}
diff --git a/gm/copyTo4444.cpp b/gm/copyTo4444.cpp
index 635cc7b834..64f2c60746 100644
--- a/gm/copyTo4444.cpp
+++ b/gm/copyTo4444.cpp
@@ -9,7 +9,6 @@
#include "Resources.h"
#include "SkCanvas.h"
-#include "SkImageDecoder.h"
#include "SkOSFile.h"
namespace skiagm {
@@ -32,9 +31,7 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
SkBitmap bm, bm4444;
- SkString pngFilename = GetResourcePath("mandrill_512.png");
- if (!SkImageDecoder::DecodeFile(pngFilename.c_str(), &bm, kN32_SkColorType,
- SkImageDecoder::kDecodePixels_Mode)) {
+ if (!GetResourceAsBitmap("mandrill_512.png", &bm)) {
SkDebugf("Could not decode the file. Did you forget to set the "
"resourcePath?\n");
return;
diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp
index 771eb6ab53..a99bae0cd9 100644
--- a/gm/downsamplebitmap.cpp
+++ b/gm/downsamplebitmap.cpp
@@ -10,7 +10,6 @@
#include "Resources.h"
#include "SkGradientShader.h"
#include "SkTypeface.h"
-#include "SkImageDecoder.h"
#include "SkStream.h"
#include "SkPaint.h"
@@ -171,21 +170,11 @@ class DownsampleBitmapImageGM: public DownsampleBitmapGM {
int fSize;
void make_bitmap() override {
- SkImageDecoder* codec = nullptr;
- SkString resourcePath = GetResourcePath(fFilename.c_str());
- SkFILEStream stream(resourcePath.c_str());
- if (stream.isValid()) {
- codec = SkImageDecoder::Factory(&stream);
- }
- if (codec) {
- stream.rewind();
- codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- delete codec;
- } else {
- fBM.allocN32Pixels(1, 1);
- *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
- }
- fSize = fBM.height();
+ if (!GetResourceAsBitmap(fFilename.c_str(), &fBM)) {
+ fBM.allocN32Pixels(1, 1);
+ fBM.eraseARGB(255, 255, 0 , 0); // red == bad
+ }
+ fSize = fBM.height();
}
private:
typedef DownsampleBitmapGM INHERITED;
diff --git a/gm/etc1bitmap.cpp b/gm/etc1bitmap.cpp
index 51c1f3948c..9d47999151 100644
--- a/gm/etc1bitmap.cpp
+++ b/gm/etc1bitmap.cpp
@@ -10,8 +10,8 @@
#include "Resources.h"
#include "SkCanvas.h"
#include "SkData.h"
+#include "SkImage.h"
#include "SkImageGenerator.h"
-#include "SkImageDecoder.h"
#include "SkOSFile.h"
#include "SkTemplates.h"
diff --git a/gm/factory.cpp b/gm/factory.cpp
index 4d36574daa..831cff0b9f 100644
--- a/gm/factory.cpp
+++ b/gm/factory.cpp
@@ -12,7 +12,6 @@
#include "SkData.h"
#include "SkDiscardableMemoryPool.h"
#include "SkDiscardablePixelRef.h"
-#include "SkImageDecoder.h"
#include "SkImageGeneratorPriv.h"
#include "SkOSFile.h"
#include "SkStream.h"
diff --git a/gm/filterbitmap.cpp b/gm/filterbitmap.cpp
index 5c63910a78..51a8064d80 100644
--- a/gm/filterbitmap.cpp
+++ b/gm/filterbitmap.cpp
@@ -9,7 +9,6 @@
#include "Resources.h"
#include "SkGradientShader.h"
-#include "SkImageDecoder.h"
#include "SkStream.h"
#include "SkTypeface.h"
@@ -196,26 +195,17 @@ protected:
}
void makeBitmap() override {
- SkImageDecoder* codec = nullptr;
- SkString resourcePath = GetResourcePath(fFilename.c_str());
- SkFILEStream stream(resourcePath.c_str());
- if (stream.isValid()) {
- codec = SkImageDecoder::Factory(&stream);
- }
- if (codec) {
- stream.rewind();
- codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- delete codec;
- } else {
- fBM.allocN32Pixels(1, 1);
- *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
- }
- fSize = fBM.height();
- if (fConvertToG8) {
- SkBitmap tmp;
- fBM.copyTo(&tmp, kGray_8_SkColorType);
- fBM = tmp;
- }
+ if (!GetResourceAsBitmap(fFilename.c_str(), &fBM)) {
+ fBM.allocN32Pixels(1, 1);
+ fBM.eraseARGB(255, 255, 0 , 0); // red == bad
+ }
+ fSize = fBM.height();
+
+ if (fConvertToG8) {
+ SkBitmap tmp;
+ fBM.copyTo(&tmp, kGray_8_SkColorType);
+ fBM = tmp;
+ }
}
private:
const bool fConvertToG8;
diff --git a/gm/filterindiabox.cpp b/gm/filterindiabox.cpp
index c5d7166423..569a694968 100644
--- a/gm/filterindiabox.cpp
+++ b/gm/filterindiabox.cpp
@@ -11,7 +11,6 @@
#include "SkBitmapProcState.h"
#include "SkBitmapScaler.h"
#include "SkGradientShader.h"
-#include "SkImageDecoder.h"
#include "SkImageEncoder.h"
#include "SkStream.h"
#include "SkTypeface.h"
@@ -99,21 +98,11 @@ protected:
}
void makeBitmap() {
- SkImageDecoder* codec = nullptr;
- SkString resourcePath = GetResourcePath(fFilename.c_str());
- SkFILEStream stream(resourcePath.c_str());
- if (stream.isValid()) {
- codec = SkImageDecoder::Factory(&stream);
- }
- if (codec) {
- stream.rewind();
- codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- delete codec;
- } else {
- fBM.allocN32Pixels(1, 1);
- *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
- }
- fSize = fBM.height();
+ if (!GetResourceAsBitmap(fFilename.c_str(), &fBM)) {
+ fBM.allocN32Pixels(1, 1);
+ fBM.eraseARGB(255, 255, 0 , 0); // red == bad
+ }
+ fSize = fBM.height();
}
private:
typedef skiagm::GM INHERITED;
diff --git a/gm/pixelxorxfermode.cpp b/gm/pixelxorxfermode.cpp
index 35926a81c6..daccca8c41 100644
--- a/gm/pixelxorxfermode.cpp
+++ b/gm/pixelxorxfermode.cpp
@@ -8,7 +8,6 @@
#include "gm.h"
#include "Resources.h"
-#include "SkImageDecoder.h"
#include "SkPixelXorXfermode.h"
#include "SkStream.h"
@@ -24,17 +23,7 @@ protected:
SkISize onISize() override { return SkISize::Make(512, 512); }
void onOnceBeforeDraw() override {
- SkImageDecoder* codec = nullptr;
- SkString resourcePath = GetResourcePath("mandrill_512.png");
- SkFILEStream stream(resourcePath.c_str());
- if (stream.isValid()) {
- codec = SkImageDecoder::Factory(&stream);
- }
- if (codec) {
- stream.rewind();
- codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- delete codec;
- } else {
+ if (!GetResourceAsBitmap("mandrill_512.png", &fBM)) {
fBM.allocN32Pixels(1, 1);
fBM.eraseARGB(255, 255, 0 , 0); // red == bad
}
diff --git a/gm/showmiplevels.cpp b/gm/showmiplevels.cpp
index d3462b7803..fd1254f9bc 100644
--- a/gm/showmiplevels.cpp
+++ b/gm/showmiplevels.cpp
@@ -11,7 +11,6 @@
#include "SkBitmapScaler.h"
#include "SkGradientShader.h"
#include "SkTypeface.h"
-#include "SkImageDecoder.h"
#include "SkStream.h"
#include "SkPaint.h"
#include "SkMipMap.h"
diff --git a/gm/tiledscaledbitmap.cpp b/gm/tiledscaledbitmap.cpp
index d74d40bf49..5511b8b3d9 100644
--- a/gm/tiledscaledbitmap.cpp
+++ b/gm/tiledscaledbitmap.cpp
@@ -9,7 +9,6 @@
#include "Resources.h"
#include "SkBitmap.h"
-#include "SkImageDecoder.h"
#include "SkPaint.h"
#include "SkShader.h"
#include "SkStream.h"
diff --git a/src/ports/SkImageDecoder_WIC.cpp b/src/ports/SkImageDecoder_WIC.cpp
index fa408836a4..c7222e635a 100644
--- a/src/ports/SkImageDecoder_WIC.cpp
+++ b/src/ports/SkImageDecoder_WIC.cpp
@@ -404,16 +404,13 @@ bool SkImageEncoder_WIC::onEncode(SkWStream* stream
hr = piBitmapFrameEncode->SetSize(width, height);
}
- //Set the pixel format of the frame.
+ //Set the pixel format of the frame. If native encoded format cannot match BGRA,
+ //it will choose the closest pixel format that it supports.
const WICPixelFormatGUID formatDesired = GUID_WICPixelFormat32bppBGRA;
WICPixelFormatGUID formatGUID = formatDesired;
if (SUCCEEDED(hr)) {
hr = piBitmapFrameEncode->SetPixelFormat(&formatGUID);
}
- if (SUCCEEDED(hr)) {
- //Be sure the image format is the one requested.
- hr = IsEqualGUID(formatGUID, formatDesired) ? S_OK : E_FAIL;
- }
//Write the pixels into the frame.
if (SUCCEEDED(hr)) {