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

Side by Side Diff: gm/nested.cpp

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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/multipicturedraw.cpp ('k') | gm/nonclosedpaths.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 #include "SkRandom.h" 9 #include "SkRandom.h"
10 #include "SkRRect.h" 10 #include "SkRRect.h"
11 11
12 namespace skiagm { 12 namespace skiagm {
13 13
14 // Test out various combinations of nested rects, ovals and rrects. 14 // Test out various combinations of nested rects, ovals and rrects.
15 class NestedGM : public GM { 15 class NestedGM : public GM {
16 public: 16 public:
17 NestedGM(bool doAA) : fDoAA(doAA) { 17 NestedGM(bool doAA) : fDoAA(doAA) {
18 this->setBGColor(0xFFDDDDDD); 18 this->setBGColor(0xFFDDDDDD);
19 } 19 }
20 20
21 protected: 21 protected:
22 virtual uint32_t onGetFlags() const SK_OVERRIDE { 22 uint32_t onGetFlags() const SK_OVERRIDE {
23 return kSkipTiled_Flag; 23 return kSkipTiled_Flag;
24 } 24 }
25 25
26 virtual SkString onShortName() SK_OVERRIDE { 26 SkString onShortName() SK_OVERRIDE {
27 SkString name("nested"); 27 SkString name("nested");
28 if (fDoAA) { 28 if (fDoAA) {
29 name.append("_aa"); 29 name.append("_aa");
30 } else { 30 } else {
31 name.append("_bw"); 31 name.append("_bw");
32 } 32 }
33 return name; 33 return name;
34 } 34 }
35 35
36 virtual SkISize onISize() SK_OVERRIDE { 36 SkISize onISize() SK_OVERRIDE {
37 return SkISize::Make(kImageWidth, kImageHeight); 37 return SkISize::Make(kImageWidth, kImageHeight);
38 } 38 }
39 39
40 enum Shapes { 40 enum Shapes {
41 kRect_Shape = 0, 41 kRect_Shape = 0,
42 kRRect_Shape, 42 kRRect_Shape,
43 kOval_Shape, 43 kOval_Shape,
44 kShapeCount 44 kShapeCount
45 }; 45 };
46 46
47 static void AddShape(SkPath* path, const SkRect& rect, Shapes shape, SkPath: :Direction dir) { 47 static void AddShape(SkPath* path, const SkRect& rect, Shapes shape, SkPath: :Direction dir) {
48 switch (shape) { 48 switch (shape) {
49 case kRect_Shape: 49 case kRect_Shape:
50 path->addRect(rect, dir); 50 path->addRect(rect, dir);
51 break; 51 break;
52 case kRRect_Shape: { 52 case kRRect_Shape: {
53 SkRRect rr; 53 SkRRect rr;
54 rr.setRectXY(rect, 5, 5); 54 rr.setRectXY(rect, 5, 5);
55 path->addRRect(rr, dir); 55 path->addRRect(rr, dir);
56 break; 56 break;
57 } 57 }
58 case kOval_Shape: 58 case kOval_Shape:
59 path->addOval(rect, dir); 59 path->addOval(rect, dir);
60 break; 60 break;
61 default: 61 default:
62 break; 62 break;
63 } 63 }
64 } 64 }
65 65
66 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 66 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
67 67
68 SkPaint shapePaint; 68 SkPaint shapePaint;
69 shapePaint.setColor(SK_ColorBLACK); 69 shapePaint.setColor(SK_ColorBLACK);
70 shapePaint.setAntiAlias(fDoAA); 70 shapePaint.setAntiAlias(fDoAA);
71 71
72 SkRect outerRect = SkRect::MakeWH(40, 40); 72 SkRect outerRect = SkRect::MakeWH(40, 40);
73 73
74 SkRect innerRects[] = { 74 SkRect innerRects[] = {
75 { 10, 10, 30, 30 }, // small 75 { 10, 10, 30, 30 }, // small
76 { .5f, 18, 4.5f, 22 } // smaller and offset to left 76 { .5f, 18, 4.5f, 22 } // smaller and offset to left
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 typedef GM INHERITED; 120 typedef GM INHERITED;
121 }; 121 };
122 122
123 /////////////////////////////////////////////////////////////////////////////// 123 ///////////////////////////////////////////////////////////////////////////////
124 124
125 DEF_GM( return new NestedGM(true); ) 125 DEF_GM( return new NestedGM(true); )
126 DEF_GM( return new NestedGM(false); ) 126 DEF_GM( return new NestedGM(false); )
127 127
128 128
129 } 129 }
OLDNEW
« no previous file with comments | « gm/multipicturedraw.cpp ('k') | gm/nonclosedpaths.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698