Loading core/java/android/view/ViewRootImpl.java +8 −0 Original line number Diff line number Diff line Loading @@ -1375,6 +1375,7 @@ public final class ViewRootImpl implements ViewParent, final boolean translucent = attrs.format != PixelFormat.OPAQUE || hasSurfaceInsets; mAttachInfo.mThreadedRenderer = ThreadedRenderer.create(mContext, translucent, attrs.getTitle().toString()); mAttachInfo.mThreadedRenderer.setSurfaceControl(mSurfaceControl); updateColorModeIfNeeded(attrs.getColorMode()); updateForceDarkMode(); if (mAttachInfo.mThreadedRenderer != null) { Loading Loading @@ -1941,6 +1942,10 @@ public final class ViewRootImpl implements ViewParent, mBlastBufferQueue.destroy(); mBlastBufferQueue = null; } if (mAttachInfo.mThreadedRenderer != null) { mAttachInfo.mThreadedRenderer.setSurfaceControl(null); } } /** Loading Loading @@ -7651,6 +7656,9 @@ public final class ViewRootImpl implements ViewParent, mSurface.transferFrom(blastSurface); } } if (mAttachInfo.mThreadedRenderer != null) { mAttachInfo.mThreadedRenderer.setSurfaceControl(mSurfaceControl); } } else { destroySurface(); } Loading graphics/java/android/graphics/HardwareRenderer.java +13 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.view.IGraphicsStatsCallback; import android.view.NativeVectorDrawableAnimator; import android.view.PixelCopy; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceHolder; import android.view.animation.AnimationUtils; Loading Loading @@ -313,6 +314,16 @@ public class HardwareRenderer { nSetSurface(mNativeProxy, surface, discardBuffer); } /** * Sets the SurfaceControl to be used internally inside render thread * @hide * @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) { nSetSurfaceControl(mNativeProxy, surfaceControl != null ? surfaceControl.mNativeObject : 0); } /** * Sets the parameters that can be used to control a render request for a * {@link HardwareRenderer}. This is not thread-safe and must not be held on to for longer Loading Loading @@ -1216,6 +1227,8 @@ public class HardwareRenderer { private static native void nSetSurface(long nativeProxy, Surface window, boolean discardBuffer); private static native void nSetSurfaceControl(long nativeProxy, long nativeSurfaceControl); private static native boolean nPause(long nativeProxy); private static native void nSetStopped(long nativeProxy, boolean stopped); Loading libs/hwui/jni/android_graphics_HardwareRenderer.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,13 @@ static void android_view_ThreadedRenderer_setSurface(JNIEnv* env, jobject clazz, } } static void android_view_ThreadedRenderer_setSurfaceControl(JNIEnv* env, jobject clazz, jlong proxyPtr, jlong surfaceControlPtr) { RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); ASurfaceControl* surfaceControl = reinterpret_cast<ASurfaceControl*>(surfaceControlPtr); proxy->setSurfaceControl(surfaceControl); } static jboolean android_view_ThreadedRenderer_pause(JNIEnv* env, jobject clazz, jlong proxyPtr) { RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); Loading Loading @@ -671,6 +678,8 @@ static const JNINativeMethod gMethods[] = { {"nSetName", "(JLjava/lang/String;)V", (void*)android_view_ThreadedRenderer_setName}, {"nSetSurface", "(JLandroid/view/Surface;Z)V", (void*)android_view_ThreadedRenderer_setSurface}, {"nSetSurfaceControl", "(JJ)V", (void*)android_view_ThreadedRenderer_setSurfaceControl}, {"nPause", "(J)Z", (void*)android_view_ThreadedRenderer_pause}, {"nSetStopped", "(JZ)V", (void*)android_view_ThreadedRenderer_setStopped}, {"nSetLightAlpha", "(JFF)V", (void*)android_view_ThreadedRenderer_setLightAlpha}, Loading libs/hwui/renderthread/CanvasContext.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ void CanvasContext::removeRenderNode(RenderNode* node) { void CanvasContext::destroy() { stopDrawing(); setSurface(nullptr); setSurfaceControl(nullptr); freePrefetchedLayers(); destroyHardwareResources(); mAnimationContext->destroy(); Loading Loading @@ -173,6 +174,19 @@ void CanvasContext::setSurface(ANativeWindow* window, bool enableTimeout) { setupPipelineSurface(); } void CanvasContext::setSurfaceControl(ASurfaceControl* surfaceControl) { if (surfaceControl == mSurfaceControl) return; auto funcs = mRenderThread.getASurfaceControlFunctions(); if (mSurfaceControl != nullptr) { funcs.releaseFunc(mSurfaceControl); } mSurfaceControl = surfaceControl; if (mSurfaceControl != nullptr) { funcs.acquireFunc(mSurfaceControl); } } void CanvasContext::setupPipelineSurface() { bool hasSurface = mRenderPipeline->setSurface( mNativeSurface ? mNativeSurface->getNativeWindow() : nullptr, mSwapBehavior); Loading libs/hwui/renderthread/CanvasContext.h +4 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ public: void setSwapBehavior(SwapBehavior swapBehavior); void setSurface(ANativeWindow* window, bool enableTimeout = true); void setSurfaceControl(ASurfaceControl* surfaceControl); bool pauseSurface(); void setStopped(bool stopped); bool hasSurface() const { return mNativeSurface.get(); } Loading Loading @@ -218,6 +219,9 @@ private: RenderThread& mRenderThread; std::unique_ptr<ReliableSurface> mNativeSurface; // The SurfaceControl reference is passed from ViewRootImpl, can be set to // NULL to remove the reference ASurfaceControl* mSurfaceControl = nullptr; // stopped indicates the CanvasContext will reject actual redraw operations, // and defer repaint until it is un-stopped bool mStopped = false; Loading Loading
core/java/android/view/ViewRootImpl.java +8 −0 Original line number Diff line number Diff line Loading @@ -1375,6 +1375,7 @@ public final class ViewRootImpl implements ViewParent, final boolean translucent = attrs.format != PixelFormat.OPAQUE || hasSurfaceInsets; mAttachInfo.mThreadedRenderer = ThreadedRenderer.create(mContext, translucent, attrs.getTitle().toString()); mAttachInfo.mThreadedRenderer.setSurfaceControl(mSurfaceControl); updateColorModeIfNeeded(attrs.getColorMode()); updateForceDarkMode(); if (mAttachInfo.mThreadedRenderer != null) { Loading Loading @@ -1941,6 +1942,10 @@ public final class ViewRootImpl implements ViewParent, mBlastBufferQueue.destroy(); mBlastBufferQueue = null; } if (mAttachInfo.mThreadedRenderer != null) { mAttachInfo.mThreadedRenderer.setSurfaceControl(null); } } /** Loading Loading @@ -7651,6 +7656,9 @@ public final class ViewRootImpl implements ViewParent, mSurface.transferFrom(blastSurface); } } if (mAttachInfo.mThreadedRenderer != null) { mAttachInfo.mThreadedRenderer.setSurfaceControl(mSurfaceControl); } } else { destroySurface(); } Loading
graphics/java/android/graphics/HardwareRenderer.java +13 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.view.IGraphicsStatsCallback; import android.view.NativeVectorDrawableAnimator; import android.view.PixelCopy; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceHolder; import android.view.animation.AnimationUtils; Loading Loading @@ -313,6 +314,16 @@ public class HardwareRenderer { nSetSurface(mNativeProxy, surface, discardBuffer); } /** * Sets the SurfaceControl to be used internally inside render thread * @hide * @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) { nSetSurfaceControl(mNativeProxy, surfaceControl != null ? surfaceControl.mNativeObject : 0); } /** * Sets the parameters that can be used to control a render request for a * {@link HardwareRenderer}. This is not thread-safe and must not be held on to for longer Loading Loading @@ -1216,6 +1227,8 @@ public class HardwareRenderer { private static native void nSetSurface(long nativeProxy, Surface window, boolean discardBuffer); private static native void nSetSurfaceControl(long nativeProxy, long nativeSurfaceControl); private static native boolean nPause(long nativeProxy); private static native void nSetStopped(long nativeProxy, boolean stopped); Loading
libs/hwui/jni/android_graphics_HardwareRenderer.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,13 @@ static void android_view_ThreadedRenderer_setSurface(JNIEnv* env, jobject clazz, } } static void android_view_ThreadedRenderer_setSurfaceControl(JNIEnv* env, jobject clazz, jlong proxyPtr, jlong surfaceControlPtr) { RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); ASurfaceControl* surfaceControl = reinterpret_cast<ASurfaceControl*>(surfaceControlPtr); proxy->setSurfaceControl(surfaceControl); } static jboolean android_view_ThreadedRenderer_pause(JNIEnv* env, jobject clazz, jlong proxyPtr) { RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); Loading Loading @@ -671,6 +678,8 @@ static const JNINativeMethod gMethods[] = { {"nSetName", "(JLjava/lang/String;)V", (void*)android_view_ThreadedRenderer_setName}, {"nSetSurface", "(JLandroid/view/Surface;Z)V", (void*)android_view_ThreadedRenderer_setSurface}, {"nSetSurfaceControl", "(JJ)V", (void*)android_view_ThreadedRenderer_setSurfaceControl}, {"nPause", "(J)Z", (void*)android_view_ThreadedRenderer_pause}, {"nSetStopped", "(JZ)V", (void*)android_view_ThreadedRenderer_setStopped}, {"nSetLightAlpha", "(JFF)V", (void*)android_view_ThreadedRenderer_setLightAlpha}, Loading
libs/hwui/renderthread/CanvasContext.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ void CanvasContext::removeRenderNode(RenderNode* node) { void CanvasContext::destroy() { stopDrawing(); setSurface(nullptr); setSurfaceControl(nullptr); freePrefetchedLayers(); destroyHardwareResources(); mAnimationContext->destroy(); Loading Loading @@ -173,6 +174,19 @@ void CanvasContext::setSurface(ANativeWindow* window, bool enableTimeout) { setupPipelineSurface(); } void CanvasContext::setSurfaceControl(ASurfaceControl* surfaceControl) { if (surfaceControl == mSurfaceControl) return; auto funcs = mRenderThread.getASurfaceControlFunctions(); if (mSurfaceControl != nullptr) { funcs.releaseFunc(mSurfaceControl); } mSurfaceControl = surfaceControl; if (mSurfaceControl != nullptr) { funcs.acquireFunc(mSurfaceControl); } } void CanvasContext::setupPipelineSurface() { bool hasSurface = mRenderPipeline->setSurface( mNativeSurface ? mNativeSurface->getNativeWindow() : nullptr, mSwapBehavior); Loading
libs/hwui/renderthread/CanvasContext.h +4 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ public: void setSwapBehavior(SwapBehavior swapBehavior); void setSurface(ANativeWindow* window, bool enableTimeout = true); void setSurfaceControl(ASurfaceControl* surfaceControl); bool pauseSurface(); void setStopped(bool stopped); bool hasSurface() const { return mNativeSurface.get(); } Loading Loading @@ -218,6 +219,9 @@ private: RenderThread& mRenderThread; std::unique_ptr<ReliableSurface> mNativeSurface; // The SurfaceControl reference is passed from ViewRootImpl, can be set to // NULL to remove the reference ASurfaceControl* mSurfaceControl = nullptr; // stopped indicates the CanvasContext will reject actual redraw operations, // and defer repaint until it is un-stopped bool mStopped = false; Loading