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

Side by Side Diff: src/gpu/gl/GrGLPathRange.cpp

Issue 1116123003: Improve caching of dashed paths in GrStencilAndCoverPathRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@dashing-nvpr-01
Patch Set: 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/gl/GrGLPathRange.h ('k') | src/gpu/gl/GrGLPathRendering.h » ('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 2014 Google Inc. 3 * Copyright 2014 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 "GrGLPathRange.h" 9 #include "GrGLPathRange.h"
10 #include "GrGLPath.h" 10 #include "GrGLPath.h"
11 #include "GrGLPathRendering.h" 11 #include "GrGLPathRendering.h"
12 #include "GrGLGpu.h" 12 #include "GrGLGpu.h"
13 13
14 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const S kStrokeRec& stroke) 14 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const G rStrokeInfo& stroke)
15 : INHERITED(gpu, pathGenerator, stroke), 15 : INHERITED(gpu, pathGenerator),
16 fStroke(stroke),
16 fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())), 17 fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())),
17 fGpuMemorySize(0) { 18 fGpuMemorySize(0) {
19 this->init();
18 this->registerWithCache(); 20 this->registerWithCache();
19 } 21 }
20 22
21 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, 23 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu,
22 GrGLuint basePathID, 24 GrGLuint basePathID,
23 int numPaths, 25 int numPaths,
24 size_t gpuMemorySize, 26 size_t gpuMemorySize,
25 const SkStrokeRec& stroke) 27 const GrStrokeInfo& stroke)
26 : INHERITED(gpu, numPaths, stroke), 28 : INHERITED(gpu, numPaths),
29 fStroke(stroke),
27 fBasePathID(basePathID), 30 fBasePathID(basePathID),
28 fGpuMemorySize(gpuMemorySize) { 31 fGpuMemorySize(gpuMemorySize) {
32 this->init();
29 this->registerWithCache(); 33 this->registerWithCache();
30 } 34 }
31 35
32 void GrGLPathRange::onInitPath(int index, const SkPath& skPath) const { 36 void GrGLPathRange::init() {
37 if (fStroke.isDashed()) {
38 fShouldStroke = false;
39 fShouldFill = true;
40 } else {
41 fShouldStroke = fStroke.needToApply();
42 fShouldFill = fStroke.isFillStyle() ||
43 fStroke.getStyle() == SkStrokeRec::kStrokeAndFill_Style;
44 }
45 }
46
47 void GrGLPathRange::onInitPath(int index, const SkPath& origSkPath) const {
33 GrGLGpu* gpu = static_cast<GrGLGpu*>(this->getGpu()); 48 GrGLGpu* gpu = static_cast<GrGLGpu*>(this->getGpu());
34 if (NULL == gpu) { 49 if (NULL == gpu) {
35 return; 50 return;
36 } 51 }
37 52
38 // Make sure the path at this index hasn't been initted already. 53 // Make sure the path at this index hasn't been initted already.
39 SkDEBUGCODE( 54 SkDEBUGCODE(
40 GrGLboolean isPath; 55 GrGLboolean isPath;
41 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index))) ; 56 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index))) ;
42 SkASSERT(GR_GL_FALSE == isPath); 57 SkASSERT(GR_GL_FALSE == isPath);
43 58
44 GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, this->getStroke() ); 59 const SkPath* skPath = &origSkPath;
60 SkTLazy<SkPath> tmpPath;
61 const GrStrokeInfo* stroke = &fStroke;
62 GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle);
63
64 // Dashing must be applied to the path. However, if dashing is present,
65 // we must convert all the paths to fills. The GrStrokeInfo::applyDash leave s
66 // simple paths as strokes but converts other paths to fills.
67 // Thus we must stroke the strokes here, so that all paths in the
68 // path range are using the same style.
69 if (fStroke.isDashed()) {
70 if (!stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) {
71 return;
72 }
73 skPath = tmpPath.get();
74 stroke = &tmpStroke;
75 if (tmpStroke.needToApply()) {
76 if (!tmpStroke.applyToPath(tmpPath.get(), *tmpPath.get())) {
77 return;
78 }
79 tmpStroke.setFillStyle();
80 }
81 }
82
83 GrGLPath::InitPathObject(gpu, fBasePathID + index, *skPath, *stroke);
45 84
46 // TODO: Use a better approximation for the individual path sizes. 85 // TODO: Use a better approximation for the individual path sizes.
47 fGpuMemorySize += 100; 86 fGpuMemorySize += 100;
48 } 87 }
49 88
50 void GrGLPathRange::onRelease() { 89 void GrGLPathRange::onRelease() {
51 SkASSERT(this->getGpu()); 90 SkASSERT(this->getGpu());
52 91
53 if (0 != fBasePathID && !this->isWrapped()) { 92 if (0 != fBasePathID && !this->isWrapped()) {
54 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fB asePathID, 93 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fB asePathID,
55 th is->getNumPaths()); 94 th is->getNumPaths());
56 fBasePathID = 0; 95 fBasePathID = 0;
57 } 96 }
58 97
59 INHERITED::onRelease(); 98 INHERITED::onRelease();
60 } 99 }
61 100
62 void GrGLPathRange::onAbandon() { 101 void GrGLPathRange::onAbandon() {
63 fBasePathID = 0; 102 fBasePathID = 0;
64 103
65 INHERITED::onAbandon(); 104 INHERITED::onAbandon();
66 } 105 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLPathRange.h ('k') | src/gpu/gl/GrGLPathRendering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698