OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrAARectRenderer.h" | 8 #include "GrAARectRenderer.h" |
9 #include "GrRefCnt.h" | 9 #include "GrRefCnt.h" |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 return; | 381 return; |
382 } | 382 } |
383 | 383 |
384 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices()); | 384 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices()); |
385 size_t vsize = drawState->getVertexSize(); | 385 size_t vsize = drawState->getVertexSize(); |
386 GrAssert(sizeof(GrPoint) + sizeof(GrColor) == vsize); | 386 GrAssert(sizeof(GrPoint) + sizeof(GrColor) == vsize); |
387 | 387 |
388 GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts); | 388 GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts); |
389 GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize); | 389 GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize); |
390 | 390 |
391 SkRect devRect; | 391 if (combinedMatrix.rectStaysRect()) { |
392 combinedMatrix.mapRect(&devRect, rect); | 392 SkRect devRect; |
| 393 combinedMatrix.mapRect(&devRect, rect); |
393 | 394 |
394 if (combinedMatrix.rectStaysRect()) { | |
395 set_inset_fan(fan0Pos, vsize, devRect, -SK_ScalarHalf, -SK_ScalarHalf); | 395 set_inset_fan(fan0Pos, vsize, devRect, -SK_ScalarHalf, -SK_ScalarHalf); |
396 set_inset_fan(fan1Pos, vsize, devRect, SK_ScalarHalf, SK_ScalarHalf); | 396 set_inset_fan(fan1Pos, vsize, devRect, SK_ScalarHalf, SK_ScalarHalf); |
397 } else { | 397 } else { |
398 // compute transformed (1, 0) and (0, 1) vectors | 398 // compute transformed (1, 0) and (0, 1) vectors |
399 SkVector vec[2] = { | 399 SkVector vec[2] = { |
400 { combinedMatrix[SkMatrix::kMScaleX], combinedMatrix[SkMatrix::kMSkewY
] }, | 400 { combinedMatrix[SkMatrix::kMScaleX], combinedMatrix[SkMatrix::kMSkewY
] }, |
401 { combinedMatrix[SkMatrix::kMSkewX], combinedMatrix[SkMatrix::kMScale
Y] } | 401 { combinedMatrix[SkMatrix::kMSkewX], combinedMatrix[SkMatrix::kMScale
Y] } |
402 }; | 402 }; |
403 | 403 |
404 vec[0].normalize(); | 404 vec[0].normalize(); |
405 vec[0].scale(SK_ScalarHalf); | 405 vec[0].scale(SK_ScalarHalf); |
406 vec[1].normalize(); | 406 vec[1].normalize(); |
407 vec[1].scale(SK_ScalarHalf); | 407 vec[1].scale(SK_ScalarHalf); |
408 | 408 |
| 409 // create the rotated rect |
409 fan0Pos->setRectFan(rect.fLeft, rect.fTop, | 410 fan0Pos->setRectFan(rect.fLeft, rect.fTop, |
410 rect.fRight, rect.fBottom, vsize); | 411 rect.fRight, rect.fBottom, vsize); |
411 combinedMatrix.mapPointsWithStride(fan0Pos, vsize, 4); | 412 combinedMatrix.mapPointsWithStride(fan0Pos, vsize, 4); |
412 | 413 |
| 414 // Now create the inset points and then outset the original |
| 415 // rotated points |
| 416 |
413 // TL | 417 // TL |
414 *((SkPoint*)((intptr_t)fan1Pos + 0 * vsize)) = | 418 *((SkPoint*)((intptr_t)fan1Pos + 0 * vsize)) = |
415 *((SkPoint*)((intptr_t)fan0Pos + 0 * vsize)) + vec[0] + vec[1]; | 419 *((SkPoint*)((intptr_t)fan0Pos + 0 * vsize)) + vec[0] + vec[1]; |
416 *((SkPoint*)((intptr_t)fan0Pos + 0 * vsize)) -= vec[0] + vec[1]; | 420 *((SkPoint*)((intptr_t)fan0Pos + 0 * vsize)) -= vec[0] + vec[1]; |
417 // BL | 421 // BL |
418 *((SkPoint*)((intptr_t)fan1Pos + 1 * vsize)) = | 422 *((SkPoint*)((intptr_t)fan1Pos + 1 * vsize)) = |
419 *((SkPoint*)((intptr_t)fan0Pos + 1 * vsize)) + vec[0] - vec[1]; | 423 *((SkPoint*)((intptr_t)fan0Pos + 1 * vsize)) + vec[0] - vec[1]; |
420 *((SkPoint*)((intptr_t)fan0Pos + 1 * vsize)) -= vec[0] - vec[1]; | 424 *((SkPoint*)((intptr_t)fan0Pos + 1 * vsize)) -= vec[0] - vec[1]; |
421 // BR | 425 // BR |
422 *((SkPoint*)((intptr_t)fan1Pos + 2 * vsize)) = | 426 *((SkPoint*)((intptr_t)fan1Pos + 2 * vsize)) = |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 // The innermost rect has full coverage | 708 // The innermost rect has full coverage |
705 verts += 8 * vsize; | 709 verts += 8 * vsize; |
706 for (int i = 0; i < 4; ++i) { | 710 for (int i = 0; i < 4; ++i) { |
707 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; | 711 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; |
708 } | 712 } |
709 | 713 |
710 target->setIndexSourceToBuffer(indexBuffer); | 714 target->setIndexSourceToBuffer(indexBuffer); |
711 target->drawIndexed(kTriangles_GrPrimitiveType, | 715 target->drawIndexed(kTriangles_GrPrimitiveType, |
712 0, 0, 16, aaStrokeRectIndexCount()); | 716 0, 0, 16, aaStrokeRectIndexCount()); |
713 } | 717 } |
OLD | NEW |