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

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

Issue 1107973004: Pull cache out of GrContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixpicturerenderer.cpp Created 5 years, 7 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
« no previous file with comments | « src/gpu/GrSWMaskHelper.cpp ('k') | src/gpu/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrDrawTargetCaps.h" 12 #include "GrDrawTargetCaps.h"
13 #include "GrGpu.h" 13 #include "GrGpu.h"
14 #include "GrPath.h" 14 #include "GrPath.h"
15 #include "GrRenderTarget.h" 15 #include "GrRenderTarget.h"
16 #include "GrRenderTargetPriv.h" 16 #include "GrRenderTargetPriv.h"
17 #include "GrResourceProvider.h"
17 #include "GrStrokeInfo.h" 18 #include "GrStrokeInfo.h"
18 19
19 /* 20 /*
20 * For now paths only natively support winding and even odd fill types 21 * For now paths only natively support winding and even odd fill types
21 */ 22 */
22 static GrPathRendering::FillType convert_skpath_filltype(SkPath::FillType fill) { 23 static GrPathRendering::FillType convert_skpath_filltype(SkPath::FillType fill) {
23 switch (fill) { 24 switch (fill) {
24 default: 25 default:
25 SkFAIL("Incomplete Switch\n"); 26 SkFAIL("Incomplete Switch\n");
26 case SkPath::kWinding_FillType: 27 case SkPath::kWinding_FillType:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const GrPipelineBuilder*, 70 const GrPipelineBuilder*,
70 const SkPath&, 71 const SkPath&,
71 const GrStrokeInfo&) const { 72 const GrStrokeInfo&) const {
72 return GrPathRenderer::kStencilOnly_StencilSupport; 73 return GrPathRenderer::kStencilOnly_StencilSupport;
73 } 74 }
74 75
75 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec& stroke) { 76 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec& stroke) {
76 GrContext* ctx = gpu->getContext(); 77 GrContext* ctx = gpu->getContext();
77 GrUniqueKey key; 78 GrUniqueKey key;
78 GrPath::ComputeKey(skPath, stroke, &key); 79 GrPath::ComputeKey(skPath, stroke, &key);
79 SkAutoTUnref<GrPath> path(static_cast<GrPath*>(ctx->findAndRefCachedResource (key))); 80 SkAutoTUnref<GrPath> path(
81 static_cast<GrPath*>(ctx->resourceProvider()->findAndRefResourceByUnique Key(key)));
80 if (NULL == path || !path->isEqualTo(skPath, stroke)) { 82 if (NULL == path || !path->isEqualTo(skPath, stroke)) {
81 path.reset(gpu->pathRendering()->createPath(skPath, stroke)); 83 path.reset(gpu->pathRendering()->createPath(skPath, stroke));
82 ctx->addResourceToCache(key, path); 84 ctx->resourceProvider()->assignUniqueKeyToResource(key, path);
83 } 85 }
84 return path.detach(); 86 return path.detach();
85 } 87 }
86 88
87 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, 89 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target,
88 GrPipelineBuilder* pipelineBui lder, 90 GrPipelineBuilder* pipelineBui lder,
89 const SkMatrix& viewMatrix, 91 const SkMatrix& viewMatrix,
90 const SkPath& path, 92 const SkPath& path,
91 const GrStrokeInfo& stroke) { 93 const GrStrokeInfo& stroke) {
92 SkASSERT(!path.isInverseFillType()); 94 SkASSERT(!path.isInverseFillType());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 0xffff); 158 0xffff);
157 159
158 pipelineBuilder->setStencil(kStencilPass); 160 pipelineBuilder->setStencil(kStencilPass);
159 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr ix)); 161 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr ix));
160 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge tFillType())); 162 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge tFillType()));
161 } 163 }
162 164
163 pipelineBuilder->stencil()->setDisabled(); 165 pipelineBuilder->stencil()->setDisabled();
164 return true; 166 return true;
165 } 167 }
OLDNEW
« no previous file with comments | « src/gpu/GrSWMaskHelper.cpp ('k') | src/gpu/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698