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/GrGLPath.cpp

Issue 450283002: Simplify GrGLPathRendering interface (Closed) Base URL: https://skia.googlesource.com/skia.git@02-path-state-to-pathrendering-class
Patch Set: rebase Created 6 years, 4 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 | « no previous file | src/gpu/gl/GrGLPathRange.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 #include "GrGLPath.h" 9 #include "GrGLPath.h"
10 #include "GrGLPathRendering.h" 10 #include "GrGLPathRendering.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 } 80 }
81 81
82 static const bool kIsWrapped = false; // The constructor creates the GL path obj ect. 82 static const bool kIsWrapped = false; // The constructor creates the GL path obj ect.
83 83
84 void GrGLPath::InitPathObject(GrGpuGL* gpu, 84 void GrGLPath::InitPathObject(GrGpuGL* gpu,
85 GrGLuint pathID, 85 GrGLuint pathID,
86 const SkPath& skPath, 86 const SkPath& skPath,
87 const SkStrokeRec& stroke) { 87 const SkStrokeRec& stroke) {
88 GrGLPathRendering* pr = gpu->glPathRendering();
89 SkSTArray<16, GrGLubyte, true> pathCommands; 88 SkSTArray<16, GrGLubyte, true> pathCommands;
90 SkSTArray<16, SkPoint, true> pathPoints; 89 SkSTArray<16, SkPoint, true> pathPoints;
91 90
92 int verbCnt = skPath.countVerbs(); 91 int verbCnt = skPath.countVerbs();
93 int pointCnt = skPath.countPoints(); 92 int pointCnt = skPath.countPoints();
94 pathCommands.resize_back(verbCnt); 93 pathCommands.resize_back(verbCnt);
95 pathPoints.resize_back(pointCnt); 94 pathPoints.resize_back(pointCnt);
96 95
97 // TODO: Direct access to path points since we could pass them on directly. 96 // TODO: Direct access to path points since we could pass them on directly.
98 skPath.getPoints(&pathPoints[0], pointCnt); 97 skPath.getPoints(&pathPoints[0], pointCnt);
99 skPath.getVerbs(&pathCommands[0], verbCnt); 98 skPath.getVerbs(&pathCommands[0], verbCnt);
100 99
101 SkDEBUGCODE(int numPts = 0); 100 SkDEBUGCODE(int numPts = 0);
102 for (int i = 0; i < verbCnt; ++i) { 101 for (int i = 0; i < verbCnt; ++i) {
103 SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]); 102 SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]);
104 pathCommands[i] = verb_to_gl_path_cmd(v); 103 pathCommands[i] = verb_to_gl_path_cmd(v);
105 SkDEBUGCODE(numPts += num_pts(v)); 104 SkDEBUGCODE(numPts += num_pts(v));
106 } 105 }
107 SkASSERT(pathPoints.count() == numPts); 106 SkASSERT(pathPoints.count() == numPts);
108 107
109 pr->pathCommands(pathID, verbCnt, &pathCommands[0], 2 * pointCnt, GR_GL_FLOA T, &pathPoints[0]); 108 GR_GL_CALL(gpu->glInterface(),
109 PathCommands(pathID, verbCnt, &pathCommands[0],
110 2 * pointCnt, GR_GL_FLOAT, &pathPoints[0]));
110 if (stroke.needToApply()) { 111 if (stroke.needToApply()) {
111 SkASSERT(!stroke.isHairlineStyle()); 112 SkASSERT(!stroke.isHairlineStyle());
112 pr->pathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stro ke.getWidth())); 113 GR_GL_CALL(gpu->glInterface(),
113 pr->pathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(strok e.getMiter())); 114 PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stro ke.getWidth())));
115 GR_GL_CALL(gpu->glInterface(),
116 PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(strok e.getMiter())));
114 GrGLenum join = join_to_gl_join(stroke.getJoin()); 117 GrGLenum join = join_to_gl_join(stroke.getJoin());
115 pr->pathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join); 118 GR_GL_CALL(gpu->glInterface(),
119 PathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join));
116 GrGLenum cap = cap_to_gl_cap(stroke.getCap()); 120 GrGLenum cap = cap_to_gl_cap(stroke.getCap());
117 pr->pathParameteri(pathID, GR_GL_PATH_INITIAL_END_CAP, cap); 121 GR_GL_CALL(gpu->glInterface(),
118 pr->pathParameteri(pathID, GR_GL_PATH_TERMINAL_END_CAP, cap); 122 PathParameteri(pathID, GR_GL_PATH_INITIAL_END_CAP, cap));
123 GR_GL_CALL(gpu->glInterface(),
124 PathParameteri(pathID, GR_GL_PATH_TERMINAL_END_CAP, cap));
119 } 125 }
120 } 126 }
121 127
122 GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke) 128 GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke)
123 : INHERITED(gpu, kIsWrapped, path, stroke), 129 : INHERITED(gpu, kIsWrapped, path, stroke),
124 fPathID(gpu->glPathRendering()->genPaths(1)) { 130 fPathID(gpu->glPathRendering()->genPaths(1)) {
125 SkASSERT(!path.isEmpty()); 131 SkASSERT(!path.isEmpty());
126 132
127 InitPathObject(gpu, fPathID, fSkPath, stroke); 133 InitPathObject(gpu, fPathID, fSkPath, stroke);
128 134
(...skipping 14 matching lines...) Expand all
143 } 149 }
144 150
145 INHERITED::onRelease(); 151 INHERITED::onRelease();
146 } 152 }
147 153
148 void GrGLPath::onAbandon() { 154 void GrGLPath::onAbandon() {
149 fPathID = 0; 155 fPathID = 0;
150 156
151 INHERITED::onAbandon(); 157 INHERITED::onAbandon();
152 } 158 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGLPathRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698