| OLD | NEW |
| 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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 const SkMatrix* toSrc = NULL; | 752 const SkMatrix* toSrc = NULL; |
| 753 SkMatrix ivm; | 753 SkMatrix ivm; |
| 754 | 754 |
| 755 if (viewM.hasPerspective()) { | 755 if (viewM.hasPerspective()) { |
| 756 if (viewM.invert(&ivm)) { | 756 if (viewM.invert(&ivm)) { |
| 757 toSrc = &ivm; | 757 toSrc = &ivm; |
| 758 } | 758 } |
| 759 } | 759 } |
| 760 devBounds->set(lines.begin(), lines.count()); | 760 devBounds->set(lines.begin(), lines.count()); |
| 761 for (int i = 0; i < lineCnt; ++i) { | 761 for (int i = 0; i < lineCnt; ++i) { |
| 762 add_line(&lines[2*i], toSrc, drawState->getCoverage(), &verts); | 762 add_line(&lines[2*i], toSrc, drawState->getCoverageColor(), &verts); |
| 763 } | 763 } |
| 764 // All the verts computed by add_line are within sqrt(1^2 + 0.5^2) of the en
d points. | 764 // All the verts computed by add_line are within sqrt(1^2 + 0.5^2) of the en
d points. |
| 765 static const SkScalar kSqrtOfOneAndAQuarter = SkFloatToScalar(1.118f); | 765 static const SkScalar kSqrtOfOneAndAQuarter = SkFloatToScalar(1.118f); |
| 766 // Add a little extra to account for vector normalization precision. | 766 // Add a little extra to account for vector normalization precision. |
| 767 static const SkScalar kOutset = kSqrtOfOneAndAQuarter + SK_Scalar1 / 20; | 767 static const SkScalar kOutset = kSqrtOfOneAndAQuarter + SK_Scalar1 / 20; |
| 768 devBounds->outset(kOutset, kOutset); | 768 devBounds->outset(kOutset, kOutset); |
| 769 | 769 |
| 770 return true; | 770 return true; |
| 771 } | 771 } |
| 772 | 772 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 for (int i = 0; i < conicCnt; ++i) { | 832 for (int i = 0; i < conicCnt; ++i) { |
| 833 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts, devBounds
); | 833 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts, devBounds
); |
| 834 } | 834 } |
| 835 return true; | 835 return true; |
| 836 } | 836 } |
| 837 | 837 |
| 838 bool GrAAHairLinePathRenderer::canDrawPath(const SkPath& path, | 838 bool GrAAHairLinePathRenderer::canDrawPath(const SkPath& path, |
| 839 const SkStrokeRec& stroke, | 839 const SkStrokeRec& stroke, |
| 840 const GrDrawTarget* target, | 840 const GrDrawTarget* target, |
| 841 bool antiAlias) const { | 841 bool antiAlias) const { |
| 842 if (!stroke.isHairlineStyle() || !antiAlias) { | 842 if (!antiAlias) { |
| 843 return false; | 843 return false; |
| 844 } | 844 } |
| 845 | 845 |
| 846 if (!IsStrokeHairlineOrEquivalent(stroke, |
| 847 target->getDrawState().getViewMatrix(), |
| 848 NULL)) { |
| 849 return false; |
| 850 } |
| 851 |
| 846 if (SkPath::kLine_SegmentMask == path.getSegmentMasks() || | 852 if (SkPath::kLine_SegmentMask == path.getSegmentMasks() || |
| 847 target->caps()->shaderDerivativeSupport()) { | 853 target->caps()->shaderDerivativeSupport()) { |
| 848 return true; | 854 return true; |
| 849 } | 855 } |
| 850 return false; | 856 return false; |
| 851 } | 857 } |
| 852 | 858 |
| 853 template <class VertexType> | 859 template <class VertexType> |
| 854 bool check_bounds(GrDrawState* drawState, const SkRect& devBounds, void* vertice
s, int vCount) | 860 bool check_bounds(GrDrawState* drawState, const SkRect& devBounds, void* vertice
s, int vCount) |
| 855 { | 861 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 881 } | 887 } |
| 882 } | 888 } |
| 883 if (!first) { | 889 if (!first) { |
| 884 return tolDevBounds.contains(actualBounds); | 890 return tolDevBounds.contains(actualBounds); |
| 885 } | 891 } |
| 886 | 892 |
| 887 return true; | 893 return true; |
| 888 } | 894 } |
| 889 | 895 |
| 890 bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, | 896 bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, |
| 891 const SkStrokeRec&, | 897 const SkStrokeRec& stroke, |
| 892 GrDrawTarget* target, | 898 GrDrawTarget* target, |
| 893 bool antiAlias) { | 899 bool antiAlias) { |
| 900 GrDrawState* drawState = target->drawState(); |
| 894 | 901 |
| 895 GrDrawState* drawState = target->drawState(); | 902 SkScalar hairlineCoverage; |
| 903 if (IsStrokeHairlineOrEquivalent(stroke, |
| 904 target->getDrawState().getViewMatrix(), |
| 905 &hairlineCoverage)) { |
| 906 uint8_t newCoverage = SkScalarRoundToInt(hairlineCoverage * |
| 907 target->getDrawState().getCover
age()); |
| 908 target->drawState()->setCoverage(newCoverage); |
| 909 } |
| 896 | 910 |
| 897 SkIRect devClipBounds; | 911 SkIRect devClipBounds; |
| 898 target->getClip()->getConservativeBounds(drawState->getRenderTarget(), &devC
lipBounds); | 912 target->getClip()->getConservativeBounds(drawState->getRenderTarget(), &devC
lipBounds); |
| 899 | 913 |
| 900 int lineCnt; | 914 int lineCnt; |
| 901 int quadCnt; | 915 int quadCnt; |
| 902 int conicCnt; | 916 int conicCnt; |
| 903 PREALLOC_PTARRAY(128) lines; | 917 PREALLOC_PTARRAY(128) lines; |
| 904 PREALLOC_PTARRAY(128) quads; | 918 PREALLOC_PTARRAY(128) quads; |
| 905 PREALLOC_PTARRAY(128) conics; | 919 PREALLOC_PTARRAY(128) conics; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 &devBounds); | 1042 &devBounds); |
| 1029 conics += n; | 1043 conics += n; |
| 1030 } | 1044 } |
| 1031 } | 1045 } |
| 1032 } | 1046 } |
| 1033 | 1047 |
| 1034 target->resetIndexSource(); | 1048 target->resetIndexSource(); |
| 1035 | 1049 |
| 1036 return true; | 1050 return true; |
| 1037 } | 1051 } |
| OLD | NEW |