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

Commit 8ab756db authored by Jerome Gaillard's avatar Jerome Gaillard
Browse files

Add RenderProxy to host builds of hwui

This makes RenderProxy and DrawFrameTask compile on host.

Bug: 322360037
Test: build libhwui on host
Change-Id: I509519e6838ed250c1a1a68390e5e16769427f63
parent d26915c2
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -541,7 +541,9 @@ cc_defaults {
        "pipeline/skia/TransformCanvas.cpp",
        "pipeline/skia/TransformCanvas.cpp",
        "renderstate/RenderState.cpp",
        "renderstate/RenderState.cpp",
        "renderthread/CanvasContext.cpp",
        "renderthread/CanvasContext.cpp",
        "renderthread/DrawFrameTask.cpp",
        "renderthread/Frame.cpp",
        "renderthread/Frame.cpp",
        "renderthread/RenderProxy.cpp",
        "renderthread/RenderTask.cpp",
        "renderthread/RenderTask.cpp",
        "renderthread/TimeLord.cpp",
        "renderthread/TimeLord.cpp",
        "hwui/AnimatedImageDrawable.cpp",
        "hwui/AnimatedImageDrawable.cpp",
@@ -620,13 +622,11 @@ cc_defaults {
                "pipeline/skia/VkFunctorDrawable.cpp",
                "pipeline/skia/VkFunctorDrawable.cpp",
                "pipeline/skia/VkInteropFunctorDrawable.cpp",
                "pipeline/skia/VkInteropFunctorDrawable.cpp",
                "renderthread/CacheManager.cpp",
                "renderthread/CacheManager.cpp",
                "renderthread/DrawFrameTask.cpp",
                "renderthread/EglManager.cpp",
                "renderthread/EglManager.cpp",
                "renderthread/ReliableSurface.cpp",
                "renderthread/ReliableSurface.cpp",
                "renderthread/RenderEffectCapabilityQuery.cpp",
                "renderthread/RenderEffectCapabilityQuery.cpp",
                "renderthread/VulkanManager.cpp",
                "renderthread/VulkanManager.cpp",
                "renderthread/VulkanSurface.cpp",
                "renderthread/VulkanSurface.cpp",
                "renderthread/RenderProxy.cpp",
                "renderthread/RenderThread.cpp",
                "renderthread/RenderThread.cpp",
                "renderthread/HintSessionWrapper.cpp",
                "renderthread/HintSessionWrapper.cpp",
                "service/GraphicsStatsService.cpp",
                "service/GraphicsStatsService.cpp",
+2 −8
Original line number Original line Diff line number Diff line
@@ -17,13 +17,11 @@
#pragma once
#pragma once


#include <private/hwui/WebViewFunctor.h>
#include <private/hwui/WebViewFunctor.h>
#ifdef __ANDROID__ // Layoutlib does not support render thread
#include <renderthread/RenderProxy.h>
#include <renderthread/RenderProxy.h>
#endif

#include <utils/LightRefBase.h>
#include <utils/LightRefBase.h>
#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/StrongPointer.h>
#include <utils/StrongPointer.h>

#include <mutex>
#include <mutex>
#include <vector>
#include <vector>


@@ -38,11 +36,7 @@ public:


    class Handle : public LightRefBase<Handle> {
    class Handle : public LightRefBase<Handle> {
    public:
    public:
        ~Handle() {
        ~Handle() { renderthread::RenderProxy::destroyFunctor(id()); }
#ifdef __ANDROID__ // Layoutlib does not support render thread
            renderthread::RenderProxy::destroyFunctor(id());
#endif
        }


        int id() const { return mReference.id(); }
        int id() const { return mReference.id(); }


+6 −12
Original line number Original line Diff line number Diff line
// #define LOG_NDEBUG 0
// #define LOG_NDEBUG 0
#include "Bitmap.h"
#include "Bitmap.h"


#include <android-base/unique_fd.h>
#include <hwui/Bitmap.h>
#include <hwui/Bitmap.h>
#include <hwui/Paint.h>
#include <hwui/Paint.h>
#include <inttypes.h>
#include <renderthread/RenderProxy.h>
#include <string.h>

#include <memory>


#include "CreateJavaOutputStreamAdaptor.h"
#include "CreateJavaOutputStreamAdaptor.h"
#include "Gainmap.h"
#include "Gainmap.h"
@@ -24,16 +30,6 @@
#include "SkTypes.h"
#include "SkTypes.h"
#include "android_nio_utils.h"
#include "android_nio_utils.h"


#ifdef __ANDROID__ // Layoutlib does not support graphic buffer, parcel or render thread
#include <android-base/unique_fd.h>
#include <renderthread/RenderProxy.h>
#endif

#include <inttypes.h>
#include <string.h>

#include <memory>

#define DEBUG_PARCEL 0
#define DEBUG_PARCEL 0


static jclass   gBitmap_class;
static jclass   gBitmap_class;
@@ -1105,11 +1101,9 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle, jlong bm1Ha
}
}


static void Bitmap_prepareToDraw(JNIEnv* env, jobject, jlong bitmapPtr) {
static void Bitmap_prepareToDraw(JNIEnv* env, jobject, jlong bitmapPtr) {
#ifdef __ANDROID__ // Layoutlib does not support render thread
    LocalScopedBitmap bitmapHandle(bitmapPtr);
    LocalScopedBitmap bitmapHandle(bitmapPtr);
    if (!bitmapHandle.valid()) return;
    if (!bitmapHandle.valid()) return;
    android::uirenderer::renderthread::RenderProxy::prepareToDraw(bitmapHandle->bitmap());
    android::uirenderer::renderthread::RenderProxy::prepareToDraw(bitmapHandle->bitmap());
#endif
}
}


static jint Bitmap_getAllocationByteCount(JNIEnv* env, jobject, jlong bitmapPtr) {
static jint Bitmap_getAllocationByteCount(JNIEnv* env, jobject, jlong bitmapPtr) {
+4 −11
Original line number Original line Diff line number Diff line
@@ -16,22 +16,19 @@


#include "GraphicsJNI.h"
#include "GraphicsJNI.h"


#ifdef __ANDROID__ // Layoutlib does not support Looper and device properties
#ifdef __ANDROID__  // Layoutlib does not support Looper
#include <utils/Looper.h>
#include <utils/Looper.h>
#endif
#endif


#include <SkRegion.h>
#include <CanvasProperty.h>
#include <SkRuntimeEffect.h>

#include <Rect.h>
#include <Rect.h>
#include <RenderNode.h>
#include <RenderNode.h>
#include <CanvasProperty.h>
#include <SkRegion.h>
#include <SkRuntimeEffect.h>
#include <hwui/Canvas.h>
#include <hwui/Canvas.h>
#include <hwui/Paint.h>
#include <hwui/Paint.h>
#include <minikin/Layout.h>
#include <minikin/Layout.h>
#ifdef __ANDROID__ // Layoutlib does not support RenderThread
#include <renderthread/RenderProxy.h>
#include <renderthread/RenderProxy.h>
#endif


namespace android {
namespace android {


@@ -85,11 +82,7 @@ static void android_view_DisplayListCanvas_resetDisplayListCanvas(CRITICAL_JNI_P
}
}


static jint android_view_DisplayListCanvas_getMaxTextureSize(JNIEnv*, jobject) {
static jint android_view_DisplayListCanvas_getMaxTextureSize(JNIEnv*, jobject) {
#ifdef __ANDROID__ // Layoutlib does not support RenderProxy (RenderThread)
    return android::uirenderer::renderthread::RenderProxy::maxTextureSize();
    return android::uirenderer::renderthread::RenderProxy::maxTextureSize();
#else
    return 4096;
#endif
}
}


static void android_view_DisplayListCanvas_enableZ(CRITICAL_JNI_PARAMS_COMMA jlong canvasPtr,
static void android_view_DisplayListCanvas_enableZ(CRITICAL_JNI_PARAMS_COMMA jlong canvasPtr,
+4 −0
Original line number Original line Diff line number Diff line
@@ -140,12 +140,14 @@ void DrawFrameTask::run() {
    if (CC_LIKELY(canDrawThisFrame)) {
    if (CC_LIKELY(canDrawThisFrame)) {
        context->draw(solelyTextureViewUpdates);
        context->draw(solelyTextureViewUpdates);
    } else {
    } else {
#ifdef __ANDROID__
        // Do a flush in case syncFrameState performed any texture uploads. Since we skipped
        // Do a flush in case syncFrameState performed any texture uploads. Since we skipped
        // the draw() call, those uploads (or deletes) will end up sitting in the queue.
        // the draw() call, those uploads (or deletes) will end up sitting in the queue.
        // Do them now
        // Do them now
        if (GrDirectContext* grContext = mRenderThread->getGrContext()) {
        if (GrDirectContext* grContext = mRenderThread->getGrContext()) {
            grContext->flushAndSubmit();
            grContext->flushAndSubmit();
        }
        }
#endif
        // wait on fences so tasks don't overlap next frame
        // wait on fences so tasks don't overlap next frame
        context->waitOnFences();
        context->waitOnFences();
    }
    }
@@ -176,11 +178,13 @@ bool DrawFrameTask::syncFrameState(TreeInfo& info) {
    bool canDraw = mContext->makeCurrent();
    bool canDraw = mContext->makeCurrent();
    mContext->unpinImages();
    mContext->unpinImages();


#ifdef __ANDROID__
    for (size_t i = 0; i < mLayers.size(); i++) {
    for (size_t i = 0; i < mLayers.size(); i++) {
        if (mLayers[i]) {
        if (mLayers[i]) {
            mLayers[i]->apply();
            mLayers[i]->apply();
        }
        }
    }
    }
#endif


    mLayers.clear();
    mLayers.clear();
    mContext->setContentDrawBounds(mContentDrawBounds);
    mContext->setContentDrawBounds(mContentDrawBounds);
Loading