Skip to content

Commit 6b98fdd

Browse files
committed
R6 - Resolved remaining issues with surface (modulo bugs in R6 that require the implementation to diverge).
1 parent e00e044 commit 6b98fdd

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

N3888_RefImpl/src/surface.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,20 @@ void surface::mark_dirty() {
4747
cairo_surface_mark_dirty(_Surface.get());
4848
}
4949

50-
void surface::mark_dirty(const bounding_box& rect) {
51-
_Dirty_rect = rect;
52-
cairo_surface_mark_dirty_rectangle(_Surface.get(), _Double_to_int(rect.x()), _Double_to_int(rect.y()), _Double_to_int(rect.width()), _Double_to_int(rect.height()));
50+
void surface::mark_dirty(error_code& ec) noexcept {
51+
cairo_surface_mark_dirty(_Surface.get());
52+
ec.clear();
53+
}
54+
55+
void surface::mark_dirty(const bounding_box& extents) {
56+
_Dirty_rect = extents;
57+
cairo_surface_mark_dirty_rectangle(_Surface.get(), _Float_to_int(extents.x()), _Float_to_int(extents.y()), _Float_to_int(extents.width()), _Float_to_int(extents.height()));
58+
}
59+
60+
void surface::mark_dirty(const bounding_box& extents, error_code& ec) noexcept {
61+
_Dirty_rect = extents;
62+
cairo_surface_mark_dirty_rectangle(_Surface.get(), _Float_to_int(extents.x()), _Float_to_int(extents.y()), _Float_to_int(extents.width()), _Float_to_int(extents.height()));
63+
ec.clear();
5364
}
5465

5566
void surface::clear() {
@@ -198,14 +209,13 @@ void surface::stroke(const brush& b, const interpreted_path& pg, const optional<
198209
cairo_stroke(context);
199210
}
200211

201-
/*void surface::mask(const brush& b, const brush& mb, const interpreted_path& pg, const optional<brush_props>& bp, const optional<mask_props>& mp, const optional<render_props>& rp, const optional<clip_props>& cl) {
212+
void surface::mask(const brush& b, const brush& mb, const optional<brush_props>& bp, const optional<mask_props>& mp, const optional<render_props>& rp, const optional<clip_props>& cl) {
202213
auto context = _Context.get();
203214
_Set_render_props(context, rp);
204215
_Set_clip_props(context, cl);
205216
_Set_brush_props(context, bp, b);
206217
_Set_mask_props(mp, mb);
207218
cairo_set_source(context, b.native_handle());
208219
cairo_new_path(context);
209-
cairo_append_path(context, pg._Native_handle());
210220
cairo_mask(context, mb.native_handle());
211-
}*/
221+
}

N3888_RefImpl/src/xio2d_impl.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace std::experimental::io2d {
3939
}
4040

4141
// Converts 'value' to an int and returns it. If nearestNeighbor is true, the return value is the result of calling 'static_cast<int>(round(value))'; if false, the return value is the result of calling 'static_cast<int>(trunc(value))'.
42-
inline int _Double_to_int(float value, bool nearestNeighbor = true) {
42+
inline int _Float_to_int(float value, bool nearestNeighbor = true) {
4343
if (nearestNeighbor) {
4444
// Round to the nearest neighbor.
4545
return static_cast<int>(::std::round(value));
@@ -2483,26 +2483,19 @@ namespace std::experimental::io2d {
24832483
return _Matrix;
24842484
}
24852485

2486-
// divergent from paper
2487-
/* template <class Allocator>
2486+
// divergent from paper ?
2487+
template <class Allocator>
24882488
inline void surface::fill(const brush& b, const path_builder<Allocator>& pf, const optional<brush_props>& bp, const optional<render_props>& rp, const optional<clip_props>& cl) {
24892489
interpreted_path pg(pf);
24902490
fill(b, pg, bp, rp, cl);
2491-
}*/
2491+
}
24922492

24932493
template <class Allocator>
24942494
inline void surface::stroke(const brush& b, const path_builder<Allocator>& pf, const optional<brush_props>& bp, const optional<stroke_props>& sp, const optional<dashes>& d, const optional<render_props>& rp, const optional<clip_props>& cl) {
24952495
interpreted_path pg(pf);
24962496
stroke(b, pg, bp, sp, d, rp, cl);
24972497
}
24982498

2499-
// divergent from paper
2500-
/* template <class Allocator>
2501-
inline void surface::mask(const brush& b, const brush& mb, const path_builder<Allocator>& pf, const optional<brush_props>& bp, const optional<mask_props>& mp, const optional<render_props>&rp, const optional<clip_props>& cl) {
2502-
interpreted_path pg(pf);
2503-
mask(b, mb, pg, bp, mp, rp, cl);
2504-
}*/
2505-
25062499
inline mapped_surface::mapped_surface(surface::native_handle_type nh, surface::native_handle_type map_of)
25072500
: _Mapped_surface(nh)
25082501
, _Map_of(map_of) {

N3888_RefImpl/src/xsurfaces.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,13 @@ namespace std::experimental::io2d {
241241
void stroke(const brush& b, const path_builder<Allocator>& pb, const optional<brush_props>& bp = nullopt, const optional<stroke_props>& sp = nullopt, const optional<dashes>& d = nullopt, const optional<render_props>& rp = nullopt, const optional<clip_props>& cl = nullopt);
242242
_IO2D_API void stroke(const brush& b, const interpreted_path& pg, const optional<brush_props>& bp = nullopt, const optional<stroke_props>& sp = nullopt, const optional<dashes>& d = nullopt, const optional<render_props>& rp = nullopt, const optional<clip_props>& cl = nullopt);
243243
template <class Allocator>
244-
void fill(const brush& b, const path_builder<Allocator>& pb, const optional<render_props>& rp = nullopt, const optional<clip_props>& cl = nullopt);
244+
void fill(const brush& b, const path_builder<Allocator>& pb, const optional<brush_props>& bp = nullopt, const optional<render_props>& rp = nullopt, const optional<clip_props>& cl = nullopt);
245245
_IO2D_API void fill(const brush& b, const interpreted_path& pg, const optional<brush_props>& bp = nullopt, const optional<render_props>& rp = nullopt, const optional<clip_props>& cl = nullopt);
246-
template <class Allocator>
247-
void mask(const brush& b, const brush& mb, const optional<brush_props>& bp = nullopt, const optional<mask_props>& mp = nullopt, const optional<render_props>& rp = nullopt, const optional<clip_props>& cl = nullopt);
246+
247+
// Broken R6 - removed unused path from mask but forgot to eliminate this overload:
248+
//template <class Allocator>
249+
//void mask(const brush& b, const brush& mb, const optional<brush_props>& bp = nullopt, const optional<mask_props>& mp = nullopt, const optional<render_props>& rp = nullopt, const optional<clip_props>& cl = nullopt);
250+
248251
_IO2D_API void mask(const brush& b, const brush& mb, const optional<brush_props>& bp = nullopt, const optional<mask_props>& mp = nullopt, const optional<render_props>& rp = nullopt, const optional<clip_props>& cl = nullopt);
249252
};
250253

0 commit comments

Comments
 (0)