| 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 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 if (kEffect_Type == fType && !drawContext) { | 66 if (kEffect_Type == fType && !drawContext) { |
| 67 skiagm::GM::DrawGpuOnlyMessage(canvas); | 67 skiagm::GM::DrawGpuOnlyMessage(canvas); |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 | 70 |
| 71 SkPaint paint; | 71 SkPaint paint; |
| 72 if (kAA_Draw_Type == fType) { | 72 if (kAA_Draw_Type == fType) { |
| 73 paint.setAntiAlias(true); | 73 paint.setAntiAlias(true); |
| 74 } | 74 } |
| 75 | 75 |
| 76 static const SkRect kMaxTileBound = SkRect::MakeWH(SkIntToScalar(kTileX)
, | 76 const SkRect kMaxTileBound = SkRect::MakeWH(SkIntToScalar(kTileX), |
| 77 SkIntToScalar(kTileY)
); | 77 SkIntToScalar(kTileY)); |
| 78 #ifdef SK_DEBUG | 78 #ifdef SK_DEBUG |
| 79 static const SkRect kMaxImageBound = SkRect::MakeWH(SkIntToScalar(kImage
Width), | 79 const SkRect kMaxImageBound = SkRect::MakeWH(SkIntToScalar(kImageWidth), |
| 80 SkIntToScalar(kImage
Height)); | 80 SkIntToScalar(kImageHeight)
); |
| 81 #endif | 81 #endif |
| 82 | 82 |
| 83 #if SK_SUPPORT_GPU | 83 #if SK_SUPPORT_GPU |
| 84 int lastEdgeType = (kEffect_Type == fType) ? kLast_GrProcessorEdgeType:
0; | 84 int lastEdgeType = (kEffect_Type == fType) ? kLast_GrProcessorEdgeType:
0; |
| 85 #else | 85 #else |
| 86 int lastEdgeType = 0; | 86 int lastEdgeType = 0; |
| 87 #endif | 87 #endif |
| 88 | 88 |
| 89 int y = 1; | 89 int y = 1; |
| 90 for (int et = 0; et <= lastEdgeType; ++et) { | 90 for (int et = 0; et <= lastEdgeType; ++et) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // The first complex case needs special handling since it is a square | 161 // The first complex case needs special handling since it is a square |
| 162 fRRects[kNumSimpleCases].setRectRadii(SkRect::MakeWH(kTileY-2, kTileY-2)
, gRadii[0]); | 162 fRRects[kNumSimpleCases].setRectRadii(SkRect::MakeWH(kTileY-2, kTileY-2)
, gRadii[0]); |
| 163 for (size_t i = 1; i < SK_ARRAY_COUNT(gRadii); ++i) { | 163 for (size_t i = 1; i < SK_ARRAY_COUNT(gRadii); ++i) { |
| 164 fRRects[kNumSimpleCases+i].setRectRadii(SkRect::MakeWH(kTileX-2, kTi
leY-2), gRadii[i]); | 164 fRRects[kNumSimpleCases+i].setRectRadii(SkRect::MakeWH(kTileX-2, kTi
leY-2), gRadii[i]); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 Type fType; | 169 Type fType; |
| 170 | 170 |
| 171 static const int kImageWidth = 640; | 171 static constexpr int kImageWidth = 640; |
| 172 static const int kImageHeight = 480; | 172 static constexpr int kImageHeight = 480; |
| 173 | 173 |
| 174 static const int kTileX = 80; | 174 static constexpr int kTileX = 80; |
| 175 static const int kTileY = 40; | 175 static constexpr int kTileY = 40; |
| 176 | 176 |
| 177 static const int kNumSimpleCases = 7; | 177 static constexpr int kNumSimpleCases = 7; |
| 178 static const int kNumComplexCases = 35; | 178 static constexpr int kNumComplexCases = 35; |
| 179 static const SkVector gRadii[kNumComplexCases][4]; | 179 static const SkVector gRadii[kNumComplexCases][4]; |
| 180 | 180 |
| 181 static const int kNumRRects = kNumSimpleCases + kNumComplexCases; | 181 static constexpr int kNumRRects = kNumSimpleCases + kNumComplexCases; |
| 182 SkRRect fRRects[kNumRRects]; | 182 SkRRect fRRects[kNumRRects]; |
| 183 | 183 |
| 184 typedef GM INHERITED; | 184 typedef GM INHERITED; |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 // Radii for the various test cases. Order is UL, UR, LR, LL | 187 // Radii for the various test cases. Order is UL, UR, LR, LL |
| 188 const SkVector RRectGM::gRadii[kNumComplexCases][4] = { | 188 const SkVector RRectGM::gRadii[kNumComplexCases][4] = { |
| 189 // a circle | 189 // a circle |
| 190 { { kTileY, kTileY }, { kTileY, kTileY }, { kTileY, kTileY }, { kTileY, kTil
eY } }, | 190 { { kTileY, kTileY }, { kTileY, kTileY }, { kTileY, kTileY }, { kTileY, kTil
eY } }, |
| 191 | 191 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 DEF_GM( return new RRectGM(RRectGM::kAA_Draw_Type); ) | 252 DEF_GM( return new RRectGM(RRectGM::kAA_Draw_Type); ) |
| 253 DEF_GM( return new RRectGM(RRectGM::kBW_Draw_Type); ) | 253 DEF_GM( return new RRectGM(RRectGM::kBW_Draw_Type); ) |
| 254 DEF_GM( return new RRectGM(RRectGM::kAA_Clip_Type); ) | 254 DEF_GM( return new RRectGM(RRectGM::kAA_Clip_Type); ) |
| 255 DEF_GM( return new RRectGM(RRectGM::kBW_Clip_Type); ) | 255 DEF_GM( return new RRectGM(RRectGM::kBW_Clip_Type); ) |
| 256 #if SK_SUPPORT_GPU | 256 #if SK_SUPPORT_GPU |
| 257 DEF_GM( return new RRectGM(RRectGM::kEffect_Type); ) | 257 DEF_GM( return new RRectGM(RRectGM::kEffect_Type); ) |
| 258 #endif | 258 #endif |
| 259 | 259 |
| 260 } | 260 } |
| OLD | NEW |