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

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

Issue 1292543002: Minor fix to not save the modeling space rect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | no next file » | 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 "GrAAFillRectBatch.h" 8 #include "GrAAFillRectBatch.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 { args.fViewMatrix[SkMatrix::kMScaleX], args.fViewMatrix[SkMatrix: :kMSkewY] }, 213 { args.fViewMatrix[SkMatrix::kMScaleX], args.fViewMatrix[SkMatrix: :kMSkewY] },
214 { args.fViewMatrix[SkMatrix::kMSkewX], args.fViewMatrix[SkMatrix: :kMScaleY] } 214 { args.fViewMatrix[SkMatrix::kMSkewX], args.fViewMatrix[SkMatrix: :kMScaleY] }
215 }; 215 };
216 216
217 vec[0].normalize(); 217 vec[0].normalize();
218 vec[0].scale(SK_ScalarHalf); 218 vec[0].scale(SK_ScalarHalf);
219 vec[1].normalize(); 219 vec[1].normalize();
220 vec[1].scale(SK_ScalarHalf); 220 vec[1].scale(SK_ScalarHalf);
221 221
222 // create the rotated rect 222 // create the rotated rect
223 fan0Pos->setRectFan(args.fRect.fLeft, args.fRect.fTop, 223 fan0Pos->setRectFan(args.fDevRect.fLeft, args.fDevRect.fTop,
224 args.fRect.fRight, args.fRect.fBottom, vertexStr ide); 224 args.fDevRect.fRight, args.fDevRect.fBottom, ver texStride);
225 args.fViewMatrix.mapPointsWithStride(fan0Pos, vertexStride, 4);
226 225
227 // Now create the inset points and then outset the original 226 // Now create the inset points and then outset the original
228 // rotated points 227 // rotated points
229 228
230 // TL 229 // TL
231 *((SkPoint*)((intptr_t)fan1Pos + 0 * vertexStride)) = 230 *((SkPoint*)((intptr_t)fan1Pos + 0 * vertexStride)) =
232 *((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) + vec[0] + v ec[1]; 231 *((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) + vec[0] + v ec[1];
233 *((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) -= vec[0] + vec[ 1]; 232 *((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) -= vec[0] + vec[ 1];
234 // BL 233 // BL
235 *((SkPoint*)((intptr_t)fan1Pos + 1 * vertexStride)) = 234 *((SkPoint*)((intptr_t)fan1Pos + 1 * vertexStride)) =
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 }; 321 };
323 322
324 BatchTracker fBatch; 323 BatchTracker fBatch;
325 SkSTArray<1, Geometry, true> fGeoData; 324 SkSTArray<1, Geometry, true> fGeoData;
326 }; 325 };
327 326
328 class AAFillRectBatchNoLocalMatrixImp { 327 class AAFillRectBatchNoLocalMatrixImp {
329 public: 328 public:
330 struct Geometry { 329 struct Geometry {
331 SkMatrix fViewMatrix; 330 SkMatrix fViewMatrix;
332 SkRect fRect;
333 SkRect fDevRect; 331 SkRect fDevRect;
334 GrColor fColor; 332 GrColor fColor;
335 }; 333 };
336 334
337 inline static bool CanCombineLocalCoords(const SkMatrix& mine, const SkMatri x& theirs, 335 inline static bool CanCombineLocalCoords(const SkMatrix& mine, const SkMatri x& theirs,
338 bool usesLocalCoords) { 336 bool usesLocalCoords) {
339 // We apply the viewmatrix to the rect points on the cpu. However, if t he pipeline uses 337 // We apply the viewmatrix to the rect points on the cpu. However, if t he pipeline uses
340 // local coords then we won't be able to batch. We could actually uploa d the viewmatrix 338 // local coords then we won't be able to batch. We could actually uploa d the viewmatrix
341 // using vertex attributes in these cases, but haven't investigated that 339 // using vertex attributes in these cases, but haven't investigated that
342 return !usesLocalCoords || mine.cheapEqualTo(theirs); 340 return !usesLocalCoords || mine.cheapEqualTo(theirs);
(...skipping 11 matching lines...) Expand all
354 } 352 }
355 353
356 inline static void FillInAttributes(intptr_t, size_t, SkPoint*, const Geomet ry&) {} 354 inline static void FillInAttributes(intptr_t, size_t, SkPoint*, const Geomet ry&) {}
357 }; 355 };
358 356
359 class AAFillRectBatchLocalMatrixImp { 357 class AAFillRectBatchLocalMatrixImp {
360 public: 358 public:
361 struct Geometry { 359 struct Geometry {
362 SkMatrix fViewMatrix; 360 SkMatrix fViewMatrix;
363 SkMatrix fLocalMatrix; 361 SkMatrix fLocalMatrix;
364 SkRect fRect;
365 SkRect fDevRect; 362 SkRect fDevRect;
366 GrColor fColor; 363 GrColor fColor;
367 }; 364 };
368 365
369 inline static bool CanCombineLocalCoords(const SkMatrix& mine, const SkMatri x& theirs, 366 inline static bool CanCombineLocalCoords(const SkMatrix& mine, const SkMatri x& theirs,
370 bool usesLocalCoords) { 367 bool usesLocalCoords) {
371 return true; 368 return true;
372 } 369 }
373 370
374 inline static GrDefaultGeoProcFactory::LocalCoords::Type LocalCoordsType() { 371 inline static GrDefaultGeoProcFactory::LocalCoords::Type LocalCoordsType() {
(...skipping 28 matching lines...) Expand all
403 namespace GrAAFillRectBatch { 400 namespace GrAAFillRectBatch {
404 401
405 GrBatch* Create(GrColor color, 402 GrBatch* Create(GrColor color,
406 const SkMatrix& viewMatrix, 403 const SkMatrix& viewMatrix,
407 const SkRect& rect, 404 const SkRect& rect,
408 const SkRect& devRect) { 405 const SkRect& devRect) {
409 AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create() ; 406 AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create() ;
410 AAFillRectBatchNoLocalMatrix::Geometry& geo = *batch->geometry(); 407 AAFillRectBatchNoLocalMatrix::Geometry& geo = *batch->geometry();
411 geo.fColor = color; 408 geo.fColor = color;
412 geo.fViewMatrix = viewMatrix; 409 geo.fViewMatrix = viewMatrix;
413 geo.fRect = rect;
414 geo.fDevRect = devRect; 410 geo.fDevRect = devRect;
415 batch->init(); 411 batch->init();
416 return batch; 412 return batch;
417 } 413 }
418 414
419 GrBatch* Create(GrColor color, 415 GrBatch* Create(GrColor color,
420 const SkMatrix& viewMatrix, 416 const SkMatrix& viewMatrix,
421 const SkMatrix& localMatrix, 417 const SkMatrix& localMatrix,
422 const SkRect& rect, 418 const SkRect& rect,
423 const SkRect& devRect) { 419 const SkRect& devRect) {
424 AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create(); 420 AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create();
425 AAFillRectBatchLocalMatrix::Geometry& geo = *batch->geometry(); 421 AAFillRectBatchLocalMatrix::Geometry& geo = *batch->geometry();
426 geo.fColor = color; 422 geo.fColor = color;
427 geo.fViewMatrix = viewMatrix; 423 geo.fViewMatrix = viewMatrix;
428 geo.fLocalMatrix = localMatrix; 424 geo.fLocalMatrix = localMatrix;
429 geo.fRect = rect;
430 geo.fDevRect = devRect; 425 geo.fDevRect = devRect;
431 batch->init(); 426 batch->init();
432 return batch; 427 return batch;
433 } 428 }
434 429
435 }; 430 };
436 431
437 //////////////////////////////////////////////////////////////////////////////// /////////////////// 432 //////////////////////////////////////////////////////////////////////////////// ///////////////////
438 433
439 #ifdef GR_TEST_UTILS 434 #ifdef GR_TEST_UTILS
440 435
441 #include "GrBatchTest.h" 436 #include "GrBatchTest.h"
442 437
443 BATCH_TEST_DEFINE(AAFillRectBatch) { 438 BATCH_TEST_DEFINE(AAFillRectBatch) {
444 AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create() ; 439 AAFillRectBatchNoLocalMatrix* batch = AAFillRectBatchNoLocalMatrix::Create() ;
445 AAFillRectBatchNoLocalMatrix::Geometry& geo = *batch->geometry(); 440 AAFillRectBatchNoLocalMatrix::Geometry& geo = *batch->geometry();
446 geo.fColor = GrRandomColor(random); 441 geo.fColor = GrRandomColor(random);
447 geo.fViewMatrix = GrTest::TestMatrix(random); 442 geo.fViewMatrix = GrTest::TestMatrix(random);
448 geo.fRect = GrTest::TestRect(random);
449 geo.fDevRect = GrTest::TestRect(random); 443 geo.fDevRect = GrTest::TestRect(random);
450 batch->init(); 444 batch->init();
451 return batch; 445 return batch;
452 } 446 }
453 447
454 BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { 448 BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
455 AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create(); 449 AAFillRectBatchLocalMatrix* batch = AAFillRectBatchLocalMatrix::Create();
456 AAFillRectBatchLocalMatrix::Geometry& geo = *batch->geometry(); 450 AAFillRectBatchLocalMatrix::Geometry& geo = *batch->geometry();
457 geo.fColor = GrRandomColor(random); 451 geo.fColor = GrRandomColor(random);
458 geo.fViewMatrix = GrTest::TestMatrix(random); 452 geo.fViewMatrix = GrTest::TestMatrix(random);
459 geo.fLocalMatrix = GrTest::TestMatrix(random); 453 geo.fLocalMatrix = GrTest::TestMatrix(random);
460 geo.fRect = GrTest::TestRect(random);
461 geo.fDevRect = GrTest::TestRect(random); 454 geo.fDevRect = GrTest::TestRect(random);
462 batch->init(); 455 batch->init();
463 return batch; 456 return batch;
464 } 457 }
465 458
466 #endif 459 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698