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

Side by Side Diff: src/gpu/GrAARectRenderer.cpp

Issue 435743002: Always use both a color and coverage attribute in GrAARectRenderer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove old ignored tests by bungeman that were accidentally re-added. Created 6 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 | « src/gpu/GrAARectRenderer.h ('k') | src/gpu/GrClipMaskManager.cpp » ('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 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 "GrGpu.h" 9 #include "GrGpu.h"
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 GrContext* context, 249 GrContext* context,
250 const GrDrawTargetCaps&, 250 const GrDrawTargetCaps&,
251 GrTexture* textures[]) { 251 GrTexture* textures[]) {
252 return GrRectEffect::Create(); 252 return GrRectEffect::Create();
253 } 253 }
254 254
255 /////////////////////////////////////////////////////////////////////////////// 255 ///////////////////////////////////////////////////////////////////////////////
256 256
257 namespace { 257 namespace {
258 258
259 extern const GrVertexAttrib gAARectCoverageAttribs[] = { 259 extern const GrVertexAttrib gAARectAttribs[] = {
260 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindin g}, 260 {kVec2f_GrVertexAttribType, 0, kPosition_Gr VertexAttribBinding},
261 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kCoverage_GrVertexAttribBindin g}, 261 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer texAttribBinding},
262 {kVec4ub_GrVertexAttribType, sizeof(SkPoint) + sizeof(SkColor), kCoverage_Gr VertexAttribBinding},
262 }; 263 };
263 264
264 extern const GrVertexAttrib gAARectColorAttribs[] = {
265 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindin g},
266 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVertexAttribBinding},
267 };
268
269 static void set_aa_rect_vertex_attributes(GrDrawState* drawState, bool useCovera ge) {
270 if (useCoverage) {
271 drawState->setVertexAttribs<gAARectCoverageAttribs>(SK_ARRAY_COUNT(gAARe ctCoverageAttribs));
272 } else {
273 drawState->setVertexAttribs<gAARectColorAttribs>(SK_ARRAY_COUNT(gAARectC olorAttribs));
274 }
275 }
276
277 static void set_inset_fan(SkPoint* pts, size_t stride, 265 static void set_inset_fan(SkPoint* pts, size_t stride,
278 const SkRect& r, SkScalar dx, SkScalar dy) { 266 const SkRect& r, SkScalar dx, SkScalar dy) {
279 pts->setRectFan(r.fLeft + dx, r.fTop + dy, 267 pts->setRectFan(r.fLeft + dx, r.fTop + dy,
280 r.fRight - dx, r.fBottom - dy, stride); 268 r.fRight - dx, r.fBottom - dy, stride);
281 } 269 }
282 270
283 }; 271 };
284 272
285 void GrAARectRenderer::reset() { 273 void GrAARectRenderer::reset() {
286 SkSafeSetNull(fAAFillRectIndexBuffer); 274 SkSafeSetNull(fAAFillRectIndexBuffer);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 432 }
445 } 433 }
446 return fAABevelStrokeRectIndexBuffer; 434 return fAABevelStrokeRectIndexBuffer;
447 } 435 }
448 } 436 }
449 437
450 void GrAARectRenderer::geometryFillAARect(GrGpu* gpu, 438 void GrAARectRenderer::geometryFillAARect(GrGpu* gpu,
451 GrDrawTarget* target, 439 GrDrawTarget* target,
452 const SkRect& rect, 440 const SkRect& rect,
453 const SkMatrix& combinedMatrix, 441 const SkMatrix& combinedMatrix,
454 const SkRect& devRect, 442 const SkRect& devRect) {
455 bool useVertexCoverage) {
456 GrDrawState* drawState = target->drawState(); 443 GrDrawState* drawState = target->drawState();
457 444
458 set_aa_rect_vertex_attributes(drawState, useVertexCoverage); 445 GrColor color = drawState->getColor();
446
447 drawState->setVertexAttribs<gAARectAttribs>(SK_ARRAY_COUNT(gAARectAttribs));
robertphillips 2014/08/11 15:50:57 Add a "bool is_opaque(GrColor)" helper to GrColor.
448 static const GrColor kFullAlphaColor = (0xFF << GrColor_SHIFT_A);
449 if ((kFullAlphaColor & color) == kFullAlphaColor) {
450 drawState->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true);
451 }
459 452
460 GrDrawTarget::AutoReleaseGeometry geo(target, 8, 0); 453 GrDrawTarget::AutoReleaseGeometry geo(target, 8, 0);
461 if (!geo.succeeded()) { 454 if (!geo.succeeded()) {
462 GrPrintf("Failed to get space for vertices!\n"); 455 GrPrintf("Failed to get space for vertices!\n");
463 return; 456 return;
464 } 457 }
465 458
466 GrIndexBuffer* indexBuffer = this->aaFillRectIndexBuffer(gpu); 459 GrIndexBuffer* indexBuffer = this->aaFillRectIndexBuffer(gpu);
467 if (NULL == indexBuffer) { 460 if (NULL == indexBuffer) {
468 GrPrintf("Failed to create index buffer!\n"); 461 GrPrintf("Failed to create index buffer!\n");
469 return; 462 return;
470 } 463 }
471 464
472 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices()); 465 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices());
473 size_t vsize = drawState->getVertexSize(); 466 size_t vsize = drawState->getVertexSize();
474 SkASSERT(sizeof(SkPoint) + sizeof(GrColor) == vsize); 467 SkASSERT(sizeof(SkPoint) + 2 * sizeof(GrColor) == vsize);
475 468
476 SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts); 469 SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
477 SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vsize); 470 SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vsize);
478 471
479 SkScalar inset = SkMinScalar(devRect.width(), SK_Scalar1); 472 SkScalar inset = SkMinScalar(devRect.width(), SK_Scalar1);
480 inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height()); 473 inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height());
481 474
482 if (combinedMatrix.rectStaysRect()) { 475 if (combinedMatrix.rectStaysRect()) {
483 // Temporarily #if'ed out. We don't want to pass in the devRect but 476 // Temporarily #if'ed out. We don't want to pass in the devRect but
484 // right now it is computed in GrContext::apply_aa_to_rect and we don't 477 // right now it is computed in GrContext::apply_aa_to_rect and we don't
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // BR 514 // BR
522 *((SkPoint*)((intptr_t)fan1Pos + 2 * vsize)) = 515 *((SkPoint*)((intptr_t)fan1Pos + 2 * vsize)) =
523 *((SkPoint*)((intptr_t)fan0Pos + 2 * vsize)) - vec[0] - vec[1]; 516 *((SkPoint*)((intptr_t)fan0Pos + 2 * vsize)) - vec[0] - vec[1];
524 *((SkPoint*)((intptr_t)fan0Pos + 2 * vsize)) += vec[0] + vec[1]; 517 *((SkPoint*)((intptr_t)fan0Pos + 2 * vsize)) += vec[0] + vec[1];
525 // TR 518 // TR
526 *((SkPoint*)((intptr_t)fan1Pos + 3 * vsize)) = 519 *((SkPoint*)((intptr_t)fan1Pos + 3 * vsize)) =
527 *((SkPoint*)((intptr_t)fan0Pos + 3 * vsize)) - vec[0] + vec[1]; 520 *((SkPoint*)((intptr_t)fan0Pos + 3 * vsize)) - vec[0] + vec[1];
528 *((SkPoint*)((intptr_t)fan0Pos + 3 * vsize)) += vec[0] - vec[1]; 521 *((SkPoint*)((intptr_t)fan0Pos + 3 * vsize)) += vec[0] - vec[1];
529 } 522 }
530 523
524 // Make verts point to vertex color and then set all the color and coverage vertex attrs values.
531 verts += sizeof(SkPoint); 525 verts += sizeof(SkPoint);
532 for (int i = 0; i < 4; ++i) { 526 for (int i = 0; i < 4; ++i) {
533 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; 527 *reinterpret_cast<GrColor*>(verts + i * vsize) = color;
528 }
robertphillips 2014/08/11 15:50:57 Fuse this into prior loop ?
529 for (int i = 0; i < 4; ++i) {
530 *reinterpret_cast<GrColor*>(verts + i * vsize + sizeof(GrColor)) = 0;
534 } 531 }
535 532
536 int scale; 533 int scale;
537 if (inset < SK_ScalarHalf) { 534 if (inset < SK_ScalarHalf) {
538 scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf)); 535 scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf));
539 SkASSERT(scale >= 0 && scale <= 255); 536 SkASSERT(scale >= 0 && scale <= 255);
540 } else { 537 } else {
541 scale = 0xff; 538 scale = 0xff;
542 } 539 }
543 540
544 GrColor innerColor;
545 if (useVertexCoverage) {
546 innerColor = GrColorPackRGBA(scale, scale, scale, scale);
547 } else {
548 if (0xff == scale) {
549 innerColor = target->getDrawState().getColor();
550 } else {
551 innerColor = SkAlphaMulQ(target->getDrawState().getColor(), scale);
552 }
553 }
554
555 verts += 4 * vsize; 541 verts += 4 * vsize;
556 for (int i = 0; i < 4; ++i) { 542 for (int i = 0; i < 4; ++i) {
557 *reinterpret_cast<GrColor*>(verts + i * vsize) = innerColor; 543 *reinterpret_cast<GrColor*>(verts + i * vsize) = color;
544 }
545 GrColor innerCoverage;
546 innerCoverage = GrColorPackRGBA(scale, scale, scale, scale);
robertphillips 2014/08/11 15:50:57 Fuse this into prior loop ?
547 for (int i = 0; i < 4; ++i) {
548 *reinterpret_cast<GrColor*>(verts + i * vsize + sizeof(GrColor)) = inner Coverage;
558 } 549 }
559 550
560 target->setIndexSourceToBuffer(indexBuffer); 551 target->setIndexSourceToBuffer(indexBuffer);
561 target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 552 target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1,
562 kVertsPerAAFillRect, 553 kVertsPerAAFillRect,
563 kIndicesPerAAFillRect); 554 kIndicesPerAAFillRect);
564 target->resetIndexSource(); 555 target->resetIndexSource();
565 } 556 }
566 557
567 namespace { 558 namespace {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 target->setIndexSourceToBuffer(gpu->getContext()->getQuadIndexBuffer()); 707 target->setIndexSourceToBuffer(gpu->getContext()->getQuadIndexBuffer());
717 target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6); 708 target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6);
718 target->resetIndexSource(); 709 target->resetIndexSource();
719 } 710 }
720 711
721 void GrAARectRenderer::strokeAARect(GrGpu* gpu, 712 void GrAARectRenderer::strokeAARect(GrGpu* gpu,
722 GrDrawTarget* target, 713 GrDrawTarget* target,
723 const SkRect& rect, 714 const SkRect& rect,
724 const SkMatrix& combinedMatrix, 715 const SkMatrix& combinedMatrix,
725 const SkRect& devRect, 716 const SkRect& devRect,
726 const SkStrokeRec& stroke, 717 const SkStrokeRec& stroke) {
727 bool useVertexCoverage) {
728 SkVector devStrokeSize; 718 SkVector devStrokeSize;
729 SkScalar width = stroke.getWidth(); 719 SkScalar width = stroke.getWidth();
730 if (width > 0) { 720 if (width > 0) {
731 devStrokeSize.set(width, width); 721 devStrokeSize.set(width, width);
732 combinedMatrix.mapVectors(&devStrokeSize, 1); 722 combinedMatrix.mapVectors(&devStrokeSize, 1);
733 devStrokeSize.setAbs(devStrokeSize); 723 devStrokeSize.setAbs(devStrokeSize);
734 } else { 724 } else {
735 devStrokeSize.set(SK_Scalar1, SK_Scalar1); 725 devStrokeSize.set(SK_Scalar1, SK_Scalar1);
736 } 726 }
737 727
(...skipping 22 matching lines...) Expand all
760 750
761 bool miterStroke = true; 751 bool miterStroke = true;
762 // For hairlines, make bevel and round joins appear the same as mitered ones . 752 // For hairlines, make bevel and round joins appear the same as mitered ones .
763 // small miter limit means right angles show bevel... 753 // small miter limit means right angles show bevel...
764 if ((width > 0) && (stroke.getJoin() != SkPaint::kMiter_Join || 754 if ((width > 0) && (stroke.getJoin() != SkPaint::kMiter_Join ||
765 stroke.getMiter() < SK_ScalarSqrt2)) { 755 stroke.getMiter() < SK_ScalarSqrt2)) {
766 miterStroke = false; 756 miterStroke = false;
767 } 757 }
768 758
769 if (spare <= 0 && miterStroke) { 759 if (spare <= 0 && miterStroke) {
770 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), 760 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside);
771 devOutside, useVertexCoverage);
772 return; 761 return;
773 } 762 }
774 763
775 SkRect devInside(devRect); 764 SkRect devInside(devRect);
776 devInside.inset(rx, ry); 765 devInside.inset(rx, ry);
777 766
778 SkRect devOutsideAssist(devRect); 767 SkRect devOutsideAssist(devRect);
779 768
780 // For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist) 769 // For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist)
781 // to draw the outer of the rect. Because there are 8 vertices on the outer 770 // to draw the outer of the rect. Because there are 8 vertices on the outer
782 // edge, while vertex number of inner edge is 4, the same as miter-stroke. 771 // edge, while vertex number of inner edge is 4, the same as miter-stroke.
783 if (!miterStroke) { 772 if (!miterStroke) {
784 devOutside.inset(0, ry); 773 devOutside.inset(0, ry);
785 devOutsideAssist.outset(0, ry); 774 devOutsideAssist.outset(0, ry);
786 } 775 }
787 776
788 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, 777 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, devIns ide, miterStroke);
789 devInside, useVertexCoverage, miterStroke);
790 } 778 }
791 779
792 void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu, 780 void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
793 GrDrawTarget* target, 781 GrDrawTarget* target,
794 const SkRect& devOutside, 782 const SkRect& devOutside,
795 const SkRect& devOutsideAssist, 783 const SkRect& devOutsideAssist,
796 const SkRect& devInside, 784 const SkRect& devInside,
797 bool useVertexCoverage,
798 bool miterStroke) { 785 bool miterStroke) {
799 GrDrawState* drawState = target->drawState(); 786 GrDrawState* drawState = target->drawState();
800 787
801 set_aa_rect_vertex_attributes(drawState, useVertexCoverage); 788 drawState->setVertexAttribs<gAARectAttribs>(SK_ARRAY_COUNT(gAARectAttribs));
789
790 GrColor color = drawState->getColor();
791 static const GrColor kFullAlphaColor = (0xFF << GrColor_SHIFT_A);
792 if ((kFullAlphaColor & color) == kFullAlphaColor) {
793 drawState->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true);
794 }
802 795
803 int innerVertexNum = 4; 796 int innerVertexNum = 4;
804 int outerVertexNum = miterStroke ? 4 : 8; 797 int outerVertexNum = miterStroke ? 4 : 8;
805 int totalVertexNum = (outerVertexNum + innerVertexNum) * 2; 798 int totalVertexNum = (outerVertexNum + innerVertexNum) * 2;
806 799
807 GrDrawTarget::AutoReleaseGeometry geo(target, totalVertexNum, 0); 800 GrDrawTarget::AutoReleaseGeometry geo(target, totalVertexNum, 0);
808 if (!geo.succeeded()) { 801 if (!geo.succeeded()) {
809 GrPrintf("Failed to get space for vertices!\n"); 802 GrPrintf("Failed to get space for vertices!\n");
810 return; 803 return;
811 } 804 }
812 GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(gpu, miterStroke) ; 805 GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(gpu, miterStroke) ;
813 if (NULL == indexBuffer) { 806 if (NULL == indexBuffer) {
814 GrPrintf("Failed to create index buffer!\n"); 807 GrPrintf("Failed to create index buffer!\n");
815 return; 808 return;
816 } 809 }
817 810
818 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices()); 811 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices());
819 size_t vsize = drawState->getVertexSize(); 812 size_t vsize = drawState->getVertexSize();
820 SkASSERT(sizeof(SkPoint) + sizeof(GrColor) == vsize);
821 813
822 // We create vertices for four nested rectangles. There are two ramps from 0 to full 814 // We create vertices for four nested rectangles. There are two ramps from 0 to full
823 // coverage, one on the exterior of the stroke and the other on the interior . 815 // coverage, one on the exterior of the stroke and the other on the interior .
824 // The following pointers refer to the four rects, from outermost to innermo st. 816 // The following pointers refer to the four rects, from outermost to innermo st.
825 SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts); 817 SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
826 SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + outerVertexNum * vsize ); 818 SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + outerVertexNum * vsize );
827 SkPoint* fan2Pos = reinterpret_cast<SkPoint*>(verts + 2 * outerVertexNum * v size); 819 SkPoint* fan2Pos = reinterpret_cast<SkPoint*>(verts + 2 * outerVertexNum * v size);
828 SkPoint* fan3Pos = reinterpret_cast<SkPoint*>(verts + (2 * outerVertexNum + innerVertexNum) * vsize); 820 SkPoint* fan3Pos = reinterpret_cast<SkPoint*>(verts + (2 * outerVertexNum + innerVertexNum) * vsize);
829 821
830 #ifndef SK_IGNORE_THIN_STROKED_RECT_FIX 822 #ifndef SK_IGNORE_THIN_STROKED_RECT_FIX
(...skipping 28 matching lines...) Expand all
859 set_inset_fan(fan0AssistPos, vsize, devOutsideAssist, -SK_ScalarHalf, -S K_ScalarHalf); 851 set_inset_fan(fan0AssistPos, vsize, devOutsideAssist, -SK_ScalarHalf, -S K_ScalarHalf);
860 // outer one of the inner two 852 // outer one of the inner two
861 set_inset_fan(fan1Pos, vsize, devOutside, inset, inset); 853 set_inset_fan(fan1Pos, vsize, devOutside, inset, inset);
862 set_inset_fan(fan1AssistPos, vsize, devOutsideAssist, inset, inset); 854 set_inset_fan(fan1AssistPos, vsize, devOutsideAssist, inset, inset);
863 // inner one of the inner two 855 // inner one of the inner two
864 set_inset_fan(fan2Pos, vsize, devInside, -inset, -inset); 856 set_inset_fan(fan2Pos, vsize, devInside, -inset, -inset);
865 // innermost 857 // innermost
866 set_inset_fan(fan3Pos, vsize, devInside, SK_ScalarHalf, SK_ScalarHalf ); 858 set_inset_fan(fan3Pos, vsize, devInside, SK_ScalarHalf, SK_ScalarHalf );
867 } 859 }
868 860
869 // The outermost rect has 0 coverage 861 // Make verts point to vertex color and then set all the color and coverage vertex attrs values.
870 verts += sizeof(SkPoint); 862 verts += sizeof(SkPoint);
871 for (int i = 0; i < outerVertexNum; ++i) { 863 for (int i = 0; i < outerVertexNum; ++i) {
872 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; 864 *reinterpret_cast<GrColor*>(verts + i * vsize) = color;
865 }
866 // The outermost rect has 0 coverage
robertphillips 2014/08/11 15:50:57 Fuse with prior loop ?
867 for (int i = 0; i < outerVertexNum; ++i) {
868 *reinterpret_cast<GrColor*>(verts + i * vsize + sizeof(GrColor)) = 0;
873 } 869 }
874 870
871 // scale is the coverage for the the inner two rects.
875 int scale; 872 int scale;
876 if (inset < SK_ScalarHalf) { 873 if (inset < SK_ScalarHalf) {
877 scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf)); 874 scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf));
878 SkASSERT(scale >= 0 && scale <= 255); 875 SkASSERT(scale >= 0 && scale <= 255);
879 } else { 876 } else {
880 scale = 0xff; 877 scale = 0xff;
881 } 878 }
882 879
883 // The inner two rects have full coverage
884 GrColor innerColor;
885 if (useVertexCoverage) {
886 innerColor = GrColorPackRGBA(scale, scale, scale, scale);
887 } else {
888 if (0xff == scale) {
889 innerColor = target->getDrawState().getColor();
890 } else {
891 innerColor = SkAlphaMulQ(target->getDrawState().getColor(), scale);
892 }
893 }
894
895 verts += outerVertexNum * vsize; 880 verts += outerVertexNum * vsize;
896 for (int i = 0; i < outerVertexNum + innerVertexNum; ++i) { 881 for (int i = 0; i < outerVertexNum + innerVertexNum; ++i) {
897 *reinterpret_cast<GrColor*>(verts + i * vsize) = innerColor; 882 *reinterpret_cast<GrColor*>(verts + i * vsize) = color;
883 }
884
robertphillips 2014/08/11 15:50:57 Fuse with prior loop ?
885 GrColor innerCoverage = GrColorPackRGBA(scale, scale, scale, scale);
886 for (int i = 0; i < outerVertexNum + innerVertexNum; ++i) {
887 *reinterpret_cast<GrColor*>(verts + i * vsize + sizeof(GrColor)) = inner Coverage;
898 } 888 }
899 889
900 // The innermost rect has 0 coverage 890 // The innermost rect has 0 coverage
901 verts += (outerVertexNum + innerVertexNum) * vsize; 891 verts += (outerVertexNum + innerVertexNum) * vsize;
902 for (int i = 0; i < innerVertexNum; ++i) { 892 for (int i = 0; i < innerVertexNum; ++i) {
903 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; 893 *reinterpret_cast<GrColor*>(verts + i * vsize) = color;
894 }
robertphillips 2014/08/11 15:50:57 Fuse with prior loop ?
895 for (int i = 0; i < innerVertexNum; ++i) {
896 *reinterpret_cast<GrColor*>(verts + i * vsize + sizeof(GrColor)) = 0;
904 } 897 }
905 898
906 target->setIndexSourceToBuffer(indexBuffer); 899 target->setIndexSourceToBuffer(indexBuffer);
907 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 900 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0,
908 totalVertexNum, aaStrokeRectIndexCount(miterStroke)); 901 totalVertexNum, aaStrokeRectIndexCount(miterStroke));
909 } 902 }
910 903
911 void GrAARectRenderer::fillAANestedRects(GrGpu* gpu, 904 void GrAARectRenderer::fillAANestedRects(GrGpu* gpu,
912 GrDrawTarget* target, 905 GrDrawTarget* target,
913 const SkRect rects[2], 906 const SkRect rects[2],
914 const SkMatrix& combinedMatrix, 907 const SkMatrix& combinedMatrix) {
915 bool useVertexCoverage) {
916 SkASSERT(combinedMatrix.rectStaysRect()); 908 SkASSERT(combinedMatrix.rectStaysRect());
917 SkASSERT(!rects[1].isEmpty()); 909 SkASSERT(!rects[1].isEmpty());
918 910
919 SkRect devOutside, devOutsideAssist, devInside; 911 SkRect devOutside, devOutsideAssist, devInside;
920 combinedMatrix.mapRect(&devOutside, rects[0]); 912 combinedMatrix.mapRect(&devOutside, rects[0]);
921 // can't call mapRect for devInside since it calls sort 913 // can't call mapRect for devInside since it calls sort
922 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2) ; 914 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2) ;
923 915
924 if (devInside.isEmpty()) { 916 if (devInside.isEmpty()) {
925 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use VertexCoverage); 917 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside);
926 return; 918 return;
927 } 919 }
928 920
929 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, 921 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, devIns ide, true);
930 devInside, useVertexCoverage, true);
931 } 922 }
OLDNEW
« no previous file with comments | « src/gpu/GrAARectRenderer.h ('k') | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698