void updateBbox();
bool operator ==(const VRleImpl &) const;
void intersected(const VRect &r, VRleImpl &result);
+ void intersect(const VRect &r, VRle::VRleSpanCb cb, void *userData) const;
void intersected(const VRleImpl &clip, VRleImpl &result);
friend VDebug& operator<<(VDebug& os, const VRleImpl& object);
void invert();
result.updateBbox();
}
+void VRleImpl::intersect(const VRect &r, VRle::VRleSpanCb cb, void *userData) const
+{
+ VRect clip = r;
+
+ VRleHelper tresult, tmp_obj;
+ std::array<VRle::Span,256> array;
+
+ //setup the tresult object
+ tresult.size = array.size();
+ tresult.alloc = array.size();
+ tresult.spans = array.data();
+
+ // setup tmp object
+ tmp_obj.size = m_spans.size();
+ tmp_obj.spans = const_cast<VRle::Span *>(m_spans.data());
+
+ // run till all the spans are processed
+ while (tmp_obj.size)
+ {
+ rleIntersectWithRect(clip, &tmp_obj, &tresult);
+ if (tresult.size) {
+ cb(tresult.size, tresult.spans, userData);
+ }
+ tresult.size = 0;
+ }
+}
+
void VRleImpl::intersected(const VRleImpl &clip, VRleImpl &result)
{
VRleHelper tresult, tmp_obj, tmp_clip;
-void VRle::intersected(const VRect &r, VRleSpanCb cb, void *userData)
+void VRle::intersect(const VRect &r, VRleSpanCb cb, void *userData) const
{
- //TODO Implement
+ d->impl.intersect(r, cb, userData);
}
void translate(int x, int y);
VRle intersected(const VRect &r) const;
VRle intersected(const VRle &other) const;
- void intersected(const VRect &r, VRleSpanCb cb, void *userData);
+ void intersect(const VRect &r, VRleSpanCb cb, void *userData) const;
VRle &intersect(const VRect &r);
int size() const;
const VRle::Span* data() const;