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

Unified Diff: gm/downsamplebitmap.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/copyTo4444.cpp ('k') | gm/etc1bitmap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/downsamplebitmap.cpp
diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp
index a99bae0cd998937cec663fef3d29fcef9d0f07da..771eb6ab53d34c8b75ae246b777eb3f09e850e45 100644
--- a/gm/downsamplebitmap.cpp
+++ b/gm/downsamplebitmap.cpp
@@ -10,6 +10,7 @@
#include "Resources.h"
#include "SkGradientShader.h"
#include "SkTypeface.h"
+#include "SkImageDecoder.h"
#include "SkStream.h"
#include "SkPaint.h"
@@ -170,11 +171,21 @@
int fSize;
void make_bitmap() override {
- if (!GetResourceAsBitmap(fFilename.c_str(), &fBM)) {
- fBM.allocN32Pixels(1, 1);
- fBM.eraseARGB(255, 255, 0 , 0); // red == bad
- }
- fSize = fBM.height();
+ 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();
}
private:
typedef DownsampleBitmapGM INHERITED;
« no previous file with comments | « gm/copyTo4444.cpp ('k') | gm/etc1bitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698