OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDraw
Context(); | 51 GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDraw
Context(); |
52 if (!drawContext) { | 52 if (!drawContext) { |
53 skiagm::GM::DrawGpuOnlyMessage(canvas); | 53 skiagm::GM::DrawGpuOnlyMessage(canvas); |
54 return; | 54 return; |
55 } | 55 } |
56 | 56 |
57 SkPaint paint; | 57 SkPaint paint; |
58 | 58 |
59 int y = kPad; | 59 int y = kPad; |
60 int x = kPad; | 60 int x = kPad; |
61 static const GrPrimitiveEdgeType kEdgeTypes[] = { | 61 constexpr GrPrimitiveEdgeType kEdgeTypes[] = { |
62 kFillAA_GrProcessorEdgeType, | 62 kFillAA_GrProcessorEdgeType, |
63 kInverseFillAA_GrProcessorEdgeType, | 63 kInverseFillAA_GrProcessorEdgeType, |
64 }; | 64 }; |
65 SkRect testBounds = SkRect::MakeIWH(fTestWidth, fTestHeight); | 65 SkRect testBounds = SkRect::MakeIWH(fTestWidth, fTestHeight); |
66 for (size_t et = 0; et < SK_ARRAY_COUNT(kEdgeTypes); ++et) { | 66 for (size_t et = 0; et < SK_ARRAY_COUNT(kEdgeTypes); ++et) { |
67 GrPrimitiveEdgeType edgeType = kEdgeTypes[et]; | 67 GrPrimitiveEdgeType edgeType = kEdgeTypes[et]; |
68 canvas->save(); | 68 canvas->save(); |
69 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 69 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
70 | 70 |
71 // Draw a background for the test case | 71 // Draw a background for the test case |
(...skipping 19 matching lines...) Expand all Loading... |
91 nullptr, nullptr
)); | 91 nullptr, nullptr
)); |
92 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint
, batch); | 92 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint
, batch); |
93 } | 93 } |
94 canvas->restore(); | 94 canvas->restore(); |
95 x = x + fTestOffsetX; | 95 x = x + fTestOffsetX; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 private: | 99 private: |
100 // pad between test cases | 100 // pad between test cases |
101 static const int kPad = 7; | 101 static constexpr int kPad = 7; |
102 // gap between rect for each case that is rendered and exterior of rrect | 102 // gap between rect for each case that is rendered and exterior of rrect |
103 static const int kGap = 3; | 103 static constexpr int kGap = 3; |
104 | 104 |
105 SkRRect fRRect; | 105 SkRRect fRRect; |
106 int fWidth; | 106 int fWidth; |
107 int fHeight; | 107 int fHeight; |
108 int fTestWidth; | 108 int fTestWidth; |
109 int fTestHeight; | 109 int fTestHeight; |
110 int fTestOffsetX; | 110 int fTestOffsetX; |
111 int fTestOffsetY; | 111 int fTestOffsetY; |
112 const char* fName; | 112 const char* fName; |
113 typedef GM INHERITED; | 113 typedef GM INHERITED; |
114 }; | 114 }; |
115 | 115 |
116 /////////////////////////////////////////////////////////////////////////////// | 116 /////////////////////////////////////////////////////////////////////////////// |
117 // This value is motivated by bug chromium:477684. It has to be large to cause o
verflow in | 117 // This value is motivated by bug chromium:477684. It has to be large to cause o
verflow in |
118 // the shader | 118 // the shader |
119 static const int kSize = 700; | 119 constexpr int kSize = 700; |
120 | 120 |
121 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRect(SkRect::MakeIWH(kSize,
kSize)), "rect"); ) | 121 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRect(SkRect::MakeIWH(kSize,
kSize)), "rect"); ) |
122 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeOval(SkRect::MakeIWH(kSize,
kSize)), "circle"); ) | 122 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeOval(SkRect::MakeIWH(kSize,
kSize)), "circle"); ) |
123 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeOval(SkRect::MakeIWH(kSize -
1, kSize - 10)), "ellipse"); ) | 123 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeOval(SkRect::MakeIWH(kSize -
1, kSize - 10)), "ellipse"); ) |
124 // The next two have small linear segments between the corners | 124 // The next two have small linear segments between the corners |
125 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRectXY(SkRect::MakeIWH(kSize
- 1, kSize - 10), kSize/2.f - 10.f, kSize/2.f - 10.f), "circular_corner"); ) | 125 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRectXY(SkRect::MakeIWH(kSize
- 1, kSize - 10), kSize/2.f - 10.f, kSize/2.f - 10.f), "circular_corner"); ) |
126 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRectXY(SkRect::MakeIWH(kSize
- 1, kSize - 10), kSize/2.f - 10.f, kSize/2.f - 15.f), "elliptical_corner"); ) | 126 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRectXY(SkRect::MakeIWH(kSize
- 1, kSize - 10), kSize/2.f - 10.f, kSize/2.f - 15.f), "elliptical_corner"); ) |
127 | 127 |
128 } | 128 } |
129 #endif | 129 #endif |
OLD | NEW |