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

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

Issue 443133003: Revert of Wrap NV_path_rendering API with GrGLPathRendering (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « src/gpu/gl/GrGLPath.h ('k') | src/gpu/gl/GrGLPathRange.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 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"
11 #include "GrGpuGL.h" 10 #include "GrGpuGL.h"
12 11
12 #define GPUGL static_cast<GrGpuGL*>(this->getGpu())
13
14 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
15 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(GPUGL->glInterface(), R, X)
16
13 namespace { 17 namespace {
14 inline GrGLubyte verb_to_gl_path_cmd(SkPath::Verb verb) { 18 inline GrGLubyte verb_to_gl_path_cmd(SkPath::Verb verb) {
15 static const GrGLubyte gTable[] = { 19 static const GrGLubyte gTable[] = {
16 GR_GL_MOVE_TO, 20 GR_GL_MOVE_TO,
17 GR_GL_LINE_TO, 21 GR_GL_LINE_TO,
18 GR_GL_QUADRATIC_CURVE_TO, 22 GR_GL_QUADRATIC_CURVE_TO,
19 0xFF, // conic 23 0xFF, // conic
20 GR_GL_CUBIC_CURVE_TO, 24 GR_GL_CUBIC_CURVE_TO,
21 GR_GL_CLOSE_PATH, 25 GR_GL_CLOSE_PATH,
22 }; 26 };
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 GR_STATIC_ASSERT(0 == SkPaint::kButt_Cap); 78 GR_STATIC_ASSERT(0 == SkPaint::kButt_Cap);
75 GR_STATIC_ASSERT(1 == SkPaint::kRound_Cap); 79 GR_STATIC_ASSERT(1 == SkPaint::kRound_Cap);
76 GR_STATIC_ASSERT(2 == SkPaint::kSquare_Cap); 80 GR_STATIC_ASSERT(2 == SkPaint::kSquare_Cap);
77 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gSkCapsToGrGLCaps) == SkPaint::kCapCount); 81 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gSkCapsToGrGLCaps) == SkPaint::kCapCount);
78 } 82 }
79 83
80 } 84 }
81 85
82 static const bool kIsWrapped = false; // The constructor creates the GL path obj ect. 86 static const bool kIsWrapped = false; // The constructor creates the GL path obj ect.
83 87
84 void GrGLPath::InitPathObject(GrGpuGL* gpu, 88 void GrGLPath::InitPathObject(const GrGLInterface* gl,
85 GrGLuint pathID, 89 GrGLuint pathID,
86 const SkPath& skPath, 90 const SkPath& skPath,
87 const SkStrokeRec& stroke) { 91 const SkStrokeRec& stroke) {
88 GrGLPathRendering* pr = gpu->pathRendering();
89 SkSTArray<16, GrGLubyte, true> pathCommands; 92 SkSTArray<16, GrGLubyte, true> pathCommands;
90 SkSTArray<16, SkPoint, true> pathPoints; 93 SkSTArray<16, SkPoint, true> pathPoints;
91 94
92 int verbCnt = skPath.countVerbs(); 95 int verbCnt = skPath.countVerbs();
93 int pointCnt = skPath.countPoints(); 96 int pointCnt = skPath.countPoints();
94 pathCommands.resize_back(verbCnt); 97 pathCommands.resize_back(verbCnt);
95 pathPoints.resize_back(pointCnt); 98 pathPoints.resize_back(pointCnt);
96 99
97 // TODO: Direct access to path points since we could pass them on directly. 100 // TODO: Direct access to path points since we could pass them on directly.
98 skPath.getPoints(&pathPoints[0], pointCnt); 101 skPath.getPoints(&pathPoints[0], pointCnt);
99 skPath.getVerbs(&pathCommands[0], verbCnt); 102 skPath.getVerbs(&pathCommands[0], verbCnt);
100 103
101 SkDEBUGCODE(int numPts = 0); 104 SkDEBUGCODE(int numPts = 0);
102 for (int i = 0; i < verbCnt; ++i) { 105 for (int i = 0; i < verbCnt; ++i) {
103 SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]); 106 SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]);
104 pathCommands[i] = verb_to_gl_path_cmd(v); 107 pathCommands[i] = verb_to_gl_path_cmd(v);
105 SkDEBUGCODE(numPts += num_pts(v)); 108 SkDEBUGCODE(numPts += num_pts(v));
106 } 109 }
107 SkASSERT(pathPoints.count() == numPts); 110 SkASSERT(pathPoints.count() == numPts);
108 111
109 pr->pathCommands(pathID, verbCnt, &pathCommands[0], 2 * pointCnt, GR_GL_FLOA T, &pathPoints[0]); 112 GR_GL_CALL(gl, PathCommands(pathID,
113 verbCnt, &pathCommands[0],
114 2 * pointCnt, GR_GL_FLOAT, &pathPoints[0]));
115
110 if (stroke.needToApply()) { 116 if (stroke.needToApply()) {
111 SkASSERT(!stroke.isHairlineStyle()); 117 SkASSERT(!stroke.isHairlineStyle());
112 pr->pathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stro ke.getWidth())); 118 GR_GL_CALL(gl, PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarT oFloat(stroke.getWidth())));
113 pr->pathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(strok e.getMiter())); 119 GR_GL_CALL(gl, PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarTo Float(stroke.getMiter())));
114 GrGLenum join = join_to_gl_join(stroke.getJoin()); 120 GrGLenum join = join_to_gl_join(stroke.getJoin());
115 pr->pathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join); 121 GR_GL_CALL(gl, PathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join));
116 GrGLenum cap = cap_to_gl_cap(stroke.getCap()); 122 GrGLenum cap = cap_to_gl_cap(stroke.getCap());
117 pr->pathParameteri(pathID, GR_GL_PATH_INITIAL_END_CAP, cap); 123 GR_GL_CALL(gl, PathParameteri(pathID, GR_GL_PATH_INITIAL_END_CAP, cap));
118 pr->pathParameteri(pathID, GR_GL_PATH_TERMINAL_END_CAP, cap); 124 GR_GL_CALL(gl, 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->pathRendering()->genPaths(1)) {
125 SkASSERT(!path.isEmpty()); 130 SkASSERT(!path.isEmpty());
126 131
127 InitPathObject(gpu, fPathID, fSkPath, stroke); 132 fPathID = gpu->createGLPathObject();
133
134 InitPathObject(static_cast<GrGpuGL*>(this->getGpu())->glInterface(),
135 fPathID, fSkPath, stroke);
128 136
129 if (stroke.needToApply()) { 137 if (stroke.needToApply()) {
130 // FIXME: try to account for stroking, without rasterizing the stroke. 138 // FIXME: try to account for stroking, without rasterizing the stroke.
131 fBounds.outset(stroke.getWidth(), stroke.getWidth()); 139 fBounds.outset(stroke.getWidth(), stroke.getWidth());
132 } 140 }
133 } 141 }
134 142
135 GrGLPath::~GrGLPath() { 143 GrGLPath::~GrGLPath() {
136 this->release(); 144 this->release();
137 } 145 }
138 146
139 void GrGLPath::onRelease() { 147 void GrGLPath::onRelease() {
140 if (0 != fPathID && !this->isWrapped()) { 148 if (0 != fPathID && !this->isWrapped()) {
141 static_cast<GrGpuGL*>(this->getGpu())->pathRendering()->deletePaths(fPat hID, 1); 149 static_cast<GrGpuGL*>(this->getGpu())->deleteGLPathObject(fPathID);
142 fPathID = 0; 150 fPathID = 0;
143 } 151 }
144 152
145 INHERITED::onRelease(); 153 INHERITED::onRelease();
146 } 154 }
147 155
148 void GrGLPath::onAbandon() { 156 void GrGLPath::onAbandon() {
149 fPathID = 0; 157 fPathID = 0;
150 158
151 INHERITED::onAbandon(); 159 INHERITED::onAbandon();
152 } 160 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLPath.h ('k') | src/gpu/gl/GrGLPathRange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698