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

Side by Side Diff: gm/filterindiabox.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 | « gm/filterbitmap.cpp ('k') | gm/gm.h » ('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 2011 Google Inc. 2 * Copyright 2011 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
10 #include "Resources.h"
11 #include "SkBitmapProcState.h"
12 #include "SkBitmapScaler.h"
9 #include "SkGradientShader.h" 13 #include "SkGradientShader.h"
10 14 #include "SkImageDecoder.h"
15 #include "SkImageEncoder.h"
16 #include "SkStream.h"
11 #include "SkTypeface.h" 17 #include "SkTypeface.h"
12 #include "SkImageDecoder.h"
13 #include "SkStream.h"
14
15 #include "SkImageEncoder.h"
16 #include "SkBitmapScaler.h"
17 #include "SkBitmapProcState.h"
18 18
19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { 19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), 20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()),
21 SkIntToScalar(bm.height())); 21 SkIntToScalar(bm.height()));
22 mat.mapRect(&bounds); 22 mat.mapRect(&bounds);
23 return SkSize::Make(bounds.width(), bounds.height()); 23 return SkSize::Make(bounds.width(), bounds.height());
24 } 24 }
25 25
26 static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx) { 26 static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx) {
27 SkPaint paint; 27 SkPaint paint;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 protected: 98 protected:
99 SkString fFilename; 99 SkString fFilename;
100 int fSize; 100 int fSize;
101 101
102 SkScalar getScale() { 102 SkScalar getScale() {
103 return 192.f/fSize; 103 return 192.f/fSize;
104 } 104 }
105 105
106 void makeBitmap() { 106 void makeBitmap() {
107 SkString path(skiagm::GM::gResourcePath); 107 SkString resourcePath = GetResourcePath();
108 path.append("/"); 108 resourcePath.append("/");
109 path.append(fFilename); 109 resourcePath.append(fFilename);
110 110
111 SkImageDecoder *codec = NULL; 111 SkImageDecoder* codec = NULL;
112 SkFILEStream stream(path.c_str()); 112 SkFILEStream stream(resourcePath.c_str());
113 if (stream.isValid()) { 113 if (stream.isValid()) {
114 codec = SkImageDecoder::Factory(&stream); 114 codec = SkImageDecoder::Factory(&stream);
115 } 115 }
116 if (codec) { 116 if (codec) {
117 stream.rewind(); 117 stream.rewind();
118 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe codePixels_Mode); 118 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe codePixels_Mode);
119 SkDELETE(codec); 119 SkDELETE(codec);
120 } else { 120 } else {
121 fBM.allocN32Pixels(1, 1); 121 fBM.allocN32Pixels(1, 1);
122 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad 122 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
123 } 123 }
124 fSize = fBM.height(); 124 fSize = fBM.height();
125 } 125 }
126 private: 126 private:
127 typedef skiagm::GM INHERITED; 127 typedef skiagm::GM INHERITED;
128 }; 128 };
129 129
130 ////////////////////////////////////////////////////////////////////////////// 130 //////////////////////////////////////////////////////////////////////////////
131 131
132 132
133 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) 133 DEF_GM( return new FilterIndiaBoxGM("box.gif"); )
OLDNEW
« no previous file with comments | « gm/filterbitmap.cpp ('k') | gm/gm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698