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

Side by Side Diff: gm/copyTo4444.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/coloremoji.cpp ('k') | gm/downsamplebitmap.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 2013 Google Inc. 2 * Copyright 2013 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"
9 #include "SkCanvas.h" 11 #include "SkCanvas.h"
10 #include "SkImageDecoder.h" 12 #include "SkImageDecoder.h"
11 #include "SkOSFile.h" 13 #include "SkOSFile.h"
12 14
13 namespace skiagm { 15 namespace skiagm {
14 16
15 /** 17 /**
16 * Test copying an image from 8888 to 4444. 18 * Test copying an image from 8888 to 4444.
17 */ 19 */
18 class CopyTo4444GM : public GM { 20 class CopyTo4444GM : public GM {
19 public: 21 public:
20 CopyTo4444GM() {} 22 CopyTo4444GM() {}
21 23
22 protected: 24 protected:
23 virtual SkString onShortName() { 25 virtual SkString onShortName() {
24 return SkString("copyTo4444"); 26 return SkString("copyTo4444");
25 } 27 }
26 28
27 virtual SkISize onISize() { 29 virtual SkISize onISize() {
28 return SkISize::Make(1024, 512); 30 return SkISize::Make(1024, 512);
29 } 31 }
30 32
31 virtual void onDraw(SkCanvas* canvas) { 33 virtual void onDraw(SkCanvas* canvas) {
32 SkBitmap bm, bm4444; 34 SkBitmap bm, bm4444;
33 SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath, "mand rill_512.png"); 35 SkString resourcePath = GetResourcePath();
36 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill _512.png");
34 if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm, kN32_SkColorType, 37 if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm, kN32_SkColorType,
35 SkImageDecoder::kDecodePixels_Mode)) { 38 SkImageDecoder::kDecodePixels_Mode)) {
36 SkDebugf("Could not decode the file. Did you forget to set the " 39 SkDebugf("Could not decode the file. Did you forget to set the "
37 "resourcePath?\n"); 40 "resourcePath?\n");
38 return; 41 return;
39 } 42 }
40 canvas->drawBitmap(bm, 0, 0); 43 canvas->drawBitmap(bm, 0, 0);
41 SkAssertResult(bm.copyTo(&bm4444, kARGB_4444_SkColorType)); 44 SkAssertResult(bm.copyTo(&bm4444, kARGB_4444_SkColorType));
42 canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0); 45 canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0);
43 } 46 }
44 47
45 private: 48 private:
46 typedef GM INHERITED; 49 typedef GM INHERITED;
47 }; 50 };
48 51
49 ////////////////////////////////////////////////////////////////////////////// 52 //////////////////////////////////////////////////////////////////////////////
50 53
51 static GM* MyFactory(void*) { return new CopyTo4444GM; } 54 static GM* MyFactory(void*) { return new CopyTo4444GM; }
52 static GMRegistry reg(MyFactory); 55 static GMRegistry reg(MyFactory);
53 56
54 } 57 }
OLDNEW
« no previous file with comments | « gm/coloremoji.cpp ('k') | gm/downsamplebitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698