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

Side by Side Diff: samplecode/SampleIdentityScale.cpp

Issue 1812323003: Remove uses of SkImageDecoder from samplecode (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 | « samplecode/SampleHairline.cpp ('k') | samplecode/SampleLayers.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 2014 Google Inc. 2 * Copyright 2014 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 "DecodeFile.h"
8 #include "gm.h" 9 #include "gm.h"
9 10
10 #include "Resources.h" 11 #include "Resources.h"
11 #include "SampleCode.h" 12 #include "SampleCode.h"
12 #include "SkBlurMaskFilter.h" 13 #include "SkBlurMaskFilter.h"
13 #include "SkCanvas.h" 14 #include "SkCanvas.h"
14 #include "SkColorPriv.h" 15 #include "SkColorPriv.h"
15 #include "SkImageDecoder.h"
16 #include "SkPath.h" 16 #include "SkPath.h"
17 #include "SkRandom.h" 17 #include "SkRandom.h"
18 #include "SkStream.h" 18 #include "SkStream.h"
19 #include "SkTime.h" 19 #include "SkTime.h"
20 20
21 // Intended to exercise pixel snapping observed with scaled images (and 21 // Intended to exercise pixel snapping observed with scaled images (and
22 // with non-scaled images, but for a different reason): Bug 1145 22 // with non-scaled images, but for a different reason): Bug 1145
23 23
24 class IdentityScaleView : public SampleView { 24 class IdentityScaleView : public SampleView {
25 public: 25 public:
26 IdentityScaleView(const char imageFilename[]) { 26 IdentityScaleView(const char imageFilename[]) {
27 SkString resourcePath = GetResourcePath(imageFilename); 27 SkString resourcePath = GetResourcePath(imageFilename);
28 SkImageDecoder* codec = nullptr; 28 if (!decode_file(resourcePath.c_str(), &fBM)) {
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::kDecode Pixels_Mode);
36 delete codec;
37 } else {
38 fBM.allocN32Pixels(1, 1); 29 fBM.allocN32Pixels(1, 1);
39 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad 30 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
40 } 31 }
41 } 32 }
42 33
43 protected: 34 protected:
44 SkBitmap fBM; 35 SkBitmap fBM;
45 36
46 // overrides from SkEventSink 37 // overrides from SkEventSink
47 bool onQuery(SkEvent* evt) override { 38 bool onQuery(SkEvent* evt) override {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 75 }
85 76
86 private: 77 private:
87 typedef SampleView INHERITED; 78 typedef SampleView INHERITED;
88 }; 79 };
89 80
90 ////////////////////////////////////////////////////////////////////////////// 81 //////////////////////////////////////////////////////////////////////////////
91 82
92 static SkView* MyFactory() { return new IdentityScaleView("mandrill_256.png"); } 83 static SkView* MyFactory() { return new IdentityScaleView("mandrill_256.png"); }
93 static SkViewRegister reg(MyFactory); 84 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleHairline.cpp ('k') | samplecode/SampleLayers.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698