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

Commit 8bc2d056 authored by Derek Sollenberger's avatar Derek Sollenberger Committed by Android (Google) Code Review
Browse files

Merge "Create proxy between Skia's SkCanvas and the framework Canvas."

parents c9adb14a 1db141f9
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -122,11 +122,6 @@ public class Picture {
     * @param canvas  The picture is drawn to this canvas
     */
    public void draw(Canvas canvas) {
        if (canvas.isHardwareAccelerated()) {
            throw new IllegalArgumentException(
                    "Picture playback is only supported on software canvas.");
        }

        if (mRecordingCanvas != null) {
            endRecording();
        }
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ LOCAL_SRC_FILES := \
    ResourceCache.cpp \
    ShadowTessellator.cpp \
    SkiaCanvas.cpp \
    SkiaCanvasProxy.cpp \
    SkiaShader.cpp \
    Snapshot.cpp \
    SpotShadow.cpp \
+8 −8
Original line number Diff line number Diff line
@@ -42,14 +42,14 @@ public:
     */
    static Canvas* create_canvas(SkCanvas* skiaCanvas);

    // TODO: enable HWUI to either create similar canvas wrapper or subclass
    //       directly from Canvas
    //static Canvas* create_canvas(uirenderer::Renderer* renderer);

    // TODO: this is a temporary affordance until all necessary logic can be
    //       moved within this interface! Further, the return value should
    //       NOT be unref'd and is valid until this canvas is destroyed or a
    //       new bitmap is set.
    /**
     *  Provides a Skia SkCanvas interface that acts as a proxy to this Canvas.
     *  It is useful for testing and clients (e.g. Picture/Movie) that expect to
     *  draw their contents into an SkCanvas.
     *
     *  Further, the returned SkCanvas should NOT be unref'd and is valid until
     *  this canvas is destroyed or a new bitmap is set.
     */
    virtual SkCanvas* asSkCanvas() = 0;

    virtual void setBitmap(SkBitmap* bitmap, bool copyState) = 0;
+10 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ DisplayListData* DisplayListRenderer::finishRecording() {
    mPathMap.clear();
    DisplayListData* data = mDisplayListData;
    mDisplayListData = nullptr;
    mSkiaCanvasProxy.reset(nullptr);
    return data;
}

@@ -94,6 +95,15 @@ void DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
    mDisplayListData->functors.add(functor);
}

SkCanvas* DisplayListRenderer::asSkCanvas() {
    LOG_ALWAYS_FATAL_IF(!mDisplayListData,
            "attempting to get an SkCanvas when we are not recording!");
    if (!mSkiaCanvasProxy) {
        mSkiaCanvasProxy.reset(new SkiaCanvasProxy(this));
    }
    return mSkiaCanvasProxy.get();
}

int DisplayListRenderer::save(SkCanvas::SaveFlags flags) {
    addStateOp(new (alloc()) SaveOp((int) flags));
    return mState.save((int) flags);
+4 −4
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "Canvas.h"
#include "CanvasState.h"
#include "DisplayList.h"
#include "SkiaCanvasProxy.h"
#include "RenderNode.h"
#include "Renderer.h"
#include "ResourceCache.h"
@@ -136,10 +137,8 @@ public:
// ----------------------------------------------------------------------------
// android/graphics/Canvas interface
// ----------------------------------------------------------------------------
    virtual SkCanvas* asSkCanvas() override {
        LOG_ALWAYS_FATAL("DisplayListRenderer has no SkCanvas");
        return nullptr;
    }
    virtual SkCanvas* asSkCanvas() override;

    virtual void setBitmap(SkBitmap* bitmap, bool copyState) override {
        LOG_ALWAYS_FATAL("DisplayListRenderer is not backed by a bitmap.");
    }
@@ -244,6 +243,7 @@ public:
private:

    CanvasState mState;
    std::unique_ptr<SkiaCanvasProxy> mSkiaCanvasProxy;

    enum DeferredBarrierType {
        kBarrier_None,
Loading