@@ -109,8 +109,8 @@ static VertexBuffer CreateSolidStrokeVertices(
109109 // We're drawing a triangle strip, so we need to "pick up the pen" by
110110 // appending transparent vertices between the end of the previous contour
111111 // and the beginning of the new contour.
112- vtx.vertex_position = polyline.points [contour_start_point_i - 1 ];
113- vtx.vertex_normal = {};
112+ vtx.position = polyline.points [contour_start_point_i - 1 ];
113+ vtx.normal = {};
114114 vtx.pen_down = 0.0 ;
115115 // Append two transparent vertices when "picking up" the pen so that the
116116 // triangle drawn when moving to the beginning of the new contour will
@@ -119,7 +119,7 @@ static VertexBuffer CreateSolidStrokeVertices(
119119 vtx_builder.AppendVertex (vtx);
120120 vtx_builder.AppendVertex (vtx);
121121
122- vtx.vertex_position = polyline.points [contour_start_point_i];
122+ vtx.position = polyline.points [contour_start_point_i];
123123 // Append two vertices at the beginning of the new contour
124124 // so that the next appended vertex will create a triangle with zero
125125 // volume.
@@ -139,16 +139,16 @@ static VertexBuffer CreateSolidStrokeVertices(
139139 point_i++) {
140140 if (point_i > contour_start_point_i) {
141141 // Generate line rect.
142- vtx.vertex_position = polyline.points [point_i - 1 ];
142+ vtx.position = polyline.points [point_i - 1 ];
143143 vtx.pen_down = 1.0 ;
144- vtx.vertex_normal = normal;
144+ vtx.normal = normal;
145145 vtx_builder.AppendVertex (vtx);
146- vtx.vertex_normal = -normal;
146+ vtx.normal = -normal;
147147 vtx_builder.AppendVertex (vtx);
148- vtx.vertex_position = polyline.points [point_i];
149- vtx.vertex_normal = normal;
148+ vtx.position = polyline.points [point_i];
149+ vtx.normal = normal;
150150 vtx_builder.AppendVertex (vtx);
151- vtx.vertex_normal = -normal;
151+ vtx.normal = -normal;
152152 vtx_builder.AppendVertex (vtx);
153153
154154 if (point_i < contour_end_point_i - 1 ) {
@@ -181,13 +181,16 @@ bool SolidStrokeContents::Render(const ContentContext& renderer,
181181 return true ;
182182 }
183183
184- using VS = SolidStrokeVertexShader;
184+ using VS = SolidStrokePipeline::VertexShader;
185+ using FS = SolidStrokePipeline::FragmentShader;
186+
187+ VS::VertInfo vert_info;
188+ vert_info.mvp = Matrix::MakeOrthographic (pass.GetRenderTargetSize ()) *
189+ entity.GetTransformation ();
190+ vert_info.size = stroke_size_;
185191
186- VS::FrameInfo frame_info;
187- frame_info.mvp = Matrix::MakeOrthographic (pass.GetRenderTargetSize ()) *
188- entity.GetTransformation ();
189- frame_info.color = color_.Premultiply ();
190- frame_info.size = stroke_size_;
192+ FS::FragInfo frag_info;
193+ frag_info.color = color_.Premultiply ();
191194
192195 Command cmd;
193196 cmd.primitive_type = PrimitiveType::kTriangleStrip ;
@@ -206,7 +209,8 @@ bool SolidStrokeContents::Render(const ContentContext& renderer,
206209 cmd.BindVertices (CreateSolidStrokeVertices (path_, pass.GetTransientsBuffer (),
207210 cap_proc_, join_proc_,
208211 miter_limit_, smoothing));
209- VS::BindFrameInfo (cmd, pass.GetTransientsBuffer ().EmplaceUniform (frame_info));
212+ VS::BindVertInfo (cmd, pass.GetTransientsBuffer ().EmplaceUniform (vert_info));
213+ FS::BindFragInfo (cmd, pass.GetTransientsBuffer ().EmplaceUniform (frag_info));
210214
211215 pass.AddCommand (cmd);
212216
@@ -251,7 +255,7 @@ void SolidStrokeContents::SetStrokeCap(Cap cap) {
251255 const Point& position, const Point& normal,
252256 const SmoothingApproximation& smoothing) {
253257 SolidStrokeVertexShader::PerVertexData vtx;
254- vtx.vertex_position = position;
258+ vtx.position = position;
255259 vtx.pen_down = 1.0 ;
256260
257261 Point forward (normal.y , -normal.x );
@@ -262,14 +266,14 @@ void SolidStrokeContents::SetStrokeCap(Cap cap) {
262266 forward + normal * PathBuilder::kArcApproximationMagic , forward)
263267 .CreatePolyline (smoothing);
264268
265- vtx.vertex_normal = normal;
269+ vtx.normal = normal;
266270 vtx_builder.AppendVertex (vtx);
267- vtx.vertex_normal = -normal;
271+ vtx.normal = -normal;
268272 vtx_builder.AppendVertex (vtx);
269273 for (const auto & point : arc_points) {
270- vtx.vertex_normal = point;
274+ vtx.normal = point;
271275 vtx_builder.AppendVertex (vtx);
272- vtx.vertex_normal = (-point).Reflect (forward);
276+ vtx.normal = (-point).Reflect (forward);
273277 vtx_builder.AppendVertex (vtx);
274278 }
275279 };
@@ -279,18 +283,18 @@ void SolidStrokeContents::SetStrokeCap(Cap cap) {
279283 const Point& position, const Point& normal,
280284 const SmoothingApproximation& smoothing) {
281285 SolidStrokeVertexShader::PerVertexData vtx;
282- vtx.vertex_position = position;
286+ vtx.position = position;
283287 vtx.pen_down = 1.0 ;
284288
285289 Point forward (normal.y , -normal.x );
286290
287- vtx.vertex_normal = normal;
291+ vtx.normal = normal;
288292 vtx_builder.AppendVertex (vtx);
289- vtx.vertex_normal = -normal;
293+ vtx.normal = -normal;
290294 vtx_builder.AppendVertex (vtx);
291- vtx.vertex_normal = normal + forward;
295+ vtx.normal = normal + forward;
292296 vtx_builder.AppendVertex (vtx);
293- vtx.vertex_normal = -normal + forward;
297+ vtx.normal = -normal + forward;
294298 vtx_builder.AppendVertex (vtx);
295299 };
296300 break ;
@@ -307,15 +311,15 @@ static Scalar CreateBevelAndGetDirection(
307311 const Point& start_normal,
308312 const Point& end_normal) {
309313 SolidStrokeVertexShader::PerVertexData vtx;
310- vtx.vertex_position = position;
314+ vtx.position = position;
311315 vtx.pen_down = 1.0 ;
312- vtx.vertex_normal = {};
316+ vtx.normal = {};
313317 vtx_builder.AppendVertex (vtx);
314318
315319 Scalar dir = start_normal.Cross (end_normal) > 0 ? -1 : 1 ;
316- vtx.vertex_normal = start_normal * dir;
320+ vtx.normal = start_normal * dir;
317321 vtx_builder.AppendVertex (vtx);
318- vtx.vertex_normal = end_normal * dir;
322+ vtx.normal = end_normal * dir;
319323 vtx_builder.AppendVertex (vtx);
320324
321325 return dir;
@@ -357,9 +361,9 @@ void SolidStrokeContents::SetStrokeJoin(Join join) {
357361
358362 // Outer miter point.
359363 SolidStrokeVertexShader::PerVertexData vtx;
360- vtx.vertex_position = position;
364+ vtx.position = position;
361365 vtx.pen_down = 1.0 ;
362- vtx.vertex_normal = miter_point * dir;
366+ vtx.normal = miter_point * dir;
363367 vtx_builder.AppendVertex (vtx);
364368 };
365369 break ;
@@ -391,12 +395,12 @@ void SolidStrokeContents::SetStrokeJoin(Join join) {
391395 .CreatePolyline (smoothing);
392396
393397 SolidStrokeVertexShader::PerVertexData vtx;
394- vtx.vertex_position = position;
398+ vtx.position = position;
395399 vtx.pen_down = 1.0 ;
396400 for (const auto & point : arc_points) {
397- vtx.vertex_normal = point * dir;
401+ vtx.normal = point * dir;
398402 vtx_builder.AppendVertex (vtx);
399- vtx.vertex_normal = (-point * dir).Reflect (middle);
403+ vtx.normal = (-point * dir).Reflect (middle);
400404 vtx_builder.AppendVertex (vtx);
401405 }
402406 };
0 commit comments