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

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

Issue 23926019: Stateful PathRenderer implementation (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: clean up 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
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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts, devBounds); 812 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts, devBounds);
813 } 813 }
814 814
815 // Start Conics 815 // Start Conics
816 for (int i = 0; i < conicCnt; ++i) { 816 for (int i = 0; i < conicCnt; ++i) {
817 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts, devBounds ); 817 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts, devBounds );
818 } 818 }
819 return true; 819 return true;
820 } 820 }
821 821
822 bool GrAAHairLinePathRenderer::canDrawPath(const SkPath& path, 822 bool GrAAHairLinePathRenderer::canDrawPath(const SkStrokeRec& stroke,
823 const SkStrokeRec& stroke,
824 const GrDrawTarget* target, 823 const GrDrawTarget* target,
825 bool antiAlias) const { 824 bool antiAlias) const {
826 if (!stroke.isHairlineStyle() || !antiAlias) { 825 if (!stroke.isHairlineStyle() || !antiAlias) {
827 return false; 826 return false;
828 } 827 }
829 828
830 if (SkPath::kLine_SegmentMask == path.getSegmentMasks() || 829 if (SkPath::kLine_SegmentMask == fPath.getSegmentMasks() ||
831 target->caps()->shaderDerivativeSupport()) { 830 target->caps()->shaderDerivativeSupport()) {
832 return true; 831 return true;
833 } 832 }
834 return false; 833 return false;
835 } 834 }
836 835
837 template <class VertexType> 836 template <class VertexType>
838 bool check_bounds(GrDrawState* drawState, const SkRect& devBounds, void* vertice s, int vCount) 837 bool check_bounds(GrDrawState* drawState, const SkRect& devBounds, void* vertice s, int vCount)
839 { 838 {
840 SkRect tolDevBounds = devBounds; 839 SkRect tolDevBounds = devBounds;
(...skipping 23 matching lines...) Expand all
864 actualBounds.growToInclude(pos.fX, pos.fY); 863 actualBounds.growToInclude(pos.fX, pos.fY);
865 } 864 }
866 } 865 }
867 if (!first) { 866 if (!first) {
868 return tolDevBounds.contains(actualBounds); 867 return tolDevBounds.contains(actualBounds);
869 } 868 }
870 869
871 return true; 870 return true;
872 } 871 }
873 872
874 bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, 873 bool GrAAHairLinePathRenderer::onDrawPath(const SkStrokeRec&,
875 const SkStrokeRec&,
876 GrDrawTarget* target, 874 GrDrawTarget* target,
877 bool antiAlias) { 875 bool antiAlias) {
878 876
879 GrDrawState* drawState = target->drawState(); 877 GrDrawState* drawState = target->drawState();
880 878
881 SkIRect devClipBounds; 879 SkIRect devClipBounds;
882 target->getClip()->getConservativeBounds(drawState->getRenderTarget(), &devC lipBounds); 880 target->getClip()->getConservativeBounds(drawState->getRenderTarget(), &devC lipBounds);
883 881
884 int lineCnt; 882 int lineCnt;
885 int quadCnt; 883 int quadCnt;
886 int conicCnt; 884 int conicCnt;
887 PREALLOC_PTARRAY(128) lines; 885 PREALLOC_PTARRAY(128) lines;
888 PREALLOC_PTARRAY(128) quads; 886 PREALLOC_PTARRAY(128) quads;
889 PREALLOC_PTARRAY(128) conics; 887 PREALLOC_PTARRAY(128) conics;
890 IntArray qSubdivs; 888 IntArray qSubdivs;
891 FloatArray cWeights; 889 FloatArray cWeights;
892 quadCnt = generate_lines_and_quads(path, drawState->getViewMatrix(), devClip Bounds, 890 quadCnt = generate_lines_and_quads(fPath, drawState->getViewMatrix(), devCli pBounds,
893 &lines, &quads, &conics, &qSubdivs, &cWei ghts); 891 &lines, &quads, &conics, &qSubdivs, &cWei ghts);
894 lineCnt = lines.count() / 2; 892 lineCnt = lines.count() / 2;
895 conicCnt = conics.count() / 3; 893 conicCnt = conics.count() / 3;
896 894
897 // do lines first 895 // do lines first
898 if (lineCnt) { 896 if (lineCnt) {
899 GrDrawTarget::AutoReleaseGeometry arg; 897 GrDrawTarget::AutoReleaseGeometry arg;
900 SkRect devBounds; 898 SkRect devBounds;
901 899
902 if (!this->createLineGeom(path, 900 if (!this->createLineGeom(fPath,
903 target, 901 target,
904 lines, 902 lines,
905 lineCnt, 903 lineCnt,
906 &arg, 904 &arg,
907 &devBounds)) { 905 &devBounds)) {
908 return false; 906 return false;
909 } 907 }
910 908
911 GrDrawTarget::AutoStateRestore asr; 909 GrDrawTarget::AutoStateRestore asr;
912 910
(...skipping 25 matching lines...) Expand all
938 lines += n; 936 lines += n;
939 } 937 }
940 } 938 }
941 } 939 }
942 940
943 // then quadratics/conics 941 // then quadratics/conics
944 if (quadCnt || conicCnt) { 942 if (quadCnt || conicCnt) {
945 GrDrawTarget::AutoReleaseGeometry arg; 943 GrDrawTarget::AutoReleaseGeometry arg;
946 SkRect devBounds; 944 SkRect devBounds;
947 945
948 if (!this->createBezierGeom(path, 946 if (!this->createBezierGeom(fPath,
949 target, 947 target,
950 quads, 948 quads,
951 quadCnt, 949 quadCnt,
952 conics, 950 conics,
953 conicCnt, 951 conicCnt,
954 qSubdivs, 952 qSubdivs,
955 cWeights, 953 cWeights,
956 &arg, 954 &arg,
957 &devBounds)) { 955 &devBounds)) {
958 return false; 956 return false;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 &devBounds); 1010 &devBounds);
1013 conics += n; 1011 conics += n;
1014 } 1012 }
1015 } 1013 }
1016 } 1014 }
1017 1015
1018 target->resetIndexSource(); 1016 target->resetIndexSource();
1019 1017
1020 return true; 1018 return true;
1021 } 1019 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698