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

Side by Side Diff: src/gpu/batches/GrNonAAFillRectBatch.cpp

Issue 1353683003: Move StrokeRectBatches into .cpp files (Closed) Base URL: https://skia.googlesource.com/skia.git@statics
Patch Set: tweaks Created 5 years, 3 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 | « src/gpu/batches/GrNonAAFillRectBatch.h ('k') | src/gpu/batches/GrNonAAStrokeRectBatch.h » ('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 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } else { 181 } else {
182 tesselate(vertices, vertexStride, geo.fColor, geo.fViewMatrix, geo.f Rect, nullptr); 182 tesselate(vertices, vertexStride, geo.fColor, geo.fViewMatrix, geo.f Rect, nullptr);
183 } 183 }
184 } 184 }
185 }; 185 };
186 186
187 typedef GrTInstanceBatch<NonAAFillRectBatchImp> NonAAFillRectBatchSimple; 187 typedef GrTInstanceBatch<NonAAFillRectBatchImp> NonAAFillRectBatchSimple;
188 typedef GrTInstanceBatch<NonAAFillRectBatchPerspectiveImp> NonAAFillRectBatchPer spective; 188 typedef GrTInstanceBatch<NonAAFillRectBatchPerspectiveImp> NonAAFillRectBatchPer spective;
189 189
190 namespace GrNonAAFillRectBatch { 190 namespace GrNonAAFillRectBatch {
191
191 GrDrawBatch* Create(GrColor color, 192 GrDrawBatch* Create(GrColor color,
192 const SkMatrix& viewMatrix, 193 const SkMatrix& viewMatrix,
193 const SkRect& rect, 194 const SkRect& rect,
194 const SkRect* localRect, 195 const SkRect* localRect,
195 const SkMatrix* localMatrix) { 196 const SkMatrix* localMatrix) {
197 SkASSERT(!viewMatrix.hasPerspective() && (!localMatrix || !localMatrix->hasP erspective()));
198 NonAAFillRectBatchSimple* batch = NonAAFillRectBatchSimple::Create();
199 NonAAFillRectBatchSimple::Geometry& geo = *batch->geometry();
196 200
197 /* Perspective has to be handled in a slow path for now */ 201 geo.fColor = color;
198 if (viewMatrix.hasPerspective() || (localMatrix && localMatrix->hasPerspecti ve())) { 202 geo.fViewMatrix = viewMatrix;
199 NonAAFillRectBatchPerspective* batch = NonAAFillRectBatchPerspective::Cr eate(); 203 geo.fRect = rect;
200 NonAAFillRectBatchPerspective::Geometry& geo = *batch->geometry();
201 204
202 geo.fColor = color; 205 if (localRect && localMatrix) {
203 geo.fViewMatrix = viewMatrix; 206 geo.fLocalQuad.setFromMappedRect(*localRect, *localMatrix);
204 geo.fRect = rect; 207 } else if (localRect) {
205 geo.fHasLocalRect = SkToBool(localRect); 208 geo.fLocalQuad.set(*localRect);
206 geo.fHasLocalMatrix = SkToBool(localMatrix); 209 } else if (localMatrix) {
207 if (localMatrix) { 210 geo.fLocalQuad.setFromMappedRect(rect, *localMatrix);
208 geo.fLocalMatrix = *localMatrix; 211 } else {
209 } 212 geo.fLocalQuad.set(rect);
210 if (localRect) { 213 }
211 geo.fLocalRect = *localRect;
212 }
213 214
214 batch->init(); 215 batch->init();
215 return batch; 216 return batch;
216 } else { 217 }
217 // TODO bubble these up as separate calls
218 NonAAFillRectBatchSimple* batch = NonAAFillRectBatchSimple::Create();
219 NonAAFillRectBatchSimple::Geometry& geo = *batch->geometry();
220 218
221 geo.fColor = color; 219 GrDrawBatch* CreateWithPerspective(GrColor color,
222 geo.fViewMatrix = viewMatrix; 220 const SkMatrix& viewMatrix,
223 geo.fRect = rect; 221 const SkRect& rect,
222 const SkRect* localRect,
223 const SkMatrix* localMatrix) {
224 SkASSERT(viewMatrix.hasPerspective() || (localMatrix && localMatrix->hasPers pective()));
225 NonAAFillRectBatchPerspective* batch = NonAAFillRectBatchPerspective::Create ();
226 NonAAFillRectBatchPerspective::Geometry& geo = *batch->geometry();
224 227
225 if (localRect && localMatrix) { 228 geo.fColor = color;
226 geo.fLocalQuad.setFromMappedRect(*localRect, *localMatrix); 229 geo.fViewMatrix = viewMatrix;
227 } else if (localRect) { 230 geo.fRect = rect;
228 geo.fLocalQuad.set(*localRect); 231 geo.fHasLocalRect = SkToBool(localRect);
229 } else if (localMatrix) { 232 geo.fHasLocalMatrix = SkToBool(localMatrix);
230 geo.fLocalQuad.setFromMappedRect(rect, *localMatrix); 233 if (localMatrix) {
231 } else { 234 geo.fLocalMatrix = *localMatrix;
232 geo.fLocalQuad.set(rect); 235 }
233 } 236 if (localRect) {
237 geo.fLocalRect = *localRect;
238 }
234 239
235 batch->init(); 240 batch->init();
236 return batch; 241 return batch;
237 }
238 } 242 }
243
239 }; 244 };
240 245
241 //////////////////////////////////////////////////////////////////////////////// /////////////////// 246 //////////////////////////////////////////////////////////////////////////////// ///////////////////
242 247
243 #ifdef GR_TEST_UTILS 248 #ifdef GR_TEST_UTILS
244 249
245 #include "GrBatchTest.h" 250 #include "GrBatchTest.h"
246 251
247 DRAW_BATCH_TEST_DEFINE(RectBatch) { 252 DRAW_BATCH_TEST_DEFINE(RectBatch) {
248 GrColor color = GrRandomColor(random); 253 GrColor color = GrRandomColor(random);
249 SkRect rect = GrTest::TestRect(random); 254 SkRect rect = GrTest::TestRect(random);
250 SkRect localRect = GrTest::TestRect(random); 255 SkRect localRect = GrTest::TestRect(random);
251 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 256 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
252 SkMatrix localMatrix = GrTest::TestMatrix(random); 257 SkMatrix localMatrix = GrTest::TestMatrix(random);
253 258
254 bool hasLocalRect = random->nextBool(); 259 bool hasLocalRect = random->nextBool();
255 bool hasLocalMatrix = random->nextBool(); 260 bool hasLocalMatrix = random->nextBool();
256 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, 261 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect,
257 hasLocalRect ? &localRect : nullptr, 262 hasLocalRect ? &localRect : nullptr,
258 hasLocalMatrix ? &localMatrix : nullptr) ; 263 hasLocalMatrix ? &localMatrix : nullptr) ;
259 } 264 }
260 265
261 #endif 266 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrNonAAFillRectBatch.h ('k') | src/gpu/batches/GrNonAAStrokeRectBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698