From: subhransu mohanty Date: Thu, 19 Sep 2019 07:45:45 +0000 (+0900) Subject: vector/rle: added operator&=() api to VRle X-Git-Tag: submit/tizen/20190923.005744~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=23bcedabbff4f6bd7403ddc88bed686523813d22;p=platform%2Fcore%2Fuifw%2Flottie-player.git vector/rle: added operator&=() api to VRle --- diff --git a/src/vector/vrle.cpp b/src/vector/vrle.cpp index d56710d..5f165df 100644 --- a/src/vector/vrle.cpp +++ b/src/vector/vrle.cpp @@ -728,4 +728,26 @@ VRle VRle::toRle(const VRect &rect) return result; } +/* + * this api makes use of thread_local temporary + * buffer to avoid creating intermediate temporary rle buffer + * the scratch buffer object will grow its size on demand + * so that future call won't need any more memory allocation. + * this function is thread safe as it uses thread_local variable + * which is unique per thread. + */ +static thread_local VRle::VRleData Scratch_Object; + +void VRle::operator&=(const VRle &o) +{ + if (empty()) return; + if (o.empty()) { + reset(); + return; + } + Scratch_Object.reset(); + Scratch_Object.opIntersect(d.read(), o.d.read()); + d.write() = Scratch_Object; +} + V_END_NAMESPACE diff --git a/src/vector/vrle.h b/src/vector/vrle.h index 6ba92d6..80cb300 100644 --- a/src/vector/vrle.h +++ b/src/vector/vrle.h @@ -51,6 +51,7 @@ public: void intersect(const VRect &r, VRleSpanCb cb, void *userData) const; void intersect(const VRle &rle, VRleSpanCb cb, void *userData) const; + void operator&=(const VRle &o); VRle operator&(const VRle &o) const; VRle operator-(const VRle &o) const; VRle operator+(const VRle &o) const; @@ -62,7 +63,7 @@ public: size_t refCount() const { return d.refCount();} void clone(const VRle &o); -private: +public: struct VRleData { enum class OpCode { Add, @@ -88,6 +89,7 @@ private: mutable VRect mBbox; mutable bool mBboxDirty = true; }; +private: friend void opIntersectHelper(const VRle::VRleData &obj1, const VRle::VRleData &obj2, VRle::VRleSpanCb cb, void *userData);