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

Unified Diff: gm/filterbitmap.cpp

Issue 1806383002: Revert of Remove uses of SkImageDecoder from gms (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/factory.cpp ('k') | gm/filterindiabox.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/filterbitmap.cpp
diff --git a/gm/filterbitmap.cpp b/gm/filterbitmap.cpp
index 51a8064d801a91057ccaee75008e17e1c35b1a32..5c63910a7842db484a3eed0595f4cb475613f0b8 100644
--- a/gm/filterbitmap.cpp
+++ b/gm/filterbitmap.cpp
@@ -9,6 +9,7 @@
#include "Resources.h"
#include "SkGradientShader.h"
+#include "SkImageDecoder.h"
#include "SkStream.h"
#include "SkTypeface.h"
@@ -195,17 +196,26 @@
}
void makeBitmap() override {
- 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;
- }
+ 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;
+ }
}
private:
const bool fConvertToG8;
« no previous file with comments | « gm/factory.cpp ('k') | gm/filterindiabox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698