Skip to content

Commit 42a1981

Browse files
committed
Renamed surface::push_group_with_content to surface::push_group. Renamed surface::copy_clip_rectangle_list to surface::get_clip_rectangles. Added path_data validation code to path class constructor.
1 parent 43370fb commit 42a1981

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

N3888_RefImpl/src/drawing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ namespace std {
980980
void save();
981981
void restore();
982982
void push_group();
983-
void push_group_with_content(content c);
983+
void push_group(content c);
984984
surface pop_group();
985985
void pop_group_to_source();
986986

@@ -1025,7 +1025,7 @@ namespace std {
10251025
bool in_clip(const point& pt) const;
10261026
void reset_clip();
10271027

1028-
::std::vector<rectangle> copy_clip_rectangle_list() const;
1028+
::std::vector<rectangle> get_clip_rectangles() const;
10291029

10301030
void fill();
10311031
void fill(const surface& s);

N3888_RefImpl/src/path.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ path::path(const path_builder& pb)
1010
, _Has_current_point(pb._Has_current_point)
1111
, _Current_point(pb._Current_point)
1212
, _Extents(pb.get_path_extents()) {
13+
// Validate path data.
14+
for (unsigned int i = 0; i < _Data.size(); i += _Data[i].header.length) {
15+
auto pdt = _Data[i].header.type;
16+
switch (pdt) {
17+
case std::experimental::drawing::path_data_type::move_to:
18+
break;
19+
case std::experimental::drawing::path_data_type::line_to:
20+
break;
21+
case std::experimental::drawing::path_data_type::curve_to:
22+
break;
23+
case std::experimental::drawing::path_data_type::new_sub_path:
24+
break;
25+
case std::experimental::drawing::path_data_type::close_path:
26+
break;
27+
default:
28+
throw drawing_exception(status::invalid_path_data);
29+
}
30+
}
1331
}
1432

1533
path::path(path&& other)

N3888_RefImpl/src/sample_draw.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,20 @@ void sample_draw::operator()(surface& rs, double elapsedTimeInMilliseconds) {
113113
radialPattern.set_extend(extend::reflect);
114114
rs.set_pattern(radialPattern.get_pattern());
115115
rs.fill();
116+
117+
auto linearPattern = linear_pattern_builder({ 510.0, 460.0 }, { 530.0, 480.0 });
118+
linearPattern.add_color_stop_rgba(0.0, rgba_color::chartreuse);
119+
linearPattern.add_color_stop_rgba(1.0, rgba_color::salmon);
120+
linearPattern.set_extend(extend::repeat);
121+
pb.reset();
122+
pb.set_origin({ 500.0, 450.0 });
123+
pb.rect({ 500.0, 450.0, 100.0, 100.0 });
124+
pb.rect({ 525.0, 425.0, 50.0, 150.0 });
125+
rs.set_path(pb.get_path());
126+
rs.set_pattern(redPattern);
127+
rs.stroke();
128+
rs.set_pattern(linearPattern.get_pattern());
129+
rs.fill();
130+
116131
timer = (timer > phaseTime * (phaseCount + 2)) ? 0.0 : timer + elapsedTimeInMilliseconds;
117132
}

N3888_RefImpl/src/surface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void surface::push_group() {
133133
cairo_push_group(_Context.get());
134134
}
135135

136-
void surface::push_group_with_content(content c) {
136+
void surface::push_group(content c) {
137137
cairo_push_group_with_content(_Context.get(), _Content_to_cairo_content_t(c));
138138
}
139139

@@ -267,7 +267,7 @@ void surface::reset_clip() {
267267
cairo_reset_clip(_Context.get());
268268
}
269269

270-
vector<rectangle> surface::copy_clip_rectangle_list() const {
270+
vector<rectangle> surface::get_clip_rectangles() const {
271271
vector<rectangle> results;
272272
std::unique_ptr<cairo_rectangle_list_t, function<void(cairo_rectangle_list_t*)>> sp_rects(cairo_copy_clip_rectangle_list(_Context.get()), &cairo_rectangle_list_destroy);
273273
_Throw_if_failed_status(_Cairo_status_t_to_status(sp_rects->status));

0 commit comments

Comments
 (0)