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

Commit 500a0c30 authored by Stan Iliev's avatar Stan Iliev
Browse files

Implement Skia pipelines for OpenGL and Vulkan.

Implement Skia pipelines for OpenGL and Vulkan:
base SkiaPipeline, SkiaOpenGLPipeline and SkiaVulkanPipeline.
Write unit tests for SkiaPipeline.

Test: Built and run manually on angler-eng.
Change-Id: Ie02583426cb3547541ad9bf91700602a6163ff58
parent 253f81b3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -23,7 +23,10 @@ hwui_src_files := \
    pipeline/skia/RenderNodeDrawable.cpp \
    pipeline/skia/ReorderBarrierDrawables.cpp \
    pipeline/skia/SkiaDisplayList.cpp \
    pipeline/skia/SkiaOpenGLPipeline.cpp \
    pipeline/skia/SkiaPipeline.cpp \
    pipeline/skia/SkiaRecordingCanvas.cpp \
    pipeline/skia/SkiaVulkanPipeline.cpp \
    renderstate/Blend.cpp \
    renderstate/MeshState.cpp \
    renderstate/OffscreenBufferPool.cpp \
@@ -296,6 +299,7 @@ LOCAL_SRC_FILES += \
    tests/unit/RenderPropertiesTests.cpp \
    tests/unit/SkiaBehaviorTests.cpp \
    tests/unit/SkiaDisplayListTests.cpp \
    tests/unit/SkiaPipelineTests.cpp \
    tests/unit/SkiaCanvasTests.cpp \
    tests/unit/SnapshotTests.cpp \
    tests/unit/StringUtilsTests.cpp \
+7 −0
Original line number Diff line number Diff line
@@ -41,6 +41,13 @@ void DeviceInfo::initialize() {
    });
}

void DeviceInfo::initialize(int maxTextureSize) {
    std::call_once(sInitializedFlag, [maxTextureSize]() {
        sDeviceInfo = new DeviceInfo();
        sDeviceInfo->mMaxTextureSize = maxTextureSize;
    });
}

void DeviceInfo::load() {
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
}
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public:
    // only call this after GL has been initialized, or at any point if compiled
    // with HWUI_NULL_GPU
    static void initialize();
    static void initialize(int maxTextureSize);

    int maxTextureSize() const { return mMaxTextureSize; }

+21 −9
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include "Matrix.h"
#include "RenderProperties.h"
#include "pipeline/skia/SkiaDisplayList.h"
#include "pipeline/skia/SkiaLayer.h"

#include <vector>

@@ -60,10 +61,6 @@ namespace proto {
class RenderNode;
}

namespace skiapipeline {
    class SkiaDisplayList;
}

/**
 * Primary class for storing recorded canvas commands, as well as per-View/ViewGroup display properties.
 *
@@ -312,14 +309,23 @@ public:
     * Returns true if an offscreen layer from any renderPipeline is attached
     * to this node.
     */
    bool hasLayer() const { return mLayer || mLayerSurface.get(); }
    bool hasLayer() const { return mLayer || mSkiaLayer.get(); }

    /**
     * Used by the RenderPipeline to attach an offscreen surface to the RenderNode.
     * The surface is then will be used to store the contents of a layer.
     */
    void setLayerSurface(sk_sp<SkSurface> layer) { mLayerSurface = layer; }

    void setLayerSurface(sk_sp<SkSurface> layer) {
        if (layer.get()) {
            if (!mSkiaLayer.get()) {
                mSkiaLayer = std::make_unique<skiapipeline::SkiaLayer>();
            }
            mSkiaLayer->layerSurface = std::move(layer);
            mSkiaLayer->inverseTransformInWindow.loadIdentity();
        } else {
            mSkiaLayer.reset();
        }
    }

    /**
     * If the RenderNode is of type LayerType::RenderLayer then this method will
@@ -330,7 +336,13 @@ public:
     * NOTE: this function is only guaranteed to return accurate results after
     *       prepareTree has been run for this RenderNode
     */
    SkSurface* getLayerSurface() const { return mLayerSurface.get(); }
    SkSurface* getLayerSurface() const {
        return mSkiaLayer.get() ? mSkiaLayer->layerSurface.get() : nullptr;
    }

    skiapipeline::SkiaLayer* getSkiaLayer() const {
        return mSkiaLayer.get();
    }

private:
    /**
@@ -346,7 +358,7 @@ private:
     * An offscreen rendering target used to contain the contents this RenderNode
     * when it has been set to draw as a LayerType::RenderLayer.
     */
    sk_sp<SkSurface> mLayerSurface;
    std::unique_ptr<skiapipeline::SkiaLayer> mSkiaLayer;
}; // class RenderNode

} /* namespace uirenderer */
+5 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
#include "RenderNode.h"
#include "MinikinUtils.h"
#include "Paint.h"
#include "Properties.h"
#include "pipeline/skia/SkiaRecordingCanvas.h"
#include "Typeface.h"

#include <SkDrawFilter.h>
@@ -27,6 +29,9 @@
namespace android {

Canvas* Canvas::create_recording_canvas(int width, int height, uirenderer::RenderNode* renderNode) {
    if (uirenderer::Properties::isSkiaEnabled()) {
        return new uirenderer::skiapipeline::SkiaRecordingCanvas(renderNode, width, height);
    }
    return new uirenderer::RecordingCanvas(width, height);
}

Loading