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

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

Issue 1967513002: Revert of Replace GrStrokeInfo with GrStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@resscale
Patch Set: Created 4 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 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLPathRange.h" 8 #include "GrGLPathRange.h"
9 #include "GrGLPath.h" 9 #include "GrGLPath.h"
10 #include "GrGLPathRendering.h" 10 #include "GrGLPathRendering.h"
11 #include "GrGLGpu.h" 11 #include "GrGLGpu.h"
12 12
13 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const G rStyle& style) 13 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const G rStrokeInfo& stroke)
14 : INHERITED(gpu, pathGenerator), 14 : INHERITED(gpu, pathGenerator),
15 fStyle(style), 15 fStroke(stroke),
16 fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())), 16 fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())),
17 fGpuMemorySize(0) { 17 fGpuMemorySize(0) {
18 this->init(); 18 this->init();
19 this->registerWithCache(SkBudgeted::kYes); 19 this->registerWithCache(SkBudgeted::kYes);
20 } 20 }
21 21
22 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, 22 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu,
23 GrGLuint basePathID, 23 GrGLuint basePathID,
24 int numPaths, 24 int numPaths,
25 size_t gpuMemorySize, 25 size_t gpuMemorySize,
26 const GrStyle& style) 26 const GrStrokeInfo& stroke)
27 : INHERITED(gpu, numPaths), 27 : INHERITED(gpu, numPaths),
28 fStyle(style), 28 fStroke(stroke),
29 fBasePathID(basePathID), 29 fBasePathID(basePathID),
30 fGpuMemorySize(gpuMemorySize) { 30 fGpuMemorySize(gpuMemorySize) {
31 this->init(); 31 this->init();
32 this->registerWithCache(SkBudgeted::kYes); 32 this->registerWithCache(SkBudgeted::kYes);
33 } 33 }
34 34
35 void GrGLPathRange::init() { 35 void GrGLPathRange::init() {
36 const SkStrokeRec& stroke = fStyle.strokeRec();
37 // Must force fill: 36 // Must force fill:
38 // * dashing: NVPR stroke dashing is different to Skia. 37 // * dashing: NVPR stroke dashing is different to Skia.
39 // * end caps: NVPR stroking degenerate contours with end caps is different to Skia. 38 // * end caps: NVPR stroking degenerate contours with end caps is different to Skia.
40 bool forceFill = fStyle.pathEffect() || 39 bool forceFill = fStroke.isDashed() ||
41 (stroke.needToApply() && stroke.getCap() != SkPaint::kButt_Cap); 40 (fStroke.needToApply() && fStroke.getCap() != SkPaint::kButt_Cap);
42 41
43 if (forceFill) { 42 if (forceFill) {
44 fShouldStroke = false; 43 fShouldStroke = false;
45 fShouldFill = true; 44 fShouldFill = true;
46 } else { 45 } else {
47 fShouldStroke = stroke.needToApply(); 46 fShouldStroke = fStroke.needToApply();
48 fShouldFill = stroke.isFillStyle() || 47 fShouldFill = fStroke.isFillStyle() ||
49 stroke.getStyle() == SkStrokeRec::kStrokeAndFill_Style; 48 fStroke.getStyle() == SkStrokeRec::kStrokeAndFill_Style;
50 } 49 }
51 } 50 }
52 51
53 void GrGLPathRange::onInitPath(int index, const SkPath& origSkPath) const { 52 void GrGLPathRange::onInitPath(int index, const SkPath& origSkPath) const {
54 GrGLGpu* gpu = static_cast<GrGLGpu*>(this->getGpu()); 53 GrGLGpu* gpu = static_cast<GrGLGpu*>(this->getGpu());
55 if (nullptr == gpu) { 54 if (nullptr == gpu) {
56 return; 55 return;
57 } 56 }
57
58 // Make sure the path at this index hasn't been initted already. 58 // Make sure the path at this index hasn't been initted already.
59 SkDEBUGCODE( 59 SkDEBUGCODE(
60 GrGLboolean isPath; 60 GrGLboolean isPath;
61 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index))) ; 61 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index))) ;
62 SkASSERT(GR_GL_FALSE == isPath); 62 SkASSERT(GR_GL_FALSE == isPath);
63 63
64 if (origSkPath.isEmpty()) { 64 if (origSkPath.isEmpty()) {
65 GrGLPath::InitPathObjectEmptyPath(gpu, fBasePathID + index); 65 GrGLPath::InitPathObjectEmptyPath(gpu, fBasePathID + index);
66 } else if (fShouldStroke) { 66 } else if (fShouldStroke) {
67 GrGLPath::InitPathObjectPathData(gpu, fBasePathID + index, origSkPath); 67 GrGLPath::InitPathObjectPathData(gpu, fBasePathID + index, origSkPath);
68 GrGLPath::InitPathObjectStroke(gpu, fBasePathID + index, fStyle.strokeRe c()); 68 GrGLPath::InitPathObjectStroke(gpu, fBasePathID + index, fStroke);
69 } else { 69 } else {
70 const SkPath* skPath = &origSkPath; 70 const SkPath* skPath = &origSkPath;
71 SkTLazy<SkPath> tmpPath; 71 SkTLazy<SkPath> tmpPath;
72 if (!fStyle.isSimpleFill()) { 72 const GrStrokeInfo* stroke = &fStroke;
73 SkStrokeRec::InitStyle fill; 73 GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle);
74 // The path effect must be applied to the path. However, if a path e ffect is present, 74
75 // we must convert all the paths to fills. The path effect applicati on may leave 75 // Dashing must be applied to the path. However, if dashing is present,
76 // simple paths as strokes but converts other paths to fills. 76 // we must convert all the paths to fills. The GrStrokeInfo::applyDash l eaves
77 // Thus we must stroke the strokes here, so that all paths in the 77 // simple paths as strokes but converts other paths to fills.
78 // path range are using the same style. 78 // Thus we must stroke the strokes here, so that all paths in the
79 if (!fStyle.applyToPath(tmpPath.init(), &fill, *skPath, SK_Scalar1)) { 79 // path range are using the same style.
80 if (fStroke.isDashed()) {
81 if (!stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) {
80 return; 82 return;
81 } 83 }
82 // We shouldn't have allowed hairlines or arbitrary path effect styl es to get here
83 // so after application we better have a filled path.
84 SkASSERT(SkStrokeRec::kFill_InitStyle == fill);
85 skPath = tmpPath.get(); 84 skPath = tmpPath.get();
86 85 stroke = &tmpStroke;
86 }
87 if (stroke->needToApply()) {
88 if (!tmpPath.isValid()) {
89 tmpPath.init();
90 }
91 if (!stroke->applyToPath(tmpPath.get(), *tmpPath.get())) {
92 return;
93 }
87 } 94 }
88 GrGLPath::InitPathObjectPathData(gpu, fBasePathID + index, *skPath); 95 GrGLPath::InitPathObjectPathData(gpu, fBasePathID + index, *skPath);
89 } 96 }
90 // TODO: Use a better approximation for the individual path sizes. 97 // TODO: Use a better approximation for the individual path sizes.
91 fGpuMemorySize += 100; 98 fGpuMemorySize += 100;
92 } 99 }
93 100
94 void GrGLPathRange::onRelease() { 101 void GrGLPathRange::onRelease() {
95 SkASSERT(this->getGpu()); 102 SkASSERT(this->getGpu());
96 103
97 if (0 != fBasePathID) { 104 if (0 != fBasePathID) {
98 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fB asePathID, 105 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fB asePathID,
99 th is->getNumPaths()); 106 th is->getNumPaths());
100 fBasePathID = 0; 107 fBasePathID = 0;
101 } 108 }
102 109
103 INHERITED::onRelease(); 110 INHERITED::onRelease();
104 } 111 }
105 112
106 void GrGLPathRange::onAbandon() { 113 void GrGLPathRange::onAbandon() {
107 fBasePathID = 0; 114 fBasePathID = 0;
108 115
109 INHERITED::onAbandon(); 116 INHERITED::onAbandon();
110 } 117 }
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