From 2793bba278801139948bfde11764181033221c48 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 12 Apr 2021 00:03:16 -0700 Subject: [PATCH] Move DisplayMode out of SurfaceHandler Summary: This diff moves DisplayMode out of SurfaceHandler, this is necessary in order to use it from react/uimanager package changelog: [internal] internal Reviewed By: ShikaSD Differential Revision: D27669846 fbshipit-source-id: 274869d8f2907b1b159f51240440acece09a746f --- .../fabric/jni/SurfaceHandlerBinding.cpp | 5 ++- .../react/renderer/core/ReactPrimitives.h | 34 +++++++++++++++++++ .../renderer/scheduler/SurfaceHandler.cpp | 1 - .../react/renderer/scheduler/SurfaceHandler.h | 34 ------------------- 4 files changed, 36 insertions(+), 38 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/SurfaceHandlerBinding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/SurfaceHandlerBinding.cpp index d4e49322f6..8e4e90a13a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/SurfaceHandlerBinding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/SurfaceHandlerBinding.cpp @@ -17,14 +17,13 @@ SurfaceHandlerBinding::SurfaceHandlerBinding( : surfaceHandler_(moduleName, surfaceId) {} void SurfaceHandlerBinding::setDisplayMode(jint mode) { - surfaceHandler_.setDisplayMode( - static_cast(mode)); + surfaceHandler_.setDisplayMode(static_cast(mode)); } void SurfaceHandlerBinding::start() { std::unique_lock lock(lifecycleMutex_); - surfaceHandler_.setDisplayMode(SurfaceHandler::DisplayMode::Visible); + surfaceHandler_.setDisplayMode(DisplayMode::Visible); if (surfaceHandler_.getStatus() != SurfaceHandler::Status::Running) { surfaceHandler_.start(); } diff --git a/ReactCommon/react/renderer/core/ReactPrimitives.h b/ReactCommon/react/renderer/core/ReactPrimitives.h index d72fa25d59..4954fcfff9 100644 --- a/ReactCommon/react/renderer/core/ReactPrimitives.h +++ b/ReactCommon/react/renderer/core/ReactPrimitives.h @@ -42,5 +42,39 @@ using ComponentHandle = int64_t; */ using ComponentName = char const *; +/* + * Defines how visual side effects (views, images, text, and so on) are + * mounted (on not) on the screen. + */ +enum class DisplayMode { + /* + * The surface is running normally. All visual side-effects will be rendered + * on the screen. + */ + Visible = 0, + + /* + * The surface is `Suspended`. All new (committed after switching to the + * mode) visual side-effects will *not* be mounted on the screen (the screen + * will stop updating). + * + * The mode can be used for preparing a surface for possible future use. + * The surface will be prepared without spending computing resources + * on mounting, and then can be instantly mounted if needed. + */ + Suspended = 1, + + /* + * The surface is `Hidden`. All previously mounted visual side-effects + * will be unmounted, and all new (committed after switching to the mode) + * visual side-effects will *not* be mounted on the screen until the mode is + * switched back to `normal`. + * + * The mode can be used for temporarily freeing computing resources of + * off-the-screen surfaces. + */ + Hidden = 2, +}; + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp b/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp index ff82f66e2c..cd3d26fcef 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp +++ b/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp @@ -15,7 +15,6 @@ namespace facebook { namespace react { using Status = SurfaceHandler::Status; -using DisplayMode = SurfaceHandler::DisplayMode; SurfaceHandler::SurfaceHandler( std::string const &moduleName, diff --git a/ReactCommon/react/renderer/scheduler/SurfaceHandler.h b/ReactCommon/react/renderer/scheduler/SurfaceHandler.h index c8c16bff63..b564f5ebac 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceHandler.h +++ b/ReactCommon/react/renderer/scheduler/SurfaceHandler.h @@ -57,40 +57,6 @@ class SurfaceHandler final { Running = 2, }; - /* - * Defines how visual side effects (views, images, text, and so on) are - * mounted (on not) on the screen. - */ - enum class DisplayMode { - /* - * The surface is running normally. All visual side-effects will be rendered - * on the screen. - */ - Visible = 0, - - /* - * The surface is `Suspended`. All new (committed after switching to the - * mode) visual side-effects will *not* be mounted on the screen (the screen - * will stop updating). - * - * The mode can be used for preparing a surface for possible future use. - * The surface will be prepared without spending computing resources - * on mounting, and then can be instantly mounted if needed. - */ - Suspended = 1, - - /* - * The surface is `Hidden`. All previously mounted visual side-effects - * will be unmounted, and all new (committed after switching to the mode) - * visual side-effects will *not* be mounted on the screen until the mode is - * switched back to `normal`. - * - * The mode can be used for temporarily freeing computing resources of - * off-the-screen surfaces. - */ - Hidden = 2, - }; - /* * Can be constructed anytime with a `moduleName` and a `surfaceId`. */