OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
10 | 10 |
11 #include "GrContext.h" | 11 #include "GrContext.h" |
12 #include "GrDrawState.h" | |
13 #include "GrDrawTargetCaps.h" | 12 #include "GrDrawTargetCaps.h" |
14 #include "GrGeometryProcessor.h" | 13 #include "GrGeometryProcessor.h" |
15 #include "GrInvariantOutput.h" | 14 #include "GrInvariantOutput.h" |
| 15 #include "GrPathUtils.h" |
16 #include "GrProcessor.h" | 16 #include "GrProcessor.h" |
17 #include "GrPathUtils.h" | 17 #include "GrPipelineBuilder.h" |
18 #include "SkGeometry.h" | 18 #include "SkGeometry.h" |
19 #include "SkString.h" | 19 #include "SkString.h" |
20 #include "SkStrokeRec.h" | 20 #include "SkStrokeRec.h" |
21 #include "SkTraceEvent.h" | 21 #include "SkTraceEvent.h" |
22 #include "gl/GrGLProcessor.h" | 22 #include "gl/GrGLProcessor.h" |
23 #include "gl/GrGLSL.h" | 23 #include "gl/GrGLSL.h" |
24 #include "gl/GrGLGeometryProcessor.h" | 24 #include "gl/GrGLGeometryProcessor.h" |
25 #include "gl/builders/GrGLProgramBuilder.h" | 25 #include "gl/builders/GrGLProgramBuilder.h" |
26 | 26 |
27 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { | 27 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 GrTexture*[]) { | 687 GrTexture*[]) { |
688 // Doesn't work without derivative instructions. | 688 // Doesn't work without derivative instructions. |
689 return caps.shaderDerivativeSupport() ? | 689 return caps.shaderDerivativeSupport() ? |
690 QuadEdgeEffect::Create(GrRandomColor(random), | 690 QuadEdgeEffect::Create(GrRandomColor(random), |
691 GrProcessorUnitTest::TestMatrix(random)) : NUL
L; | 691 GrProcessorUnitTest::TestMatrix(random)) : NUL
L; |
692 } | 692 } |
693 | 693 |
694 /////////////////////////////////////////////////////////////////////////////// | 694 /////////////////////////////////////////////////////////////////////////////// |
695 | 695 |
696 bool GrAAConvexPathRenderer::canDrawPath(const GrDrawTarget* target, | 696 bool GrAAConvexPathRenderer::canDrawPath(const GrDrawTarget* target, |
697 const GrDrawState*, | 697 const GrPipelineBuilder*, |
698 const SkMatrix& viewMatrix, | 698 const SkMatrix& viewMatrix, |
699 const SkPath& path, | 699 const SkPath& path, |
700 const SkStrokeRec& stroke, | 700 const SkStrokeRec& stroke, |
701 bool antiAlias) const { | 701 bool antiAlias) const { |
702 return (target->caps()->shaderDerivativeSupport() && antiAlias && | 702 return (target->caps()->shaderDerivativeSupport() && antiAlias && |
703 stroke.isFillStyle() && !path.isInverseFillType() && path.isConvex()
); | 703 stroke.isFillStyle() && !path.isInverseFillType() && path.isConvex()
); |
704 } | 704 } |
705 | 705 |
706 bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target, | 706 bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target, |
707 GrDrawState* drawState, | 707 GrPipelineBuilder* pipelineBuilder, |
708 GrColor color, | 708 GrColor color, |
709 const SkMatrix& vm, | 709 const SkMatrix& vm, |
710 const SkPath& origPath, | 710 const SkPath& origPath, |
711 const SkStrokeRec&, | 711 const SkStrokeRec&, |
712 bool antiAlias) { | 712 bool antiAlias) { |
713 | 713 |
714 const SkPath* path = &origPath; | 714 const SkPath* path = &origPath; |
715 if (path->isEmpty()) { | 715 if (path->isEmpty()) { |
716 return true; | 716 return true; |
717 } | 717 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 actualBounds.set(verts[0].fPos, verts[1].fPos); | 775 actualBounds.set(verts[0].fPos, verts[1].fPos); |
776 for (int i = 2; i < vCount; ++i) { | 776 for (int i = 2; i < vCount; ++i) { |
777 actualBounds.growToInclude(verts[i].fPos.fX, verts[i].fPos.fY); | 777 actualBounds.growToInclude(verts[i].fPos.fX, verts[i].fPos.fY); |
778 } | 778 } |
779 SkASSERT(tolDevBounds.contains(actualBounds)); | 779 SkASSERT(tolDevBounds.contains(actualBounds)); |
780 #endif | 780 #endif |
781 | 781 |
782 int vOffset = 0; | 782 int vOffset = 0; |
783 for (int i = 0; i < draws.count(); ++i) { | 783 for (int i = 0; i < draws.count(); ++i) { |
784 const Draw& draw = draws[i]; | 784 const Draw& draw = draws[i]; |
785 target->drawIndexed(drawState, | 785 target->drawIndexed(pipelineBuilder, |
786 quadProcessor, | 786 quadProcessor, |
787 kTriangles_GrPrimitiveType, | 787 kTriangles_GrPrimitiveType, |
788 vOffset, // start vertex | 788 vOffset, // start vertex |
789 0, // start index | 789 0, // start index |
790 draw.fVertexCnt, | 790 draw.fVertexCnt, |
791 draw.fIndexCnt, | 791 draw.fIndexCnt, |
792 &devBounds); | 792 &devBounds); |
793 vOffset += draw.fVertexCnt; | 793 vOffset += draw.fVertexCnt; |
794 } | 794 } |
795 | 795 |
796 return true; | 796 return true; |
797 } | 797 } |
OLD | NEW |