From: subhransu mohanty Date: Fri, 31 May 2019 00:40:08 +0000 (+0900) Subject: vector: keep a shared reference to cached color table X-Git-Tag: submit/tizen/20190619.051039~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ca9b0b49806eed2d138998858ff3b517d2f6f53;p=platform%2Fcore%2Fuifw%2Flottie-player.git vector: keep a shared reference to cached color table --- diff --git a/src/vector/vdrawhelper.cpp b/src/vector/vdrawhelper.cpp index 9c79372..ebe4e38 100644 --- a/src/vector/vdrawhelper.cpp +++ b/src/vector/vdrawhelper.cpp @@ -59,18 +59,16 @@ class VGradientCache { public: - struct CacheInfo : public VSpanData::Pinnable { + struct CacheInfo : public VColorTable { inline CacheInfo(VGradientStops s) : stops(std::move(s)) {} - uint32_t buffer32[VGradient::colorTableSize]; VGradientStops stops; - bool alpha{true}; }; - typedef std::unordered_multimap> - VGradientColorTableHash; + using VGradientColorTableHash = std::unordered_multimap>; + bool generateGradientColorTable(const VGradientStops &stops, float alpha, uint32_t *colorTable, int size); - inline const std::shared_ptr getBuffer( + inline const std::shared_ptr getBuffer( const VGradient &gradient) { uint64_t hash_val = 0; @@ -748,9 +746,9 @@ void VSpanData::setup(const VBrush &brush, VPainter::CompositionMode /*mode*/, break; case VBrush::Type::LinearGradient: { mType = VSpanData::Type::LinearGradient; - auto cacheInfo = VGradientCacheInstance.getBuffer(*brush.mGradient); - mGradient.mColorTable = cacheInfo->buffer32; - mGradient.mColorTableAlpha = cacheInfo->alpha; + mColorTable = VGradientCacheInstance.getBuffer(*brush.mGradient); + mGradient.mColorTable = mColorTable->buffer32; + mGradient.mColorTableAlpha = mColorTable->alpha; mGradient.linear.x1 = brush.mGradient->linear.x1; mGradient.linear.y1 = brush.mGradient->linear.y1; mGradient.linear.x2 = brush.mGradient->linear.x2; @@ -761,9 +759,9 @@ void VSpanData::setup(const VBrush &brush, VPainter::CompositionMode /*mode*/, } case VBrush::Type::RadialGradient: { mType = VSpanData::Type::RadialGradient; - auto cacheInfo = VGradientCacheInstance.getBuffer(*brush.mGradient); - mGradient.mColorTable = cacheInfo->buffer32; - mGradient.mColorTableAlpha = cacheInfo->alpha; + mColorTable = VGradientCacheInstance.getBuffer(*brush.mGradient); + mGradient.mColorTable = mColorTable->buffer32; + mGradient.mColorTableAlpha = mColorTable->alpha; mGradient.radial.cx = brush.mGradient->radial.cx; mGradient.radial.cy = brush.mGradient->radial.cy; mGradient.radial.fx = brush.mGradient->radial.fx; diff --git a/src/vector/vdrawhelper.h b/src/vector/vdrawhelper.h index 0653772..93710bb 100644 --- a/src/vector/vdrawhelper.h +++ b/src/vector/vdrawhelper.h @@ -138,11 +138,13 @@ struct VBitmapData int const_alpha; }; +struct VColorTable +{ + uint32_t buffer32[VGradient::colorTableSize]; + bool alpha{true}; +}; + struct VSpanData { - class Pinnable { - protected: - ~Pinnable() = default; - }; enum class Type { None, Solid, LinearGradient, RadialGradient, Texture }; void updateSpanFunc(); @@ -174,7 +176,7 @@ struct VSpanData { ProcessRleSpan mBlendFunc; ProcessRleSpan mUnclippedBlendFunc; VSpanData::Type mType; - std::shared_ptr mCachedGradient; + std::shared_ptr mColorTable{nullptr}; VPoint mOffset; // offset to the subsurface VSize mDrawableSize;// suburface size union {