| 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 391 } |
| 392 | 392 |
| 393 GrIndexBuffer* indexBuffer = this->aaFillRectIndexBuffer(gpu); | 393 GrIndexBuffer* indexBuffer = this->aaFillRectIndexBuffer(gpu); |
| 394 if (NULL == indexBuffer) { | 394 if (NULL == indexBuffer) { |
| 395 GrPrintf("Failed to create index buffer!\n"); | 395 GrPrintf("Failed to create index buffer!\n"); |
| 396 return; | 396 return; |
| 397 } | 397 } |
| 398 | 398 |
| 399 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices()); | 399 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices()); |
| 400 size_t vsize = drawState->getVertexSize(); | 400 size_t vsize = drawState->getVertexSize(); |
| 401 GrAssert(sizeof(GrPoint) + sizeof(GrColor) == vsize); | 401 SkASSERT(sizeof(GrPoint) + sizeof(GrColor) == vsize); |
| 402 | 402 |
| 403 GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts); | 403 GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts); |
| 404 GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize); | 404 GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize); |
| 405 | 405 |
| 406 SkScalar inset = SkMinScalar(devRect.width(), SK_Scalar1); | 406 SkScalar inset = SkMinScalar(devRect.width(), SK_Scalar1); |
| 407 inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height()); | 407 inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height()); |
| 408 | 408 |
| 409 if (combinedMatrix.rectStaysRect()) { | 409 if (combinedMatrix.rectStaysRect()) { |
| 410 // Temporarily #if'ed out. We don't want to pass in the devRect but | 410 // Temporarily #if'ed out. We don't want to pass in the devRect but |
| 411 // right now it is computed in GrContext::apply_aa_to_rect and we don't | 411 // right now it is computed in GrContext::apply_aa_to_rect and we don't |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 538 |
| 539 // compute transformed (width, 0) and (0, height) vectors | 539 // compute transformed (width, 0) and (0, height) vectors |
| 540 SkVector vec[2] = { | 540 SkVector vec[2] = { |
| 541 { combinedMatrix[SkMatrix::kMScaleX], combinedMatrix[SkMatrix::kMSkewY] }, | 541 { combinedMatrix[SkMatrix::kMScaleX], combinedMatrix[SkMatrix::kMSkewY] }, |
| 542 { combinedMatrix[SkMatrix::kMSkewX], combinedMatrix[SkMatrix::kMScaleY] } | 542 { combinedMatrix[SkMatrix::kMSkewX], combinedMatrix[SkMatrix::kMScaleY] } |
| 543 }; | 543 }; |
| 544 | 544 |
| 545 SkScalar newWidth = SkScalarHalf(rect.width() * vec[0].length()) + SK_Scalar
Half; | 545 SkScalar newWidth = SkScalarHalf(rect.width() * vec[0].length()) + SK_Scalar
Half; |
| 546 SkScalar newHeight = SkScalarHalf(rect.height() * vec[1].length()) + SK_Scal
arHalf; | 546 SkScalar newHeight = SkScalarHalf(rect.height() * vec[1].length()) + SK_Scal
arHalf; |
| 547 drawState->setVertexAttribs<gAARectVertexAttribs>(SK_ARRAY_COUNT(gAARectVert
exAttribs)); | 547 drawState->setVertexAttribs<gAARectVertexAttribs>(SK_ARRAY_COUNT(gAARectVert
exAttribs)); |
| 548 GrAssert(sizeof(RectVertex) == drawState->getVertexSize()); | 548 SkASSERT(sizeof(RectVertex) == drawState->getVertexSize()); |
| 549 | 549 |
| 550 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 550 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
| 551 if (!geo.succeeded()) { | 551 if (!geo.succeeded()) { |
| 552 GrPrintf("Failed to get space for vertices!\n"); | 552 GrPrintf("Failed to get space for vertices!\n"); |
| 553 return; | 553 return; |
| 554 } | 554 } |
| 555 | 555 |
| 556 RectVertex* verts = reinterpret_cast<RectVertex*>(geo.vertices()); | 556 RectVertex* verts = reinterpret_cast<RectVertex*>(geo.vertices()); |
| 557 | 557 |
| 558 GrEffectRef* effect = GrRectEffect::Create(); | 558 GrEffectRef* effect = GrRectEffect::Create(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 588 } | 588 } |
| 589 | 589 |
| 590 void GrAARectRenderer::shaderFillAlignedAARect(GrGpu* gpu, | 590 void GrAARectRenderer::shaderFillAlignedAARect(GrGpu* gpu, |
| 591 GrDrawTarget* target, | 591 GrDrawTarget* target, |
| 592 const SkRect& rect, | 592 const SkRect& rect, |
| 593 const SkMatrix& combinedMatrix) { | 593 const SkMatrix& combinedMatrix) { |
| 594 GrDrawState* drawState = target->drawState(); | 594 GrDrawState* drawState = target->drawState(); |
| 595 SkASSERT(combinedMatrix.rectStaysRect()); | 595 SkASSERT(combinedMatrix.rectStaysRect()); |
| 596 | 596 |
| 597 drawState->setVertexAttribs<gAAAARectVertexAttribs>(SK_ARRAY_COUNT(gAAAARect
VertexAttribs)); | 597 drawState->setVertexAttribs<gAAAARectVertexAttribs>(SK_ARRAY_COUNT(gAAAARect
VertexAttribs)); |
| 598 GrAssert(sizeof(AARectVertex) == drawState->getVertexSize()); | 598 SkASSERT(sizeof(AARectVertex) == drawState->getVertexSize()); |
| 599 | 599 |
| 600 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 600 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
| 601 if (!geo.succeeded()) { | 601 if (!geo.succeeded()) { |
| 602 GrPrintf("Failed to get space for vertices!\n"); | 602 GrPrintf("Failed to get space for vertices!\n"); |
| 603 return; | 603 return; |
| 604 } | 604 } |
| 605 | 605 |
| 606 AARectVertex* verts = reinterpret_cast<AARectVertex*>(geo.vertices()); | 606 AARectVertex* verts = reinterpret_cast<AARectVertex*>(geo.vertices()); |
| 607 | 607 |
| 608 GrEffectRef* effect = GrAlignedRectEffect::Create(); | 608 GrEffectRef* effect = GrAlignedRectEffect::Create(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 return; | 711 return; |
| 712 } | 712 } |
| 713 GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(gpu); | 713 GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(gpu); |
| 714 if (NULL == indexBuffer) { | 714 if (NULL == indexBuffer) { |
| 715 GrPrintf("Failed to create index buffer!\n"); | 715 GrPrintf("Failed to create index buffer!\n"); |
| 716 return; | 716 return; |
| 717 } | 717 } |
| 718 | 718 |
| 719 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices()); | 719 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices()); |
| 720 size_t vsize = drawState->getVertexSize(); | 720 size_t vsize = drawState->getVertexSize(); |
| 721 GrAssert(sizeof(GrPoint) + sizeof(GrColor) == vsize); | 721 SkASSERT(sizeof(GrPoint) + sizeof(GrColor) == vsize); |
| 722 | 722 |
| 723 // We create vertices for four nested rectangles. There are two ramps from 0
to full | 723 // We create vertices for four nested rectangles. There are two ramps from 0
to full |
| 724 // coverage, one on the exterior of the stroke and the other on the interior
. | 724 // coverage, one on the exterior of the stroke and the other on the interior
. |
| 725 // The following pointers refer to the four rects, from outermost to innermo
st. | 725 // The following pointers refer to the four rects, from outermost to innermo
st. |
| 726 GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts); | 726 GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts); |
| 727 GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize); | 727 GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize); |
| 728 GrPoint* fan2Pos = reinterpret_cast<GrPoint*>(verts + 8 * vsize); | 728 GrPoint* fan2Pos = reinterpret_cast<GrPoint*>(verts + 8 * vsize); |
| 729 GrPoint* fan3Pos = reinterpret_cast<GrPoint*>(verts + 12 * vsize); | 729 GrPoint* fan3Pos = reinterpret_cast<GrPoint*>(verts + 12 * vsize); |
| 730 | 730 |
| 731 #ifndef SK_IGNORE_THIN_STROKED_RECT_FIX | 731 #ifndef SK_IGNORE_THIN_STROKED_RECT_FIX |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 // can't call mapRect for devInside since it calls sort | 803 // can't call mapRect for devInside since it calls sort |
| 804 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; | 804 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; |
| 805 | 805 |
| 806 if (devInside.isEmpty()) { | 806 if (devInside.isEmpty()) { |
| 807 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use
VertexCoverage); | 807 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use
VertexCoverage); |
| 808 return; | 808 return; |
| 809 } | 809 } |
| 810 | 810 |
| 811 this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCove
rage); | 811 this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCove
rage); |
| 812 } | 812 } |
| OLD | NEW |