| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkRRect.h" | 9 #include "SkRRect.h" |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 void setUpRRects() { | 69 void setUpRRects() { |
| 70 // each RRect must fit in a 0x0 -> (kTileX-2)x(kTileY-2) block. These wi
ll be tiled across | 70 // each RRect must fit in a 0x0 -> (kTileX-2)x(kTileY-2) block. These wi
ll be tiled across |
| 71 // the screen in kTileX x kTileY tiles. The extra empty pixels on each s
ide are for AA. | 71 // the screen in kTileX x kTileY tiles. The extra empty pixels on each s
ide are for AA. |
| 72 | 72 |
| 73 // simple cases | 73 // simple cases |
| 74 fRRects[0].setRect(SkRect::MakeWH(kTileX-2, kTileY-2)); | 74 fRRects[0].setRect(SkRect::MakeWH(kTileX-2, kTileY-2)); |
| 75 fRRects[1].setOval(SkRect::MakeWH(kTileX-2, kTileY-2)); | 75 fRRects[1].setOval(SkRect::MakeWH(kTileX-2, kTileY-2)); |
| 76 fRRects[2].setRectXY(SkRect::MakeWH(kTileX-2, kTileY-2), 10, 10); | 76 fRRects[2].setRectXY(SkRect::MakeWH(kTileX-2, kTileY-2), 10, 10); |
| 77 fRRects[3].setRectXY(SkRect::MakeWH(kTileX-2, kTileY-2), 10, 5); |
| 78 // small circular corners are an interesting test case for gpu clipping |
| 79 fRRects[4].setRectXY(SkRect::MakeWH(kTileX-2, kTileY-2), 1, 1); |
| 80 fRRects[5].setRectXY(SkRect::MakeWH(kTileX-2, kTileY-2), 0.5f, 0.5f); |
| 81 fRRects[6].setRectXY(SkRect::MakeWH(kTileX-2, kTileY-2), 0.2f, 0.2f); |
| 77 | 82 |
| 78 // The first complex case needs special handling since it is a square | 83 // The first complex case needs special handling since it is a square |
| 79 fRRects[kNumSimpleCases].setRectRadii(SkRect::MakeWH(kTileY-2, kTileY-2)
, gRadii[0]); | 84 fRRects[kNumSimpleCases].setRectRadii(SkRect::MakeWH(kTileY-2, kTileY-2)
, gRadii[0]); |
| 80 for (size_t i = 1; i < SK_ARRAY_COUNT(gRadii); ++i) { | 85 for (size_t i = 1; i < SK_ARRAY_COUNT(gRadii); ++i) { |
| 81 fRRects[kNumSimpleCases+i].setRectRadii(SkRect::MakeWH(kTileX-2, kTi
leY-2), gRadii[i]); | 86 fRRects[kNumSimpleCases+i].setRectRadii(SkRect::MakeWH(kTileX-2, kTi
leY-2), gRadii[i]); |
| 82 } | 87 } |
| 83 } | 88 } |
| 84 | 89 |
| 85 private: | 90 private: |
| 86 bool fDoAA; | 91 bool fDoAA; |
| 87 bool fDoClip; // use clipRRect & drawRect instead of drawRRect | 92 bool fDoClip; // use clipRRect & drawRect instead of drawRRect |
| 88 | 93 |
| 89 static const int kImageWidth = 640; | 94 static const int kImageWidth = 640; |
| 90 static const int kImageHeight = 480; | 95 static const int kImageHeight = 480; |
| 91 | 96 |
| 92 static const int kTileX = 80; | 97 static const int kTileX = 80; |
| 93 static const int kTileY = 40; | 98 static const int kTileY = 40; |
| 94 | 99 |
| 95 static const int kNumSimpleCases = 3; | 100 static const int kNumSimpleCases = 7; |
| 96 static const int kNumComplexCases = 19; | 101 static const int kNumComplexCases = 19; |
| 97 static const SkVector gRadii[kNumComplexCases][4]; | 102 static const SkVector gRadii[kNumComplexCases][4]; |
| 98 | 103 |
| 99 static const int kNumRRects = kNumSimpleCases + kNumComplexCases; | 104 static const int kNumRRects = kNumSimpleCases + kNumComplexCases; |
| 100 SkRRect fRRects[kNumRRects]; | 105 SkRRect fRRects[kNumRRects]; |
| 101 | 106 |
| 102 typedef GM INHERITED; | 107 typedef GM INHERITED; |
| 103 }; | 108 }; |
| 104 | 109 |
| 105 // Radii for the various test cases. Order is UL, UR, LR, LL | 110 // Radii for the various test cases. Order is UL, UR, LR, LL |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 }; | 144 }; |
| 140 | 145 |
| 141 /////////////////////////////////////////////////////////////////////////////// | 146 /////////////////////////////////////////////////////////////////////////////// |
| 142 | 147 |
| 143 DEF_GM( return new RRectGM(false, false); ) | 148 DEF_GM( return new RRectGM(false, false); ) |
| 144 DEF_GM( return new RRectGM(true, false); ) | 149 DEF_GM( return new RRectGM(true, false); ) |
| 145 DEF_GM( return new RRectGM(false, true); ) | 150 DEF_GM( return new RRectGM(false, true); ) |
| 146 DEF_GM( return new RRectGM(true, true); ) | 151 DEF_GM( return new RRectGM(true, true); ) |
| 147 | 152 |
| 148 } | 153 } |
| OLD | NEW |