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

Commit 825fa4d5 authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Revert "Make stopped state a first-class thing"" into nyc-dev

parents cf0cc881 eab3f265
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -485,24 +485,14 @@ public final class ThreadedRenderer {
    }

    /**
     * Halts any current rendering into the surface. Use this if it is unclear whether
     * Stops any rendering into the surface. Use this if it is unclear whether
     * or not the surface used by the HardwareRenderer will be changing. It
     * Suspends any rendering into the surface, but will not do any destruction.
     *
     * Any subsequent draws will override the pause, resuming normal operation.
     * Suspends any rendering into the surface, but will not do any destruction
     */
    boolean pauseSurface(Surface surface) {
        return nPauseSurface(mNativeProxy, surface);
    }

    /**
     * Hard stops or resumes rendering into the surface. This flag is used to
     * determine whether or not it is safe to use the given surface *at all*
     */
    void setStopped(boolean stopped) {
        nSetStopped(mNativeProxy, stopped);
    }

    /**
     * Destroys all hardware rendering resources associated with the specified
     * view hierarchy.
@@ -998,7 +988,6 @@ public final class ThreadedRenderer {
    private static native void nInitialize(long nativeProxy, Surface window);
    private static native void nUpdateSurface(long nativeProxy, Surface window);
    private static native boolean nPauseSurface(long nativeProxy, Surface window);
    private static native void nSetStopped(long nativeProxy, boolean stopped);
    private static native void nSetup(long nativeProxy, int width, int height,
            float lightRadius, int ambientShadowAlpha, int spotShadowAlpha);
    private static native void nSetLightCenter(long nativeProxy,
+4 −7
Original line number Diff line number Diff line
@@ -1079,16 +1079,13 @@ public final class ViewRootImpl implements ViewParent,
    void setWindowStopped(boolean stopped) {
        if (mStopped != stopped) {
            mStopped = stopped;
            final ThreadedRenderer renderer = mAttachInfo.mHardwareRenderer;
            if (renderer != null) {
                if (DEBUG_DRAW) Log.d(mTag, "WindowStopped on " + getTitle() + " set to " + mStopped);
                renderer.setStopped(mStopped);
            }
            if (!mStopped) {
                scheduleTraversals();
            } else {
                if (renderer != null) {
                    renderer.destroyHardwareResources(mView);
                if (mAttachInfo.mHardwareRenderer != null) {
                    if (DEBUG_DRAW) Log.d(mTag, "WindowStopped on " + getTitle());
                    mAttachInfo.mHardwareRenderer.updateSurface(null);
                    mAttachInfo.mHardwareRenderer.destroyHardwareResources(mView);
                }
            }
        }
+0 −7
Original line number Diff line number Diff line
@@ -479,12 +479,6 @@ static jboolean android_view_ThreadedRenderer_pauseSurface(JNIEnv* env, jobject
    return proxy->pauseSurface(surface);
}

static void android_view_ThreadedRenderer_setStopped(JNIEnv* env, jobject clazz,
        jlong proxyPtr, jboolean stopped) {
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
    proxy->setStopped(stopped);
}

static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, jlong proxyPtr,
        jint width, jint height, jfloat lightRadius, jint ambientShadowAlpha, jint spotShadowAlpha) {
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
@@ -738,7 +732,6 @@ static const JNINativeMethod gMethods[] = {
    { "nInitialize", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_initialize },
    { "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface },
    { "nPauseSurface", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_pauseSurface },
    { "nSetStopped", "(JZ)V", (void*) android_view_ThreadedRenderer_setStopped },
    { "nSetup", "(JIIFII)V", (void*) android_view_ThreadedRenderer_setup },
    { "nSetLightCenter", "(JFFF)V", (void*) android_view_ThreadedRenderer_setLightCenter },
    { "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque },
+9 −17
Original line number Diff line number Diff line
@@ -113,11 +113,18 @@ void CanvasContext::setSurface(Surface* surface) {
        mBufferPreserved = mEglManager.setPreserveBuffer(mEglSurface, preserveBuffer);
        mHaveNewSurface = true;
        mSwapHistory.clear();
        makeCurrent();
    } else {
        mRenderThread.removeFrameCallback(this);
    }
}

void CanvasContext::requireSurface() {
    LOG_ALWAYS_FATAL_IF(mEglSurface == EGL_NO_SURFACE,
            "requireSurface() called but no surface set!");
    makeCurrent();
}

void CanvasContext::setSwapBehavior(SwapBehavior swapBehavior) {
    mSwapBehavior = swapBehavior;
}
@@ -139,18 +146,6 @@ bool CanvasContext::pauseSurface(Surface* surface) {
    return mRenderThread.removeFrameCallback(this);
}

void CanvasContext::setStopped(bool stopped) {
    if (mStopped != stopped) {
        mStopped = stopped;
        if (mStopped) {
            mRenderThread.removeFrameCallback(this);
            if (mEglManager.isCurrent(mEglSurface)) {
                mEglManager.makeCurrent(EGL_NO_SURFACE);
            }
        }
    }
}

// TODO: don't pass viewport size, it's automatic via EGL
void CanvasContext::setup(int width, int height, float lightRadius,
        uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) {
@@ -177,9 +172,7 @@ void CanvasContext::setOpaque(bool opaque) {
    mOpaque = opaque;
}

bool CanvasContext::makeCurrent() {
    if (mStopped) return false;

void CanvasContext::makeCurrent() {
    // TODO: Figure out why this workaround is needed, see b/13913604
    // In the meantime this matches the behavior of GLRenderer, so it is not a regression
    EGLint error = 0;
@@ -187,7 +180,6 @@ bool CanvasContext::makeCurrent() {
    if (error) {
        setSurface(nullptr);
    }
    return !error;
}

static bool wasSkipped(FrameInfo* info) {
@@ -679,7 +671,7 @@ void CanvasContext::runWithGlContext(RenderTask* task) {
}

Layer* CanvasContext::createTextureLayer() {
    mEglManager.initialize();
    requireSurface();
    return LayerRenderer::createTextureLayer(mRenderThread.renderState());
}

+2 −3
Original line number Diff line number Diff line
@@ -82,14 +82,13 @@ public:
    void initialize(Surface* surface);
    void updateSurface(Surface* surface);
    bool pauseSurface(Surface* surface);
    void setStopped(bool stopped);
    bool hasSurface() { return mNativeSurface.get(); }

    void setup(int width, int height, float lightRadius,
            uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
    void setLightCenter(const Vector3& lightCenter);
    void setOpaque(bool opaque);
    bool makeCurrent();
    void makeCurrent();
    void prepareTree(TreeInfo& info, int64_t* uiFrameInfo,
            int64_t syncQueued, RenderNode* target);
    void draw();
@@ -173,6 +172,7 @@ private:
    friend class android::uirenderer::RenderState;

    void setSurface(Surface* window);
    void requireSurface();

    void freePrefetchedLayers(TreeObserver* observer);

@@ -185,7 +185,6 @@ private:
    EglManager& mEglManager;
    sp<Surface> mNativeSurface;
    EGLSurface mEglSurface = EGL_NO_SURFACE;
    bool mStopped = false;
    bool mBufferPreserved = false;
    SwapBehavior mSwapBehavior = kSwap_default;
    struct SwapHistory {
Loading