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

Side by Side Diff: gm/pixelxorxfermode.cpp

Issue 1791583002: 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 unified diff | Download patch
« no previous file with comments | « gm/filterindiabox.cpp ('k') | gm/showmiplevels.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "Resources.h" 9 #include "Resources.h"
10 10
11 #include "SkImageDecoder.h"
12 #include "SkPixelXorXfermode.h" 11 #include "SkPixelXorXfermode.h"
13 #include "SkStream.h" 12 #include "SkStream.h"
14 13
15 class PixelXorXfermodeGM : public skiagm::GM { 14 class PixelXorXfermodeGM : public skiagm::GM {
16 public: 15 public:
17 PixelXorXfermodeGM() { } 16 PixelXorXfermodeGM() { }
18 17
19 protected: 18 protected:
20 SkString onShortName() override { 19 SkString onShortName() override {
21 return SkString("pixelxorxfermode"); 20 return SkString("pixelxorxfermode");
22 } 21 }
23 22
24 SkISize onISize() override { return SkISize::Make(512, 512); } 23 SkISize onISize() override { return SkISize::Make(512, 512); }
25 24
26 void onOnceBeforeDraw() override { 25 void onOnceBeforeDraw() override {
27 SkImageDecoder* codec = nullptr; 26 if (!GetResourceAsBitmap("mandrill_512.png", &fBM)) {
28 SkString resourcePath = GetResourcePath("mandrill_512.png");
29 SkFILEStream stream(resourcePath.c_str());
30 if (stream.isValid()) {
31 codec = SkImageDecoder::Factory(&stream);
32 }
33 if (codec) {
34 stream.rewind();
35 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDeco dePixels_Mode);
36 delete codec;
37 } else {
38 fBM.allocN32Pixels(1, 1); 27 fBM.allocN32Pixels(1, 1);
39 fBM.eraseARGB(255, 255, 0 , 0); // red == bad 28 fBM.eraseARGB(255, 255, 0 , 0); // red == bad
40 } 29 }
41 } 30 }
42 31
43 void onDraw(SkCanvas* canvas) override { 32 void onDraw(SkCanvas* canvas) override {
44 canvas->drawBitmap(fBM, 0, 0); 33 canvas->drawBitmap(fBM, 0, 0);
45 34
46 SkRect r = SkRect::MakeIWH(256, 256); 35 SkRect r = SkRect::MakeIWH(256, 256);
47 36
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 73
85 private: 74 private:
86 SkBitmap fBM; 75 SkBitmap fBM;
87 76
88 typedef GM INHERITED; 77 typedef GM INHERITED;
89 }; 78 };
90 79
91 ////////////////////////////////////////////////////////////////////////////// 80 //////////////////////////////////////////////////////////////////////////////
92 81
93 DEF_GM(return new PixelXorXfermodeGM;) 82 DEF_GM(return new PixelXorXfermodeGM;)
OLDNEW
« no previous file with comments | « gm/filterindiabox.cpp ('k') | gm/showmiplevels.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698