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/GrAAHairLinePathRenderer.cpp

Issue 24269004: Reenable GrAAHairlinePathRenderer assert w/ fix (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Improved comment Created 7 years, 3 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 | Annotate | Revision Log
« 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 2011 Google Inc. 2 * Copyright 2011 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 "GrAAHairLinePathRenderer.h" 8 #include "GrAAHairLinePathRenderer.h"
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 bool GrAAHairLinePathRenderer::createLineGeom(const SkPath& path, 731 bool GrAAHairLinePathRenderer::createLineGeom(const SkPath& path,
732 GrDrawTarget* target, 732 GrDrawTarget* target,
733 const PtArray& lines, 733 const PtArray& lines,
734 int lineCnt, 734 int lineCnt,
735 GrDrawTarget::AutoReleaseGeometry* arg, 735 GrDrawTarget::AutoReleaseGeometry* arg,
736 SkRect* devBounds) { 736 SkRect* devBounds) {
737 GrDrawState* drawState = target->drawState(); 737 GrDrawState* drawState = target->drawState();
738 738
739 const SkMatrix& viewM = drawState->getViewMatrix(); 739 const SkMatrix& viewM = drawState->getViewMatrix();
740 740
741 devBounds->outset(SK_Scalar1, SK_Scalar1);
742
743 int vertCnt = kVertsPerLineSeg * lineCnt; 741 int vertCnt = kVertsPerLineSeg * lineCnt;
744 742
745 drawState->setVertexAttribs<gHairlineLineAttribs>(SK_ARRAY_COUNT(gHairlineLi neAttribs)); 743 drawState->setVertexAttribs<gHairlineLineAttribs>(SK_ARRAY_COUNT(gHairlineLi neAttribs));
746 SkASSERT(sizeof(LineVertex) == drawState->getVertexSize()); 744 SkASSERT(sizeof(LineVertex) == drawState->getVertexSize());
747 745
748 if (!arg->set(target, vertCnt, 0)) { 746 if (!arg->set(target, vertCnt, 0)) {
749 return false; 747 return false;
750 } 748 }
751 749
752 LineVertex* verts = reinterpret_cast<LineVertex*>(arg->vertices()); 750 LineVertex* verts = reinterpret_cast<LineVertex*>(arg->vertices());
753 751
754 const SkMatrix* toSrc = NULL; 752 const SkMatrix* toSrc = NULL;
755 SkMatrix ivm; 753 SkMatrix ivm;
756 754
757 if (viewM.hasPerspective()) { 755 if (viewM.hasPerspective()) {
758 if (viewM.invert(&ivm)) { 756 if (viewM.invert(&ivm)) {
759 toSrc = &ivm; 757 toSrc = &ivm;
760 } 758 }
761 } 759 }
762 devBounds->set(lines.begin(), lines.count()); 760 devBounds->set(lines.begin(), lines.count());
763 for (int i = 0; i < lineCnt; ++i) { 761 for (int i = 0; i < lineCnt; ++i) {
764 add_line(&lines[2*i], toSrc, drawState->getCoverage(), &verts); 762 add_line(&lines[2*i], toSrc, drawState->getCoverage(), &verts);
765 } 763 }
766 // All the verts computed by add_line are within unit distance of the end po ints. Add a little 764 // All the verts computed by add_line are within sqrt(1^2 + 0.5^2) of the en d points.
767 // extra to account for vector normalization precision. 765 static const SkScalar kSqrtOfOneAndAQuarter = SkFloatToScalar(1.118f);
768 static const SkScalar kOutset = SK_Scalar1 + SK_Scalar1 / 20; 766 // Add a little extra to account for vector normalization precision.
767 static const SkScalar kOutset = kSqrtOfOneAndAQuarter + SK_Scalar1 / 20;
769 devBounds->outset(kOutset, kOutset); 768 devBounds->outset(kOutset, kOutset);
770 769
771 return true; 770 return true;
772 } 771 }
773 772
774 bool GrAAHairLinePathRenderer::createBezierGeom( 773 bool GrAAHairLinePathRenderer::createBezierGeom(
775 const SkPath& path, 774 const SkPath& path,
776 GrDrawTarget* target, 775 GrDrawTarget* target,
777 const PtArray& quads, 776 const PtArray& quads,
778 int quadCnt, 777 int quadCnt,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 // createLineGeom transforms the geometry to device space when the matri x does not have 929 // createLineGeom transforms the geometry to device space when the matri x does not have
931 // perspective. 930 // perspective.
932 if (target->getDrawState().getViewMatrix().hasPerspective()) { 931 if (target->getDrawState().getViewMatrix().hasPerspective()) {
933 asr.set(target, GrDrawTarget::kPreserve_ASRInit); 932 asr.set(target, GrDrawTarget::kPreserve_ASRInit);
934 } else if (!asr.setIdentity(target, GrDrawTarget::kPreserve_ASRInit)) { 933 } else if (!asr.setIdentity(target, GrDrawTarget::kPreserve_ASRInit)) {
935 return false; 934 return false;
936 } 935 }
937 GrDrawState* drawState = target->drawState(); 936 GrDrawState* drawState = target->drawState();
938 937
939 // Check devBounds 938 // Check devBounds
940 // SkASSERT(check_bounds<LineVertex>(drawState, devBounds, arg.vertices() , 939 SkASSERT(check_bounds<LineVertex>(drawState, devBounds, arg.vertices(),
941 // kVertsPerLineSeg * lineCnt)); 940 kVertsPerLineSeg * lineCnt));
942 941
943 { 942 {
944 GrDrawState::AutoRestoreEffects are(drawState); 943 GrDrawState::AutoRestoreEffects are(drawState);
945 target->setIndexSourceToBuffer(fLinesIndexBuffer); 944 target->setIndexSourceToBuffer(fLinesIndexBuffer);
946 int lines = 0; 945 int lines = 0;
947 while (lines < lineCnt) { 946 while (lines < lineCnt) {
948 int n = GrMin(lineCnt - lines, kNumLineSegsInIdxBuffer); 947 int n = GrMin(lineCnt - lines, kNumLineSegsInIdxBuffer);
949 target->drawIndexed(kTriangles_GrPrimitiveType, 948 target->drawIndexed(kTriangles_GrPrimitiveType,
950 kVertsPerLineSeg*lines, // startV 949 kVertsPerLineSeg*lines, // startV
951 0, // startI 950 0, // startI
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 &devBounds); 1028 &devBounds);
1030 conics += n; 1029 conics += n;
1031 } 1030 }
1032 } 1031 }
1033 } 1032 }
1034 1033
1035 target->resetIndexSource(); 1034 target->resetIndexSource();
1036 1035
1037 return true; 1036 return true;
1038 } 1037 }
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