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

Commit dd37c987 authored by Jerome Gaillard's avatar Jerome Gaillard
Browse files

Remove unnecessary #ifdefs

This enables more functionalities of RootRenderNode and associated
classes on host by removing now unnecessary #ifdefs.

Bug: 322360037
Test: build libhwui on host
Change-Id: I95c9e7c76ceec47e0573c7799160bde3f2a579ae
parent 8ab756db
Loading
Loading
Loading
Loading
+8 −14
Original line number Diff line number Diff line
@@ -16,18 +16,6 @@

#include "RenderNode.h"

#include "DamageAccumulator.h"
#include "Debug.h"
#include "Properties.h"
#include "TreeInfo.h"
#include "VectorDrawable.h"
#include "private/hwui/WebViewFunctor.h"
#ifdef __ANDROID__
#include "renderthread/CanvasContext.h"
#else
#include "DamageAccumulator.h"
#include "pipeline/skia/SkiaDisplayList.h"
#endif
#include <SkPathOps.h>
#include <gui/TraceUtils.h>
#include <ui/FatVector.h>
@@ -37,6 +25,14 @@
#include <sstream>
#include <string>

#include "DamageAccumulator.h"
#include "Debug.h"
#include "Properties.h"
#include "TreeInfo.h"
#include "VectorDrawable.h"
#include "private/hwui/WebViewFunctor.h"
#include "renderthread/CanvasContext.h"

#ifdef __ANDROID__
#include "include/gpu/ganesh/SkImageGanesh.h"
#endif
@@ -186,7 +182,6 @@ void RenderNode::prepareLayer(TreeInfo& info, uint32_t dirtyMask) {
}

void RenderNode::pushLayerUpdate(TreeInfo& info) {
#ifdef __ANDROID__ // Layoutlib does not support CanvasContext and Layers
    LayerType layerType = properties().effectiveLayerType();
    // If we are not a layer OR we cannot be rendered (eg, view was detached)
    // we need to destroy any Layers we may have had previously
@@ -218,7 +213,6 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) {
    // That might be us, so tell CanvasContext that this layer is in the
    // tree and should not be destroyed.
    info.canvasContext.markLayerInUse(this);
#endif
}

/**
+6 −18
Original line number Diff line number Diff line
@@ -18,11 +18,12 @@

#ifdef __ANDROID__ // Layoutlib does not support Looper (windows)
#include <utils/Looper.h>
#else
#include "utils/MessageHandler.h"
#endif

namespace android::uirenderer {

#ifdef __ANDROID__ // Layoutlib does not support Looper
class FinishAndInvokeListener : public MessageHandler {
public:
    explicit FinishAndInvokeListener(PropertyValuesAnimatorSet* anim) : mAnimator(anim) {
@@ -237,9 +238,13 @@ void RootRenderNode::detachVectorDrawableAnimator(PropertyValuesAnimatorSet* ani
        // user events, in which case the already posted listener's id will become stale, and
        // the onFinished callback will then be ignored.
        sp<FinishAndInvokeListener> message = new FinishAndInvokeListener(anim);
#ifdef __ANDROID__  // Layoutlib does not support Looper
        auto looper = Looper::getForThread();
        LOG_ALWAYS_FATAL_IF(looper == nullptr, "Not on a looper thread?");
        looper->sendMessageDelayed(ms2ns(remainingTimeInMs), message, 0);
#else
        message->handleMessage(0);
#endif
        anim->clearOneShotListener();
    }
}
@@ -285,22 +290,5 @@ private:
AnimationContext* ContextFactoryImpl::createAnimationContext(renderthread::TimeLord& clock) {
    return new AnimationContextBridge(clock, mRootNode);
}
#else

void RootRenderNode::prepareTree(TreeInfo& info) {
    info.errorHandler = mErrorHandler.get();
    info.updateWindowPositions = true;
    RenderNode::prepareTree(info);
    info.updateWindowPositions = false;
    info.errorHandler = nullptr;
}

void RootRenderNode::attachAnimatingNode(RenderNode* animatingNode) { }

void RootRenderNode::destroy() { }

void RootRenderNode::addVectorDrawableAnimator(PropertyValuesAnimatorSet* anim) { }

#endif

}  // namespace android::uirenderer
+0 −2
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@ private:
    void detachVectorDrawableAnimator(PropertyValuesAnimatorSet* anim);
};

#ifdef __ANDROID__ // Layoutlib does not support Animations
class ContextFactoryImpl : public IContextFactory {
public:
    explicit ContextFactoryImpl(RootRenderNode* rootNode) : mRootNode(rootNode) {}
@@ -84,6 +83,5 @@ public:
private:
    RootRenderNode* mRootNode;
};
#endif

}  // namespace android::uirenderer
+2 −17
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@
#include <hwui/ImageDecoder.h>
#ifdef __ANDROID__
#include <utils/Looper.h>
#else
#include "utils/MessageHandler.h"
#endif

#include "ColorFilter.h"
@@ -182,23 +184,6 @@ static void AnimatedImageDrawable_nSetRepeatCount(JNIEnv* env, jobject /*clazz*/
    drawable->setRepetitionCount(loopCount);
}

#ifndef __ANDROID__
struct Message {
    Message(int w) {}
};

class MessageHandler : public virtual RefBase {
protected:
    virtual ~MessageHandler() override {}

public:
    /**
     * Handles a message.
     */
    virtual void handleMessage(const Message& message) = 0;
};
#endif

class InvokeListener : public MessageHandler {
public:
    InvokeListener(JNIEnv* env, jobject javaObject) {
+3 −11
Original line number Diff line number Diff line
@@ -15,19 +15,17 @@
 */

#define ATRACE_TAG ATRACE_TAG_VIEW
#include "GraphicsJNI.h"

#include <Animator.h>
#include <DamageAccumulator.h>
#include <Matrix.h>
#include <RenderNode.h>
#ifdef __ANDROID__ // Layoutlib does not support CanvasContext
#include <renderthread/CanvasContext.h>
#endif
#include <TreeInfo.h>
#include <effects/StretchEffect.h>
#include <gui/TraceUtils.h>
#include <hwui/Paint.h>
#include <renderthread/CanvasContext.h>

#include "GraphicsJNI.h"

namespace android {

@@ -640,7 +638,6 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,

            ATRACE_NAME("Update SurfaceView position");

#ifdef __ANDROID__ // Layoutlib does not support CanvasContext
            JNIEnv* env = jnienv();
            // Update the new position synchronously. We cannot defer this to
            // a worker pool to process asynchronously because the UI thread
@@ -669,7 +666,6 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
                env->DeleteGlobalRef(mListener);
                mListener = nullptr;
            }
#endif
        }

        virtual void onPositionLost(RenderNode& node, const TreeInfo* info) override {
@@ -682,7 +678,6 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,

            ATRACE_NAME("SurfaceView position lost");
            JNIEnv* env = jnienv();
#ifdef __ANDROID__ // Layoutlib does not support CanvasContext
            // Update the lost position synchronously. We cannot defer this to
            // a worker pool to process asynchronously because the UI thread
            // may be unblocked by the time a worker thread can process this,
@@ -698,7 +693,6 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
                env->DeleteGlobalRef(mListener);
                mListener = nullptr;
            }
#endif
        }

    private:
@@ -750,7 +744,6 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
                StretchEffectBehavior::Shader) {
                JNIEnv* env = jnienv();

#ifdef __ANDROID__  // Layoutlib does not support CanvasContext
                SkVector stretchDirection = effect->getStretchDirection();
                jboolean keepListening = env->CallStaticBooleanMethod(
                        gPositionListener.clazz, gPositionListener.callApplyStretch, mListener,
@@ -762,7 +755,6 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
                    env->DeleteGlobalRef(mListener);
                    mListener = nullptr;
                }
#endif
            }
        }

Loading