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

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

Merge "Add extended brightness plumbing to VRI"

parents 7ff16d23 55887762
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -572,17 +572,10 @@ public final class ThreadedRenderer extends HardwareRenderer {
    }

    @Override
    public void setSurfaceControl(@Nullable SurfaceControl surfaceControl) {
        super.setSurfaceControl(surfaceControl);
    public void setSurfaceControl(@Nullable SurfaceControl surfaceControl,
            @Nullable BLASTBufferQueue blastBufferQueue) {
        super.setSurfaceControl(surfaceControl, blastBufferQueue);
        mWebViewOverlayProvider.setSurfaceControl(surfaceControl);
        updateWebViewOverlayCallbacks();
    }

    /**
     * Sets the BLASTBufferQueue being used for rendering. This is required to be specified
     * for WebView overlay support
     */
    public void setBlastBufferQueue(@Nullable BLASTBufferQueue blastBufferQueue) {
        mWebViewOverlayProvider.setBLASTBufferQueue(blastBufferQueue);
        updateWebViewOverlayCallbacks();
    }
+34 −14
Original line number Diff line number Diff line
@@ -683,6 +683,10 @@ public final class ViewRootImpl implements ViewParent,

    private BLASTBufferQueue mBlastBufferQueue;

    private boolean mUpdateSdrHdrRatioInfo = false;
    private float mDesiredSdrHdrRatio = 1f;
    private float mRenderSdrHdrRatio = 1f;

    /**
     * Child container layer of {@code mSurface} with the same bounds as its parent, and cropped to
     * the surface insets. This surface is created only if a client requests it via {@link
@@ -1627,18 +1631,16 @@ public final class ViewRootImpl implements ViewParent,
                final boolean hasSurfaceInsets = insets.left != 0 || insets.right != 0
                        || insets.top != 0 || insets.bottom != 0;
                final boolean translucent = attrs.format != PixelFormat.OPAQUE || hasSurfaceInsets;
                mAttachInfo.mThreadedRenderer = ThreadedRenderer.create(mContext, translucent,
                final ThreadedRenderer renderer = ThreadedRenderer.create(mContext, translucent,
                        attrs.getTitle().toString());
                mAttachInfo.mThreadedRenderer = renderer;
                renderer.setSurfaceControl(mSurfaceControl, mBlastBufferQueue);
                updateColorModeIfNeeded(attrs.getColorMode());
                updateForceDarkMode();
                if (mAttachInfo.mThreadedRenderer != null) {
                    mAttachInfo.mHardwareAccelerated =
                mAttachInfo.mHardwareAccelerated = true;
                mAttachInfo.mHardwareAccelerationRequested = true;
                if (mHardwareRendererObserver != null) {
                        mAttachInfo.mThreadedRenderer.addObserver(mHardwareRendererObserver);
                    }
                    mAttachInfo.mThreadedRenderer.setSurfaceControl(mSurfaceControl);
                    mAttachInfo.mThreadedRenderer.setBlastBufferQueue(mBlastBufferQueue);
                    renderer.addObserver(mHardwareRendererObserver);
                }
            }
        }
@@ -2264,8 +2266,7 @@ public final class ViewRootImpl implements ViewParent,
        }

        if (mAttachInfo.mThreadedRenderer != null) {
            mAttachInfo.mThreadedRenderer.setSurfaceControl(null);
            mAttachInfo.mThreadedRenderer.setBlastBufferQueue(null);
            mAttachInfo.mThreadedRenderer.setSurfaceControl(null, null);
        }
    }

@@ -4828,6 +4829,13 @@ public final class ViewRootImpl implements ViewParent,

                useAsyncReport = true;

                if (mUpdateSdrHdrRatioInfo) {
                    mUpdateSdrHdrRatioInfo = false;
                    applyTransactionOnDraw(mTransaction.setExtendedRangeBrightness(
                            getSurfaceControl(), mRenderSdrHdrRatio, mDesiredSdrHdrRatio));
                    mAttachInfo.mThreadedRenderer.setTargetSdrHdrRatio(mRenderSdrHdrRatio);
                }

                if (forceDraw) {
                    mAttachInfo.mThreadedRenderer.forceDrawNextFrame();
                }
@@ -5361,7 +5369,20 @@ public final class ViewRootImpl implements ViewParent,
                && !getConfiguration().isScreenWideColorGamut()) {
            colorMode = ActivityInfo.COLOR_MODE_DEFAULT;
        }
        mAttachInfo.mThreadedRenderer.setColorMode(colorMode);
        float desiredRatio = mAttachInfo.mThreadedRenderer.setColorMode(colorMode);
        if (desiredRatio != mDesiredSdrHdrRatio) {
            mDesiredSdrHdrRatio = desiredRatio;
            mUpdateSdrHdrRatioInfo = true;
        }
    }

    /** happylint */
    public void setTargetSdrHdrRatio(float ratio) {
        if (mRenderSdrHdrRatio != ratio) {
            mRenderSdrHdrRatio = ratio;
            mUpdateSdrHdrRatioInfo = true;
            invalidate();
        }
    }

    @Override
@@ -8435,8 +8456,7 @@ public final class ViewRootImpl implements ViewParent,
                updateBlastSurfaceIfNeeded();
            }
            if (mAttachInfo.mThreadedRenderer != null) {
                mAttachInfo.mThreadedRenderer.setSurfaceControl(mSurfaceControl);
                mAttachInfo.mThreadedRenderer.setBlastBufferQueue(mBlastBufferQueue);
                mAttachInfo.mThreadedRenderer.setSurfaceControl(mSurfaceControl, mBlastBufferQueue);
            }
            if (mPreviousTransformHint != transformHint) {
                mPreviousTransformHint = transformHint;
+15 −4
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ public class HardwareRenderer {
    private boolean mOpaque = true;
    private boolean mForceDark = false;
    private @ActivityInfo.ColorMode int mColorMode = ActivityInfo.COLOR_MODE_DEFAULT;
    private float mDesiredSdrHdrRatio = 1f;

    /**
     * Creates a new instance of a HardwareRenderer. The HardwareRenderer will default
@@ -319,7 +320,8 @@ public class HardwareRenderer {
     * @param surfaceControl The surface control to pass to render thread in hwui.
     *        If null, any previous references held in render thread will be discarded.
    */
    public void setSurfaceControl(@Nullable SurfaceControl surfaceControl) {
    public void setSurfaceControl(@Nullable SurfaceControl surfaceControl,
            @Nullable BLASTBufferQueue blastBufferQueue) {
        nSetSurfaceControl(mNativeProxy, surfaceControl != null ? surfaceControl.mNativeObject : 0);
    }

@@ -643,11 +645,12 @@ public class HardwareRenderer {
     * @param colorMode The @{@link ActivityInfo.ColorMode} to request
     * @hide
     */
    public void setColorMode(@ActivityInfo.ColorMode int colorMode) {
    public float setColorMode(@ActivityInfo.ColorMode int colorMode) {
        if (mColorMode != colorMode) {
            mColorMode = colorMode;
            nSetColorMode(mNativeProxy, colorMode);
            mDesiredSdrHdrRatio = nSetColorMode(mNativeProxy, colorMode);
        }
        return mDesiredSdrHdrRatio;
    }

    /**
@@ -663,6 +666,12 @@ public class HardwareRenderer {
        nSetColorMode(mNativeProxy, colorMode);
    }

    /** @hide */
    public void setTargetSdrHdrRatio(float ratio) {
        if (ratio < 1.f || Float.isNaN(ratio) || Float.isInfinite(ratio)) ratio = 1.f;
        nSetTargetSdrHdrRatio(mNativeProxy, ratio);
    }

    /**
     * Blocks until all previously queued work has completed.
     *
@@ -1451,7 +1460,9 @@ public class HardwareRenderer {

    private static native void nSetOpaque(long nativeProxy, boolean opaque);

    private static native void nSetColorMode(long nativeProxy, int colorMode);
    private static native float nSetColorMode(long nativeProxy, int colorMode);

    private static native void nSetTargetSdrHdrRatio(long nativeProxy, float ratio);

    private static native void nSetSdrWhitePoint(long nativeProxy, float whitePoint);

+1 −3
Original line number Diff line number Diff line
@@ -25,10 +25,8 @@ enum class ColorMode {
    // WideColorGamut selects the most optimal colorspace & format for the device's display
    // Most commonly DisplayP3 + RGBA_8888 currently.
    WideColorGamut = 1,
    // HDR Rec2020 + F16
    // Extended range Display P3
    Hdr = 2,
    // HDR Rec2020 + 1010102
    Hdr10 = 3,
    // Alpha 8
    A8 = 4,
};
+12 −4
Original line number Diff line number Diff line
@@ -232,10 +232,16 @@ static void android_view_ThreadedRenderer_setOpaque(JNIEnv* env, jobject clazz,
    proxy->setOpaque(opaque);
}

static void android_view_ThreadedRenderer_setColorMode(JNIEnv* env, jobject clazz,
        jlong proxyPtr, jint colorMode) {
static jfloat android_view_ThreadedRenderer_setColorMode(JNIEnv* env, jobject clazz, jlong proxyPtr,
                                                         jint colorMode) {
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
    proxy->setColorMode(static_cast<ColorMode>(colorMode));
    return proxy->setColorMode(static_cast<ColorMode>(colorMode));
}

static void android_view_ThreadedRenderer_setTargetSdrHdrRatio(JNIEnv* env, jobject clazz,
                                                               jlong proxyPtr, jfloat ratio) {
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
    return proxy->setRenderSdrHdrRatio(ratio);
}

static void android_view_ThreadedRenderer_setSdrWhitePoint(JNIEnv* env, jobject clazz,
@@ -924,7 +930,9 @@ static const JNINativeMethod gMethods[] = {
        {"nSetLightAlpha", "(JFF)V", (void*)android_view_ThreadedRenderer_setLightAlpha},
        {"nSetLightGeometry", "(JFFFF)V", (void*)android_view_ThreadedRenderer_setLightGeometry},
        {"nSetOpaque", "(JZ)V", (void*)android_view_ThreadedRenderer_setOpaque},
        {"nSetColorMode", "(JI)V", (void*)android_view_ThreadedRenderer_setColorMode},
        {"nSetColorMode", "(JI)F", (void*)android_view_ThreadedRenderer_setColorMode},
        {"nSetTargetSdrHdrRatio", "(JF)V",
         (void*)android_view_ThreadedRenderer_setTargetSdrHdrRatio},
        {"nSetSdrWhitePoint", "(JF)V", (void*)android_view_ThreadedRenderer_setSdrWhitePoint},
        {"nSetIsHighEndGfx", "(Z)V", (void*)android_view_ThreadedRenderer_setIsHighEndGfx},
        {"nSetIsLowRam", "(Z)V", (void*)android_view_ThreadedRenderer_setIsLowRam},
Loading