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

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

Issue 23440049: Implement stroking a path with nv_path_rendering (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 /* 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 9
10 #include "GrStencilAndCoverPathRenderer.h" 10 #include "GrStencilAndCoverPathRenderer.h"
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() { 33 GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() {
34 fGpu->unref(); 34 fGpu->unref();
35 } 35 }
36 36
37 bool GrStencilAndCoverPathRenderer::canDrawPath(const SkPath& path, 37 bool GrStencilAndCoverPathRenderer::canDrawPath(const SkPath& path,
38 const SkStrokeRec& stroke, 38 const SkStrokeRec& stroke,
39 const GrDrawTarget* target, 39 const GrDrawTarget* target,
40 bool antiAlias) const { 40 bool antiAlias) const {
41 return stroke.isFillStyle() && 41 return !stroke.isHairlineStyle() &&
42 !antiAlias && // doesn't do per-path AA, relies on the target having MSAA 42 !antiAlias && // doesn't do per-path AA, relies on the target having MSAA
43 !target->getDrawState().willEffectReadDstColor() && // not supported yet 43 !target->getDrawState().willEffectReadDstColor() && // not supported yet
44 NULL != target->getDrawState().getRenderTarget()->getStencilBuffer() && 44 NULL != target->getDrawState().getRenderTarget()->getStencilBuffer() &&
45 target->getDrawState().getStencil().isDisabled(); 45 target->getDrawState().getStencil().isDisabled();
46 } 46 }
47 47
48 GrPathRenderer::StencilSupport GrStencilAndCoverPathRenderer::onGetStencilSuppor t( 48 GrPathRenderer::StencilSupport GrStencilAndCoverPathRenderer::onGetStencilSuppor t(
49 const SkPath&, 49 const SkPath&,
50 const SkStrokeRec& , 50 const SkStrokeRec& ,
51 const GrDrawTarget*) con st { 51 const GrDrawTarget*) con st {
52 return GrPathRenderer::kStencilOnly_StencilSupport; 52 return GrPathRenderer::kStencilOnly_StencilSupport;
53 } 53 }
54 54
55 void GrStencilAndCoverPathRenderer::onStencilPath(const SkPath& path, 55 void GrStencilAndCoverPathRenderer::onStencilPath(const SkPath& path,
56 const SkStrokeRec& stroke, 56 const SkStrokeRec& stroke,
57 GrDrawTarget* target) { 57 GrDrawTarget* target) {
58 SkASSERT(!path.isInverseFillType()); 58 SkASSERT(!path.isInverseFillType());
59 SkAutoTUnref<GrPath> p(fGpu->createPath(path)); 59 SkAutoTUnref<GrPath> p(fGpu->createPath(path, stroke));
60 target->stencilPath(p, stroke, path.getFillType()); 60 target->stencilPath(p, stroke, path.getFillType());
61 } 61 }
62 62
63 bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path, 63 bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path,
64 const SkStrokeRec& stroke, 64 const SkStrokeRec& stroke,
65 GrDrawTarget* target, 65 GrDrawTarget* target,
66 bool antiAlias) { 66 bool antiAlias) {
67 SkASSERT(!antiAlias); 67 SkASSERT(!antiAlias);
68 SkASSERT(!stroke.isHairlineStyle()); 68 SkASSERT(!stroke.isHairlineStyle());
69 69
70 GrDrawState* drawState = target->drawState(); 70 GrDrawState* drawState = target->drawState();
71 SkASSERT(drawState->getStencil().isDisabled()); 71 SkASSERT(drawState->getStencil().isDisabled());
72 72
73 SkAutoTUnref<GrPath> p(fGpu->createPath(path)); 73 SkAutoTUnref<GrPath> p(fGpu->createPath(path, stroke));
74 74
75 if (path.isInverseFillType()) { 75 if (path.isInverseFillType()) {
76 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, 76 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass,
77 kZero_StencilOp, 77 kZero_StencilOp,
78 kZero_StencilOp, 78 kZero_StencilOp,
79 // We know our rect will hit pixels outside the clip and the user bi ts will be 0 79 // We know our rect will hit pixels outside the clip and the user bi ts will be 0
80 // outside the clip. So we can't just fill where the user bits are 0 . We also need to 80 // outside the clip. So we can't just fill where the user bits are 0 . We also need to
81 // check that the clip bit is set. 81 // check that the clip bit is set.
82 kEqualIfInClip_StencilFunc, 82 kEqualIfInClip_StencilFunc,
83 0xffff, 83 0xffff,
84 0x0000, 84 0x0000,
85 0xffff); 85 0xffff);
86 86
87 *drawState->stencil() = kInvertedStencilPass; 87 *drawState->stencil() = kInvertedStencilPass;
88 } else { 88 } else {
89 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, 89 GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
90 kZero_StencilOp, 90 kZero_StencilOp,
91 kZero_StencilOp, 91 kZero_StencilOp,
92 kNotEqual_StencilFunc, 92 kNotEqual_StencilFunc,
93 0xffff, 93 0xffff,
94 0x0000, 94 0x0000,
95 0xffff); 95 0xffff);
96 96
97 *drawState->stencil() = kStencilPass; 97 *drawState->stencil() = kStencilPass;
98 } 98 }
99 99
100 target->fillPath(p, stroke, path.getFillType()); 100 target->drawPath(p, stroke, path.getFillType());
101 101
102 target->drawState()->stencil()->setDisabled(); 102 target->drawState()->stencil()->setDisabled();
103 return true; 103 return true;
104 } 104 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/gl/GrGLPath.h » ('j') | src/gpu/gl/GrGLPath.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698