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

Side by Side Diff: gm/texdata.cpp

Issue 73643005: Implement a benchmark for GrResourceCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 // This test only works with the GPU backend. 9 // This test only works with the GPU backend.
10 10
11 #include "gm.h" 11 #include "gm.h"
12 12
13 #if SK_SUPPORT_GPU 13 #if SK_SUPPORT_GPU
14 #include "GrContext.h" 14 #include "GrContext.h"
15 #include "GrUtils.h"
15 #include "effects/GrSimpleTextureEffect.h" 16 #include "effects/GrSimpleTextureEffect.h"
16 #include "SkColorPriv.h" 17 #include "SkColorPriv.h"
17 #include "SkDevice.h" 18 #include "SkDevice.h"
18 19
19 namespace skiagm { 20 namespace skiagm {
20 21
21 static const int S = 200; 22 static const int S = 200;
22 23
23 class TexDataGM : public GM { 24 class TexDataGM : public GM {
24 public: 25 public:
25 TexDataGM() { 26 TexDataGM() {
26 this->setBGColor(0xff000000); 27 this->setBGColor(0xff000000);
27 } 28 }
28 29
29 protected: 30 protected:
30 virtual SkString onShortName() { 31 virtual SkString onShortName() {
31 return SkString("texdata"); 32 return SkString("texdata");
32 } 33 }
33 34
34 virtual SkISize onISize() { 35 virtual SkISize onISize() {
35 return make_isize(2*S, 2*S); 36 return make_isize(2*S, 2*S);
36 } 37 }
37 38
38 virtual uint32_t onGetFlags() const SK_OVERRIDE { return kGPUOnly_Flag; } 39 virtual uint32_t onGetFlags() const SK_OVERRIDE { return kGPUOnly_Flag; }
39 40
40 virtual void onDraw(SkCanvas* canvas) { 41 virtual void onDraw(SkCanvas* canvas) {
41 SkBaseDevice* device = canvas->getTopDevice(); 42 SkBaseDevice* device = canvas->getTopDevice();
42 GrRenderTarget* target = device->accessRenderTarget(); 43 GrRenderTarget* target = device->accessRenderTarget();
43 GrContext* ctx = GM::GetGr(canvas); 44 GrContext* ctx = GrUtils::GetGr(canvas);
44 if (ctx && target) { 45 if (ctx && target) {
45 SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S)); 46 SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S));
46 static const int stride = 2 * S; 47 static const int stride = 2 * S;
47 static const SkPMColor gray = SkPackARGB32(0x40, 0x40, 0x40, 0x40); 48 static const SkPMColor gray = SkPackARGB32(0x40, 0x40, 0x40, 0x40);
48 static const SkPMColor white = SkPackARGB32(0xff, 0xff, 0xff, 0xff); 49 static const SkPMColor white = SkPackARGB32(0xff, 0xff, 0xff, 0xff);
49 static const SkPMColor red = SkPackARGB32(0x80, 0x80, 0x00, 0x00); 50 static const SkPMColor red = SkPackARGB32(0x80, 0x80, 0x00, 0x00);
50 static const SkPMColor blue = SkPackARGB32(0x80, 0x00, 0x00, 0x80); 51 static const SkPMColor blue = SkPackARGB32(0x80, 0x00, 0x00, 0x80);
51 static const SkPMColor green = SkPackARGB32(0x80, 0x00, 0x80, 0x00); 52 static const SkPMColor green = SkPackARGB32(0x80, 0x00, 0x80, 0x00);
52 static const SkPMColor black = SkPackARGB32(0x00, 0x00, 0x00, 0x00); 53 static const SkPMColor black = SkPackARGB32(0x00, 0x00, 0x00, 0x00);
53 for (int i = 0; i < 2; ++i) { 54 for (int i = 0; i < 2; ++i) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 }; 140 };
140 141
141 ////////////////////////////////////////////////////////////////////////////// 142 //////////////////////////////////////////////////////////////////////////////
142 143
143 static GM* MyFactory(void*) { return new TexDataGM; } 144 static GM* MyFactory(void*) { return new TexDataGM; }
144 static GMRegistry reg(MyFactory); 145 static GMRegistry reg(MyFactory);
145 146
146 } 147 }
147 148
148 #endif 149 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698