Remove uses of SkImageDecoder from gms

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1791583002

Review URL: https://codereview.chromium.org/1791583002
This commit is contained in:
msarett 2016-03-17 07:19:41 -07:00 committed by Commit bot
parent 667433ff5b
commit d427266a58
12 changed files with 26 additions and 155 deletions

View File

@ -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"

View File

@ -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
}

View File

@ -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);
}

View File

@ -32,9 +32,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;

View File

@ -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;

View File

@ -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"

View File

@ -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"

View File

@ -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;

View File

@ -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;

View File

@ -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
}

View File

@ -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"

View File

@ -9,7 +9,6 @@
#include "Resources.h"
#include "SkBitmap.h"
#include "SkImageDecoder.h"
#include "SkPaint.h"
#include "SkShader.h"
#include "SkStream.h"