offscreen rendering of shape layer 57/296457/4 accepted/tizen_8.0_unified accepted/tizen/8.0/unified/20231005.094232 accepted/tizen/unified/20230801.174213 tizen_8.0_m2_release
authorjoogab.yun <joogab.yun@samsung.com>
Fri, 28 Jul 2023 05:34:30 +0000 (14:34 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Mon, 31 Jul 2023 01:40:15 +0000 (10:40 +0900)
Revert "lottieitem: Added alpha in Fill::updateContent method."

This reverts commit fb12ddc8d0195672aa1ade6e181c8b26378ad10d.

Revert "Update color blending style in LottieItem"

This reverts commit 8cb666211b859267ec530ff8798c08c29aefecaf.

Change-Id: I27d3213b04514f6c60eb817aa924ca74103c5b09

src/lottie/lottieitem.cpp
src/lottie/lottieitem.h

index d6c9ed3..f5c8c2f 100644 (file)
@@ -165,28 +165,6 @@ bool renderer::Composition::render(const rlottie::Surface &surface)
     painter.setDrawRegion(
         VRect(int(surface.drawRegionPosX()), int(surface.drawRegionPosY()),
               int(surface.drawRegionWidth()), int(surface.drawRegionHeight())));
-
-    // layer surface should be created if it is not created already or its size
-    // is changed.
-    bool isLayerSurfaceCreated = mSurfaceCache.is_layer_surface_created();
-    bool isLayerSurfaceSizeChanged =
-        isLayerSurfaceCreated &&
-        (mSurfaceCache.get_layer_surface()->width() != surface.width() ||
-         mSurfaceCache.get_layer_surface()->height() != surface.height());
-
-    if (!isLayerSurfaceCreated || isLayerSurfaceSizeChanged) {
-        if (isLayerSurfaceCreated && isLayerSurfaceSizeChanged)
-            mSurfaceCache.delete_layer_surface();
-
-        mSurfaceCache.create_layer_surface(surface.width(), surface.height(),
-                                           VBitmap::Format::ARGB32_Premultiplied);
-
-        // set layer draw region
-        mSurfaceCache.get_layer_painter()->setDrawRegion(
-            VRect(int(surface.drawRegionPosX()), int(surface.drawRegionPosY()),
-                  int(surface.drawRegionWidth()), int(surface.drawRegionHeight())));
-    }
-
     mRootLayer->render(&painter, {}, {}, mSurfaceCache);
     painter.end();
     return true;
@@ -236,7 +214,7 @@ void renderer::Mask::preprocess(const VRect &clip)
 }
 
 void renderer::Layer::render(VPainter *painter, const VRle &inheritMask,
-                             const VRle &matteRle, SurfaceCache &cache)
+                             const VRle &matteRle, SurfaceCache &)
 {
     auto renderlist = renderList();
 
@@ -252,42 +230,31 @@ void renderer::Layer::render(VPainter *painter, const VRle &inheritMask,
         mask = inheritMask;
     }
 
-    VPainter *usedPainter = painter;
-
-    if (cache.get_layer_painter() != nullptr) {
-        usedPainter = cache.get_layer_painter();
-        usedPainter->begin(cache.get_layer_surface());
-    }
-
     for (auto &i : renderlist) {
-        usedPainter->setBrush(i->mBrush);
+        painter->setBrush(i->mBrush);
         VRle rle = i->rle();
         if (matteRle.empty()) {
             if (mask.empty()) {
                 // no mask no matte
-                usedPainter->drawRle(VPoint(), rle);
+                painter->drawRle(VPoint(), rle);
             } else {
                 // only mask
-                usedPainter->drawRle(rle, mask);
+                painter->drawRle(rle, mask);
             }
+
         } else {
             if (!mask.empty()) rle = rle & mask;
 
             if (rle.empty()) continue;
             if (matteType() == model::MatteType::AlphaInv) {
                 rle = rle - matteRle;
-                usedPainter->drawRle(VPoint(), rle);
+                painter->drawRle(VPoint(), rle);
             } else {
                 // render with matteRle as clip.
-                usedPainter->drawRle(rle, matteRle);
+                painter->drawRle(rle, matteRle);
             }
         }
     }
-
-    if (cache.get_layer_painter() != nullptr) {
-        usedPainter->end();
-        painter->drawBitmap(VPoint(), *cache.get_layer_surface(), mCombinedAlpha * 255.0f);
-    }
 }
 
 void renderer::LayerMask::preprocess(const VRect &clip)
@@ -869,7 +836,7 @@ renderer::ShapeLayer::ShapeLayer(model::Layer *layerData,
 
 void renderer::ShapeLayer::updateContent()
 {
-    mRoot->update(frameNo(), combinedMatrix(), combinedAlpha(), flag());
+    mRoot->update(frameNo(), combinedMatrix(), 1.0f , flag());
 
     if (mLayerData->hasPathOperator()) {
         mRoot->applyTrim();
@@ -896,6 +863,27 @@ renderer::DrawableList renderer::ShapeLayer::renderList()
     return {mDrawableList.data(), mDrawableList.size()};
 }
 
+void renderer::ShapeLayer::render(VPainter *painter, const VRle &inheritMask,
+                                 const VRle &matteRle, SurfaceCache &cache)
+{
+    if (vIsZero(combinedAlpha())) return;
+
+    if (vCompare(combinedAlpha(), 1.0)) {
+        Layer::render(painter, inheritMask, matteRle, cache);
+    } else {
+        //do offscreen rendering
+        VSize    size = painter->clipBoundingRect().size();
+        VPainter srcPainter;
+        VBitmap srcBitmap = cache.make_surface(size.width(), size.height());
+        srcPainter.begin(&srcBitmap);
+        Layer::render(&srcPainter, inheritMask, matteRle, cache);
+        srcPainter.end();
+        painter->drawBitmap(VPoint(), srcBitmap,
+                            uint8_t(combinedAlpha() * 255.0f));
+        cache.release_surface(srcBitmap);
+    }
+}
+
 bool renderer::Group::resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
                                      LOTVariant &value)
 {
@@ -991,7 +979,7 @@ void renderer::Group::update(int frameNo, const VMatrix &parentMatrix,
 
         mMatrix = m;
 
-        alpha = mModel.transform()->opacity(frameNo);
+        alpha = parentAlpha * mModel.transform()->opacity(frameNo);
         if (!vCompare(alpha, parentAlpha)) {
             newFlag |= DirtyFlagBit::Alpha;
         }
index 587f10b..b070897 100644 (file)
@@ -106,31 +106,9 @@ public:
     }
 
     void release_surface(VBitmap &surface) { mCache.push_back(surface); }
-    bool is_layer_surface_created() const { return mIsLayerBitmapCreated; }
-    void create_layer_surface(size_t width, size_t height, VBitmap::Format format)
-    {
-        if (mIsLayerBitmapCreated) return;
-
-        mLayerBitmap = std::make_unique<VBitmap>(width, height, format);
-        mBitmapPainter = std::make_unique<VPainter>(mLayerBitmap.get());
-        mIsLayerBitmapCreated = true;
-    }
-    void delete_layer_surface()
-    {
-        if (!mIsLayerBitmapCreated) return;
-
-        mLayerBitmap.reset();
-        mBitmapPainter.reset();
-        mIsLayerBitmapCreated = false;
-    }
-    VPainter* get_layer_painter() const { return mBitmapPainter.get(); }
-    VBitmap* get_layer_surface() const { return mLayerBitmap.get(); }
 
 private:
     std::vector<VBitmap> mCache;
-    std::unique_ptr<VBitmap>   mLayerBitmap{nullptr};
-    std::unique_ptr<VPainter>  mBitmapPainter{nullptr};
-    bool                       mIsLayerBitmapCreated{false};
 };
 
 class Drawable final : public VDrawable {
@@ -341,6 +319,8 @@ public:
     void         buildLayerNode() final;
     bool         resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
                                 LOTVariant &value) override;
+    void         render(VPainter *painter, const VRle &mask, const VRle &matteRle,
+                        SurfaceCache &cache) final;
 
 protected:
     void                     preprocessStage(const VRect &clip) final;