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 "GrNonAAFillRectBatch.h" | 8 #include "GrNonAAFillRectBatch.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 public: | 117 public: |
118 struct Geometry { | 118 struct Geometry { |
119 SkMatrix fViewMatrix; | 119 SkMatrix fViewMatrix; |
120 SkRect fRect; | 120 SkRect fRect; |
121 GrQuad fLocalQuad; | 121 GrQuad fLocalQuad; |
122 GrColor fColor; | 122 GrColor fColor; |
123 }; | 123 }; |
124 | 124 |
125 static const char* Name() { return "NonAAFillRectBatch"; } | 125 static const char* Name() { return "NonAAFillRectBatch"; } |
126 | 126 |
127 static SkString DumpInfo(const Geometry& geo) { | 127 static SkString DumpInfo(const Geometry& geo, int index) { |
128 SkString str; | 128 SkString str; |
129 str.appendf("Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n"
, | 129 str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f
]\n", |
| 130 index, |
130 geo.fColor, | 131 geo.fColor, |
131 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect
.fBottom); | 132 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect
.fBottom); |
132 return str; | 133 return str; |
133 } | 134 } |
134 | 135 |
135 static bool CanCombine(const Geometry& mine, const Geometry& theirs, | 136 static bool CanCombine(const Geometry& mine, const Geometry& theirs, |
136 const GrPipelineOptimizations& opts) { | 137 const GrPipelineOptimizations& opts) { |
137 return true; | 138 return true; |
138 } | 139 } |
139 | 140 |
(...skipping 21 matching lines...) Expand all Loading... |
161 SkMatrix fLocalMatrix; | 162 SkMatrix fLocalMatrix; |
162 SkRect fRect; | 163 SkRect fRect; |
163 SkRect fLocalRect; | 164 SkRect fLocalRect; |
164 GrColor fColor; | 165 GrColor fColor; |
165 bool fHasLocalMatrix; | 166 bool fHasLocalMatrix; |
166 bool fHasLocalRect; | 167 bool fHasLocalRect; |
167 }; | 168 }; |
168 | 169 |
169 static const char* Name() { return "NonAAFillRectBatchPerspective"; } | 170 static const char* Name() { return "NonAAFillRectBatchPerspective"; } |
170 | 171 |
171 static SkString DumpInfo(const Geometry& geo) { | 172 static SkString DumpInfo(const Geometry& geo, int index) { |
172 SkString str; | 173 SkString str; |
173 str.appendf("Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n"
, | 174 str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f
]\n", |
| 175 index, |
174 geo.fColor, | 176 geo.fColor, |
175 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect
.fBottom); | 177 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect
.fBottom); |
176 return str; | 178 return str; |
177 } | 179 } |
178 | 180 |
179 static bool CanCombine(const Geometry& mine, const Geometry& theirs, | 181 static bool CanCombine(const Geometry& mine, const Geometry& theirs, |
180 const GrPipelineOptimizations& opts) { | 182 const GrPipelineOptimizations& opts) { |
181 // We could batch across perspective vm changes if we really wanted to | 183 // We could batch across perspective vm changes if we really wanted to |
182 return mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix) && | 184 return mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix) && |
183 mine.fHasLocalRect == theirs.fHasLocalRect && | 185 mine.fHasLocalRect == theirs.fHasLocalRect && |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 SkMatrix localMatrix = GrTest::TestMatrix(random); | 329 SkMatrix localMatrix = GrTest::TestMatrix(random); |
328 | 330 |
329 bool hasLocalRect = random->nextBool(); | 331 bool hasLocalRect = random->nextBool(); |
330 bool hasLocalMatrix = random->nextBool(); | 332 bool hasLocalMatrix = random->nextBool(); |
331 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, | 333 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, |
332 hasLocalRect ? &localRect : nullptr, | 334 hasLocalRect ? &localRect : nullptr, |
333 hasLocalMatrix ? &localMatrix : nullptr)
; | 335 hasLocalMatrix ? &localMatrix : nullptr)
; |
334 } | 336 } |
335 | 337 |
336 #endif | 338 #endif |
OLD | NEW |