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

Side by Side Diff: samplecode/SampleSubpixelTranslate.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/SampleSlides.cpp ('k') | samplecode/SampleText.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 "SkRandom.h" 16 #include "SkRandom.h"
17 #include "SkStream.h" 17 #include "SkStream.h"
18 18
19 // Intended to exercise pixel snapping observed with scaled images (and 19 // Intended to exercise pixel snapping observed with scaled images (and
20 // with non-scaled images, but for a different reason): Bug 1145 20 // with non-scaled images, but for a different reason): Bug 1145
21 21
22 class SubpixelTranslateView : public SampleView { 22 class SubpixelTranslateView : public SampleView {
23 public: 23 public:
24 SubpixelTranslateView(const char imageFilename[], 24 SubpixelTranslateView(const char imageFilename[],
25 float horizontalVelocity, 25 float horizontalVelocity,
26 float verticalVelocity) 26 float verticalVelocity)
27 : fHorizontalVelocity(horizontalVelocity), 27 : fHorizontalVelocity(horizontalVelocity),
28 fVerticalVelocity(verticalVelocity) { 28 fVerticalVelocity(verticalVelocity) {
29 SkString resourcePath = GetResourcePath(imageFilename); 29 SkString resourcePath = GetResourcePath(imageFilename);
30 SkImageDecoder* codec = nullptr; 30 if (!decode_file(resourcePath.c_str(), &fBM)) {
31 SkFILEStream stream(resourcePath.c_str());
32 if (stream.isValid()) {
33 codec = SkImageDecoder::Factory(&stream);
34 }
35 if (codec) {
36 stream.rewind();
37 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecode Pixels_Mode);
38 delete codec;
39 } else {
40 fBM.allocN32Pixels(1, 1); 31 fBM.allocN32Pixels(1, 1);
41 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad 32 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
42 } 33 }
43 fCurPos = SkPoint::Make(0,0); 34 fCurPos = SkPoint::Make(0,0);
44 fSize = 200; 35 fSize = 200;
45 } 36 }
46 37
47 protected: 38 protected:
48 SkBitmap fBM; 39 SkBitmap fBM;
49 SkScalar fSize; 40 SkScalar fSize;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 104 }
114 105
115 private: 106 private:
116 typedef SampleView INHERITED; 107 typedef SampleView INHERITED;
117 }; 108 };
118 109
119 ////////////////////////////////////////////////////////////////////////////// 110 //////////////////////////////////////////////////////////////////////////////
120 111
121 static SkView* MyFactory() { return new SubpixelTranslateView("mandrill_256.png" , .05f, .05f); } 112 static SkView* MyFactory() { return new SubpixelTranslateView("mandrill_256.png" , .05f, .05f); }
122 static SkViewRegister reg(MyFactory); 113 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleSlides.cpp ('k') | samplecode/SampleText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698