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

Side by Side Diff: samplecode/SampleSubpixelTranslate.cpp

Issue 346453002: Refactor how we handle resources path in Tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix rebase conflict Created 6 years, 6 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/SamplePicture.cpp ('k') | samplecode/SampleUnpremul.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
2 /* 1 /*
3 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9 #include "gm.h" 8 #include "gm.h"
9
10 #include "Resources.h"
10 #include "SampleCode.h" 11 #include "SampleCode.h"
11 #include "SkBlurMaskFilter.h" 12 #include "SkBlurMaskFilter.h"
13 #include "SkCanvas.h"
12 #include "SkColorPriv.h" 14 #include "SkColorPriv.h"
13 #include "SkCanvas.h"
14 #include "SkImageDecoder.h" 15 #include "SkImageDecoder.h"
15 #include "SkRandom.h" 16 #include "SkRandom.h"
16 #include "SkStream.h" 17 #include "SkStream.h"
17 18
18 // Intended to exercise pixel snapping observed with scaled images (and 19 // Intended to exercise pixel snapping observed with scaled images (and
19 // with non-scaled images, but for a different reason): Bug 1145 20 // with non-scaled images, but for a different reason): Bug 1145
20 21
21 class SubpixelTranslateView : public SampleView { 22 class SubpixelTranslateView : public SampleView {
22 public: 23 public:
23 SubpixelTranslateView(const char imageFilename[], 24 SubpixelTranslateView(const char imageFilename[],
24 float horizontalVelocity, 25 float horizontalVelocity,
25 float verticalVelocity) 26 float verticalVelocity)
26 : fFilename(imageFilename), 27 : fFilename(imageFilename),
27 fHorizontalVelocity(horizontalVelocity), 28 fHorizontalVelocity(horizontalVelocity),
28 fVerticalVelocity(verticalVelocity) { 29 fVerticalVelocity(verticalVelocity) {
29 SkString path(skiagm::GM::GetResourcePath()); 30 SkString resourcePath = GetResourcePath();
30 path.append("/"); 31 resourcePath.append("/");
31 path.append(fFilename); 32 resourcePath.append(fFilename);
32 33
33 SkImageDecoder *codec = NULL; 34 SkImageDecoder* codec = NULL;
34 SkFILEStream stream(path.c_str()); 35 SkFILEStream stream(resourcePath.c_str());
35 if (stream.isValid()) { 36 if (stream.isValid()) {
36 codec = SkImageDecoder::Factory(&stream); 37 codec = SkImageDecoder::Factory(&stream);
37 } 38 }
38 if (codec) { 39 if (codec) {
39 stream.rewind(); 40 stream.rewind();
40 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecode Pixels_Mode); 41 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecode Pixels_Mode);
41 SkDELETE(codec); 42 SkDELETE(codec);
42 } else { 43 } else {
43 fBM.allocN32Pixels(1, 1); 44 fBM.allocN32Pixels(1, 1);
44 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad 45 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 117 }
117 118
118 private: 119 private:
119 typedef SampleView INHERITED; 120 typedef SampleView INHERITED;
120 }; 121 };
121 122
122 ////////////////////////////////////////////////////////////////////////////// 123 //////////////////////////////////////////////////////////////////////////////
123 124
124 static SkView* MyFactory() { return new SubpixelTranslateView("mandrill_256.png" , .05f, .05f); } 125 static SkView* MyFactory() { return new SubpixelTranslateView("mandrill_256.png" , .05f, .05f); }
125 static SkViewRegister reg(MyFactory); 126 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SamplePicture.cpp ('k') | samplecode/SampleUnpremul.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698