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

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

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