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 | 9 |
10 #include "GrStencilAndCoverPathRenderer.h" | 10 #include "GrStencilAndCoverPathRenderer.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, | 68 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, |
69 const GrPipelineBuilder*, | 69 const GrPipelineBuilder*, |
70 const SkPath&, | 70 const SkPath&, |
71 const GrStrokeInfo&) const { | 71 const GrStrokeInfo&) const { |
72 return GrPathRenderer::kStencilOnly_StencilSupport; | 72 return GrPathRenderer::kStencilOnly_StencilSupport; |
73 } | 73 } |
74 | 74 |
75 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const GrStrokeInfo&
stroke) { | 75 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const GrStrokeInfo&
stroke) { |
76 GrContext* ctx = gpu->getContext(); | 76 GrContext* ctx = gpu->getContext(); |
77 GrUniqueKey key; | 77 GrUniqueKey key; |
78 GrPath::ComputeKey(skPath, stroke, &key); | 78 bool isVolatile; |
| 79 GrPath::ComputeKey(skPath, stroke, &key, &isVolatile); |
79 SkAutoTUnref<GrPath> path( | 80 SkAutoTUnref<GrPath> path( |
80 static_cast<GrPath*>(ctx->resourceProvider()->findAndRefResourceByUnique
Key(key))); | 81 static_cast<GrPath*>(ctx->resourceProvider()->findAndRefResourceByUnique
Key(key))); |
81 if (NULL == path) { | 82 if (NULL == path) { |
82 path.reset(gpu->pathRendering()->createPath(skPath, stroke)); | 83 path.reset(gpu->pathRendering()->createPath(skPath, stroke)); |
83 ctx->resourceProvider()->assignUniqueKeyToResource(key, path); | 84 if (!isVolatile) { |
| 85 ctx->resourceProvider()->assignUniqueKeyToResource(key, path); |
| 86 } |
84 } else { | 87 } else { |
85 SkASSERT(path->isEqualTo(skPath, stroke)); | 88 SkASSERT(path->isEqualTo(skPath, stroke)); |
86 } | 89 } |
87 return path.detach(); | 90 return path.detach(); |
88 } | 91 } |
89 | 92 |
90 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, | 93 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, |
91 GrPipelineBuilder* pipelineBui
lder, | 94 GrPipelineBuilder* pipelineBui
lder, |
92 const SkMatrix& viewMatrix, | 95 const SkMatrix& viewMatrix, |
93 const SkPath& path, | 96 const SkPath& path, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 0xffff); | 161 0xffff); |
159 | 162 |
160 pipelineBuilder->setStencil(kStencilPass); | 163 pipelineBuilder->setStencil(kStencilPass); |
161 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr
ix)); | 164 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr
ix)); |
162 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge
tFillType())); | 165 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge
tFillType())); |
163 } | 166 } |
164 | 167 |
165 pipelineBuilder->stencil()->setDisabled(); | 168 pipelineBuilder->stencil()->setDisabled(); |
166 return true; | 169 return true; |
167 } | 170 } |
OLD | NEW |