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

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

Issue 23926019: Stateful PathRenderer implementation (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add assert & patch for missing AutoPathClear Created 6 years, 10 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 | « src/gpu/GrAAHairLinePathRenderer.h ('k') | src/gpu/GrClipMaskManager.h » ('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 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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts, devBounds); 819 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts, devBounds);
820 } 820 }
821 821
822 // Start Conics 822 // Start Conics
823 for (int i = 0; i < conicCnt; ++i) { 823 for (int i = 0; i < conicCnt; ++i) {
824 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts, devBounds ); 824 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts, devBounds );
825 } 825 }
826 return true; 826 return true;
827 } 827 }
828 828
829 bool GrAAHairLinePathRenderer::canDrawPath(const SkPath& path, 829 bool GrAAHairLinePathRenderer::canDrawPath(const SkStrokeRec& stroke,
830 const SkStrokeRec& stroke,
831 const GrDrawTarget* target, 830 const GrDrawTarget* target,
832 bool antiAlias) const { 831 bool antiAlias) const {
833 if (!antiAlias) { 832 if (!antiAlias) {
834 return false; 833 return false;
835 } 834 }
836 835
837 if (!IsStrokeHairlineOrEquivalent(stroke, 836 if (!IsStrokeHairlineOrEquivalent(stroke,
838 target->getDrawState().getViewMatrix(), 837 target->getDrawState().getViewMatrix(),
839 NULL)) { 838 NULL)) {
840 return false; 839 return false;
841 } 840 }
842 841
843 if (SkPath::kLine_SegmentMask == path.getSegmentMasks() || 842 if (SkPath::kLine_SegmentMask == this->path().getSegmentMasks() ||
844 target->caps()->shaderDerivativeSupport()) { 843 target->caps()->shaderDerivativeSupport()) {
845 return true; 844 return true;
846 } 845 }
847 return false; 846 return false;
848 } 847 }
849 848
850 template <class VertexType> 849 template <class VertexType>
851 bool check_bounds(GrDrawState* drawState, const SkRect& devBounds, void* vertice s, int vCount) 850 bool check_bounds(GrDrawState* drawState, const SkRect& devBounds, void* vertice s, int vCount)
852 { 851 {
853 SkRect tolDevBounds = devBounds; 852 SkRect tolDevBounds = devBounds;
(...skipping 23 matching lines...) Expand all
877 actualBounds.growToInclude(pos.fX, pos.fY); 876 actualBounds.growToInclude(pos.fX, pos.fY);
878 } 877 }
879 } 878 }
880 if (!first) { 879 if (!first) {
881 return tolDevBounds.contains(actualBounds); 880 return tolDevBounds.contains(actualBounds);
882 } 881 }
883 882
884 return true; 883 return true;
885 } 884 }
886 885
887 bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, 886 bool GrAAHairLinePathRenderer::onDrawPath(const SkStrokeRec& stroke,
888 const SkStrokeRec& stroke,
889 GrDrawTarget* target, 887 GrDrawTarget* target,
890 bool antiAlias) { 888 bool antiAlias) {
891 GrDrawState* drawState = target->drawState(); 889 GrDrawState* drawState = target->drawState();
892 890
893 SkScalar hairlineCoverage; 891 SkScalar hairlineCoverage;
894 if (IsStrokeHairlineOrEquivalent(stroke, 892 if (IsStrokeHairlineOrEquivalent(stroke,
895 target->getDrawState().getViewMatrix(), 893 target->getDrawState().getViewMatrix(),
896 &hairlineCoverage)) { 894 &hairlineCoverage)) {
897 uint8_t newCoverage = SkScalarRoundToInt(hairlineCoverage * 895 uint8_t newCoverage = SkScalarRoundToInt(hairlineCoverage *
898 target->getDrawState().getCover age()); 896 target->getDrawState().getCover age());
899 target->drawState()->setCoverage(newCoverage); 897 target->drawState()->setCoverage(newCoverage);
900 } 898 }
901 899
902 SkIRect devClipBounds; 900 SkIRect devClipBounds;
903 target->getClip()->getConservativeBounds(drawState->getRenderTarget(), &devC lipBounds); 901 target->getClip()->getConservativeBounds(drawState->getRenderTarget(), &devC lipBounds);
904 902
905 int lineCnt; 903 int lineCnt;
906 int quadCnt; 904 int quadCnt;
907 int conicCnt; 905 int conicCnt;
908 PREALLOC_PTARRAY(128) lines; 906 PREALLOC_PTARRAY(128) lines;
909 PREALLOC_PTARRAY(128) quads; 907 PREALLOC_PTARRAY(128) quads;
910 PREALLOC_PTARRAY(128) conics; 908 PREALLOC_PTARRAY(128) conics;
911 IntArray qSubdivs; 909 IntArray qSubdivs;
912 FloatArray cWeights; 910 FloatArray cWeights;
913 quadCnt = generate_lines_and_quads(path, drawState->getViewMatrix(), devClip Bounds, 911 quadCnt = generate_lines_and_quads(this->path(), drawState->getViewMatrix(), devClipBounds,
914 &lines, &quads, &conics, &qSubdivs, &cWei ghts); 912 &lines, &quads, &conics, &qSubdivs, &cWei ghts);
915 lineCnt = lines.count() / 2; 913 lineCnt = lines.count() / 2;
916 conicCnt = conics.count() / 3; 914 conicCnt = conics.count() / 3;
917 915
918 // do lines first 916 // do lines first
919 if (lineCnt) { 917 if (lineCnt) {
920 GrDrawTarget::AutoReleaseGeometry arg; 918 GrDrawTarget::AutoReleaseGeometry arg;
921 SkRect devBounds; 919 SkRect devBounds;
922 920
923 if (!this->createLineGeom(path, 921 if (!this->createLineGeom(this->path(),
924 target, 922 target,
925 lines, 923 lines,
926 lineCnt, 924 lineCnt,
927 &arg, 925 &arg,
928 &devBounds)) { 926 &devBounds)) {
929 return false; 927 return false;
930 } 928 }
931 929
932 GrDrawTarget::AutoStateRestore asr; 930 GrDrawTarget::AutoStateRestore asr;
933 931
(...skipping 25 matching lines...) Expand all
959 lines += n; 957 lines += n;
960 } 958 }
961 } 959 }
962 } 960 }
963 961
964 // then quadratics/conics 962 // then quadratics/conics
965 if (quadCnt || conicCnt) { 963 if (quadCnt || conicCnt) {
966 GrDrawTarget::AutoReleaseGeometry arg; 964 GrDrawTarget::AutoReleaseGeometry arg;
967 SkRect devBounds; 965 SkRect devBounds;
968 966
969 if (!this->createBezierGeom(path, 967 if (!this->createBezierGeom(this->path(),
970 target, 968 target,
971 quads, 969 quads,
972 quadCnt, 970 quadCnt,
973 conics, 971 conics,
974 conicCnt, 972 conicCnt,
975 qSubdivs, 973 qSubdivs,
976 cWeights, 974 cWeights,
977 &arg, 975 &arg,
978 &devBounds)) { 976 &devBounds)) {
979 return false; 977 return false;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 &devBounds); 1031 &devBounds);
1034 conics += n; 1032 conics += n;
1035 } 1033 }
1036 } 1034 }
1037 } 1035 }
1038 1036
1039 target->resetIndexSource(); 1037 target->resetIndexSource();
1040 1038
1041 return true; 1039 return true;
1042 } 1040 }
OLDNEW
« no previous file with comments | « src/gpu/GrAAHairLinePathRenderer.h ('k') | src/gpu/GrClipMaskManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698