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

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

Issue 400713003: Add a GrPathRange class (Closed) Base URL: https://skia.googlesource.com/skia.git@clupload-ispath
Patch Set: Created 6 years, 5 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
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 "GrGpuGL.h" 10 #include "GrGpuGL.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 GR_STATIC_ASSERT(0 == SkPaint::kButt_Cap); 78 GR_STATIC_ASSERT(0 == SkPaint::kButt_Cap);
79 GR_STATIC_ASSERT(1 == SkPaint::kRound_Cap); 79 GR_STATIC_ASSERT(1 == SkPaint::kRound_Cap);
80 GR_STATIC_ASSERT(2 == SkPaint::kSquare_Cap); 80 GR_STATIC_ASSERT(2 == SkPaint::kSquare_Cap);
81 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gSkCapsToGrGLCaps) == SkPaint::kCapCount); 81 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gSkCapsToGrGLCaps) == SkPaint::kCapCount);
82 } 82 }
83 83
84 } 84 }
85 85
86 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.
87 87
88 GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke) 88 void GrGLPath::InitPathObject(const GrGLInterface* gl,
89 : INHERITED(gpu, kIsWrapped, path, stroke) { 89 GrGLuint pathID,
90 SkASSERT(!path.isEmpty()); 90 const SkPath& skPath,
91 91 const SkStrokeRec& stroke) {
92 fPathID = gpu->createGLPathObject();
93
94 SkSTArray<16, GrGLubyte, true> pathCommands; 92 SkSTArray<16, GrGLubyte, true> pathCommands;
95 SkSTArray<16, SkPoint, true> pathPoints; 93 SkSTArray<16, SkPoint, true> pathPoints;
96 94
97 int verbCnt = fSkPath.countVerbs(); 95 int verbCnt = skPath.countVerbs();
98 int pointCnt = fSkPath.countPoints(); 96 int pointCnt = skPath.countPoints();
99 pathCommands.resize_back(verbCnt); 97 pathCommands.resize_back(verbCnt);
100 pathPoints.resize_back(pointCnt); 98 pathPoints.resize_back(pointCnt);
101 99
102 // 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.
103 fSkPath.getPoints(&pathPoints[0], pointCnt); 101 skPath.getPoints(&pathPoints[0], pointCnt);
104 fSkPath.getVerbs(&pathCommands[0], verbCnt); 102 skPath.getVerbs(&pathCommands[0], verbCnt);
105 103
106 SkDEBUGCODE(int numPts = 0); 104 SkDEBUGCODE(int numPts = 0);
107 for (int i = 0; i < verbCnt; ++i) { 105 for (int i = 0; i < verbCnt; ++i) {
108 SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]); 106 SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]);
109 pathCommands[i] = verb_to_gl_path_cmd(v); 107 pathCommands[i] = verb_to_gl_path_cmd(v);
110 SkDEBUGCODE(numPts += num_pts(v)); 108 SkDEBUGCODE(numPts += num_pts(v));
111 } 109 }
112 SkASSERT(pathPoints.count() == numPts); 110 SkASSERT(pathPoints.count() == numPts);
113 111
114 GL_CALL(PathCommands(fPathID, 112 GR_GL_CALL(gl, PathCommands(pathID,
115 verbCnt, &pathCommands[0], 113 verbCnt, &pathCommands[0],
116 2 * pointCnt, GR_GL_FLOAT, &pathPoints[0])); 114 2 * pointCnt, GR_GL_FLOAT, &pathPoints[0]));
117 115
118 if (stroke.needToApply()) { 116 if (stroke.needToApply()) {
119 GL_CALL(PathParameterf(fPathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat (stroke.getWidth()))); 117 GR_GL_CALL(gl, PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarT oFloat(stroke.getWidth())));
120 GL_CALL(PathParameterf(fPathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat( stroke.getMiter()))); 118 GR_GL_CALL(gl, PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarTo Float(stroke.getMiter())));
121 GrGLenum join = join_to_gl_join(stroke.getJoin()); 119 GrGLenum join = join_to_gl_join(stroke.getJoin());
122 GL_CALL(PathParameteri(fPathID, GR_GL_PATH_JOIN_STYLE, join)); 120 GR_GL_CALL(gl, PathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join));
123 GrGLenum cap = cap_to_gl_cap(stroke.getCap()); 121 GrGLenum cap = cap_to_gl_cap(stroke.getCap());
124 GL_CALL(PathParameteri(fPathID, GR_GL_PATH_INITIAL_END_CAP, cap)); 122 GR_GL_CALL(gl, PathParameteri(pathID, GR_GL_PATH_INITIAL_END_CAP, cap));
125 GL_CALL(PathParameteri(fPathID, GR_GL_PATH_TERMINAL_END_CAP, cap)); 123 GR_GL_CALL(gl, PathParameteri(pathID, GR_GL_PATH_TERMINAL_END_CAP, cap)) ;
126
127 // FIXME: try to account for stroking, without rasterizing the stroke.
128 fBounds.outset(SkScalarToFloat(stroke.getWidth()), SkScalarToFloat(strok e.getWidth()));
129 } 124 }
130 } 125 }
131 126
127 GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke)
128 : INHERITED(gpu, kIsWrapped, path, stroke) {
129 SkASSERT(!path.isEmpty());
130
131 fPathID = gpu->createGLPathObject();
132
133 InitPathObject(static_cast<GrGpuGL*>(this->getGpu())->glInterface(),
134 fPathID, fSkPath, stroke);
135
136 if (stroke.needToApply()) {
137 // FIXME: try to account for stroking, without rasterizing the stroke.
138 fBounds.outset(stroke.getWidth(), stroke.getWidth());
139 }
140 }
141
132 GrGLPath::~GrGLPath() { 142 GrGLPath::~GrGLPath() {
133 this->release(); 143 this->release();
134 } 144 }
135 145
136 void GrGLPath::onRelease() { 146 void GrGLPath::onRelease() {
137 if (0 != fPathID && !this->isWrapped()) { 147 if (0 != fPathID && !this->isWrapped()) {
138 static_cast<GrGpuGL*>(this->getGpu())->deleteGLPathObject(fPathID); 148 static_cast<GrGpuGL*>(this->getGpu())->deleteGLPathObject(fPathID);
139 fPathID = 0; 149 fPathID = 0;
140 } 150 }
141 151
142 INHERITED::onRelease(); 152 INHERITED::onRelease();
143 } 153 }
144 154
145 void GrGLPath::onAbandon() { 155 void GrGLPath::onAbandon() {
146 fPathID = 0; 156 fPathID = 0;
147 157
148 INHERITED::onAbandon(); 158 INHERITED::onAbandon();
149 } 159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698