Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea1fe9b9 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Update SkiaDisplayList to use the modified SkLiteDL

SkLiteDL is no longer refcounted or a subclass of SkDrawable.

Test: on device testing in SkiaGL mode
Change-Id: I9ad53d764a26ab382d80d54908325962f2075802
parent 23e6ad0e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -197,12 +197,12 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const {
            if (needsLayer) {
                canvas->saveLayer(bounds, &paint);
            }
            canvas->drawDrawable(displayList->mDrawable.get());
            displayList->draw(canvas);
            if (needsLayer) {
                canvas->restore();
            }
        } else {
            canvas->drawDrawable(displayList->mDrawable.get());
            displayList->draw(canvas);
        }
    }
}
+4 −8
Original line number Diff line number Diff line
@@ -27,10 +27,6 @@ namespace android {
namespace uirenderer {
namespace skiapipeline {

SkiaDisplayList::SkiaDisplayList(SkRect bounds) : mDrawable(SkLiteDL::New(bounds)) {
    SkASSERT(projectionReceiveIndex == -1);
}

void SkiaDisplayList::syncContents() {
    for (auto& functor : mChildFunctors) {
        functor.syncFunctor();
@@ -41,7 +37,7 @@ void SkiaDisplayList::syncContents() {
}

bool SkiaDisplayList::reuseDisplayList(RenderNode* node, renderthread::CanvasContext* context) {
    reset(SkRect::MakeEmpty());
    reset();
    node->attachAvailableList(this);
    return true;
}
@@ -102,10 +98,10 @@ bool SkiaDisplayList::prepareListAndChildren(TreeObserver& observer, TreeInfo& i
    return isDirty;
}

void SkiaDisplayList::reset(SkRect bounds) {
void SkiaDisplayList::reset() {
    mProjectionReceiver = nullptr;

    mDrawable->reset(bounds);
    mDisplayList.reset();

    mMutableImages.clear();
    mVectorDrawables.clear();
@@ -119,7 +115,7 @@ void SkiaDisplayList::reset(SkRect bounds) {

void SkiaDisplayList::output(std::ostream& output, uint32_t level) {
    DumpOpsCanvas canvas(output, level, *this);
    mDrawable->draw(&canvas, nullptr);
    mDisplayList.draw(&canvas);
}

}; // namespace skiapipeline
+16 −10
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@

#include <deque>
#include <SkLiteDL.h>
#include <SkPictureRecorder.h>
#include <SkLiteRecorder.h>

namespace android {
namespace uirenderer {
@@ -39,22 +39,22 @@ namespace skiapipeline {
 */
class SkiaDisplayList : public DisplayList {
public:
    SkiaDisplayList(SkRect bounds);
    SkiaDisplayList() { SkASSERT(projectionReceiveIndex == -1); }
    virtual ~SkiaDisplayList() {
        /* Given that we are using a LinearStdAllocator to store some of the
         * SkDrawable contents we must ensure that any other object that is
         * holding a reference to those drawables is destroyed prior to their
         * deletion.
         */
        mDrawable.reset();
        mDisplayList.reset();
    }

    /**
     * This resets the DisplayList so that it behaves as if the object were newly
     * constructed with the provided bounds.  The reuse avoids any overhead
     * associated with destroying the SkLiteDL as well as the deques and vectors.
     * constructed.  The reuse avoids any overhead associated with destroying
     * the SkLiteDL as well as the deques and vectors.
     */
    void reset(SkRect bounds);
    void reset();

    /**
     * Use the linear allocator to create any SkDrawables needed by the display
@@ -72,7 +72,7 @@ public:
    /**
     * Returns true if the DisplayList does not have any recorded content
     */
    bool isEmpty() const override { return mDrawable->empty(); }
    bool isEmpty() const override { return mDisplayList.empty(); }

    /**
     * Returns true if this list directly contains a GLFunctor drawing command.
@@ -126,18 +126,24 @@ public:
     */
    inline bool containsProjectionReceiver() const { return mProjectionReceiver; }

    void attachRecorder(SkLiteRecorder* recorder, const SkIRect& bounds) {
        recorder->reset(&mDisplayList, bounds);
    }

    void draw(SkCanvas* canvas) { mDisplayList.draw(canvas); }

    void output(std::ostream& output, uint32_t level) override;

    /**
     * We use std::deque here because (1) we need to iterate through these
     * elements and (2) mDrawable holds pointers to the elements, so they cannot
     * relocate.
     * elements and (2) mDisplayList holds pointers to the elements, so they
     * cannot relocate.
     */
    std::deque<RenderNodeDrawable> mChildNodes;
    std::deque<GLFunctorDrawable> mChildFunctors;
    std::vector<SkImage*> mMutableImages;
    std::vector<VectorDrawableRoot*> mVectorDrawables;
    sk_sp<SkLiteDL> mDrawable;
    SkLiteDL mDisplayList;

    //mProjectionReceiver points to a child node (stored in mChildNodes) that is as a projection
    //receiver. It is set at record time and used at both prepare and draw tree traversals to
+3 −6
Original line number Diff line number Diff line
@@ -39,14 +39,11 @@ void SkiaRecordingCanvas::initDisplayList(uirenderer::RenderNode* renderNode, in
    if (renderNode) {
        mDisplayList = renderNode->detachAvailableList();
    }
    SkRect bounds = SkRect::MakeWH(width, height);
    if (mDisplayList) {
        mDisplayList->reset(bounds);
    } else {
        mDisplayList.reset(new SkiaDisplayList(bounds));
    if (!mDisplayList) {
        mDisplayList.reset(new SkiaDisplayList());
    }

    mRecorder.reset(mDisplayList->mDrawable.get());
    mDisplayList->attachRecorder(&mRecorder, SkIRect::MakeWH(width, height));
    SkiaCanvas::reset(&mRecorder);
}

+2 −2
Original line number Diff line number Diff line
@@ -44,9 +44,9 @@ TEST(RenderNodeDrawable, create) {
                canvas.drawColor(Color::Red_500, SkBlendMode::kSrcOver);
            });

    auto skLiteDL = SkLiteDL::New(SkRect::MakeWH(1, 1));
    SkLiteDL skLiteDL;
    SkLiteRecorder canvas;
    canvas.reset(skLiteDL.get());
    canvas.reset(&skLiteDL, SkIRect::MakeWH(1, 1));
    canvas.translate(100, 100);
    RenderNodeDrawable drawable(rootNode.get(), &canvas);

Loading