Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb24060

Browse files
committed
Shorten Agg template usage with class template argument deduction.
Many parts of the Agg & path processing pipeline work by constructingnested templated objects that represent steps of the processingpipeline, e.g. (simplified example)```agg::conv_transform<mpl::PathIterator> // The processing step. tpath // The name of the result. (path, trans); // The arguments passed to the processing step.PathNanRemover<agg::conv_transform<mpl::PathIterator>> nan_removed (tpath, true, path.has_codes());```The current implementation makes the code shorter by introducing aliastypenames for the types at each intermediate step.As of C++17, this can be made simpler and shorter because class templateargument deduction ("CTAD") allows not specifying the template arguments(in angle brackets) anymore, i.e. one can write```agg::conv_transform tpath(path, trans);PathNanRemover nan_removed(tpath, true, path.has_codes());```and the compiler will auto-fill in the required types.Furthermore, because these steps can be seen as a pipeline (even thoughthey are implemented as the construction of nested objects), it may feelmore natural to write them as repeated "function" (constructor)application, i.e.```auto tpath = agg::conv_transform{path, trans};auto nan_removed = PathNanRemover{tpath, true, path.has_codes()};```Perform this transformation whereever applicable.
1 parent9f7b3dd commitcb24060

File tree

3 files changed

+138
-245
lines changed

3 files changed

+138
-245
lines changed

‎src/_backend_agg.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,6 @@ bool RendererAgg::render_clippath(mpl::PathIterator &clippath,
122122
const agg::trans_affine &clippath_trans,
123123
e_snap_mode snap_mode)
124124
{
125-
typedef agg::conv_transform<mpl::PathIterator>transformed_path_t;
126-
typedef PathNanRemover<transformed_path_t>nan_removed_t;
127-
/* Unlike normal Paths, the clip path cannot be clipped to the Figure bbox,
128-
* because it needs to remain a complete closed path, so there is no
129-
* PathClipper<nan_removed_t> step.*/
130-
typedef PathSnapper<nan_removed_t>snapped_t;
131-
typedef PathSimplifier<snapped_t>simplify_t;
132-
typedef agg::conv_curve<simplify_t>curve_t;
133-
134125
bool has_clippath = (clippath.total_vertices() !=0);
135126

136127
if (has_clippath &&
@@ -141,13 +132,19 @@ bool RendererAgg::render_clippath(mpl::PathIterator &clippath,
141132
trans *=agg::trans_affine_translation(0.0, (double)height);
142133

143134
rendererBaseAlphaMask.clear(agg::gray8(0,0));
144-
transformed_path_ttransformed_clippath(clippath, trans);
145-
nan_removed_tnan_removed_clippath(transformed_clippath,true, clippath.has_codes());
146-
snapped_tsnapped_clippath(nan_removed_clippath, snap_mode, clippath.total_vertices(),0.0);
147-
simplify_tsimplified_clippath(snapped_clippath,
148-
clippath.should_simplify() && !clippath.has_codes(),
149-
clippath.simplify_threshold());
150-
curve_tcurved_clippath(simplified_clippath);
135+
auto transformed_clippath = agg::conv_transform{clippath, trans};
136+
auto nan_removed_clippath = PathNanRemover{
137+
transformed_clippath,true, clippath.has_codes()};
138+
// Unlike normal Paths, the clip path cannot be clipped to the Figure
139+
// bbox, because it needs to remain a complete closed path, so there is
140+
// no PathClipper step after nan-removal.
141+
auto snapped_clippath = PathSnapper{
142+
nan_removed_clippath, snap_mode, clippath.total_vertices(),0.0};
143+
auto simplified_clippath = PathSimplifier{
144+
snapped_clippath,
145+
clippath.should_simplify() && !clippath.has_codes(),
146+
clippath.simplify_threshold()};
147+
auto curved_clippath = agg::conv_curve{simplified_clippath};
151148
theRasterizer.add_path(curved_clippath);
152149
rendererAlphaMask.color(agg::gray8(255,255));
153150
agg::render_scanlines(theRasterizer, scanlineAlphaMask, rendererAlphaMask);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp