Skip to content

Commit

Permalink
Move DisplayMode out of SurfaceHandler
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Apr 12, 2021
1 parent 84c70b2 commit 2793bba
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ SurfaceHandlerBinding::SurfaceHandlerBinding(
: surfaceHandler_(moduleName, surfaceId) {}

void SurfaceHandlerBinding::setDisplayMode(jint mode) {
surfaceHandler_.setDisplayMode(
static_cast<SurfaceHandler::DisplayMode>(mode));
surfaceHandler_.setDisplayMode(static_cast<DisplayMode>(mode));
}

void SurfaceHandlerBinding::start() {
std::unique_lock<better::shared_mutex> lock(lifecycleMutex_);

surfaceHandler_.setDisplayMode(SurfaceHandler::DisplayMode::Visible);
surfaceHandler_.setDisplayMode(DisplayMode::Visible);
if (surfaceHandler_.getStatus() != SurfaceHandler::Status::Running) {
surfaceHandler_.start();
}
Expand Down
34 changes: 34 additions & 0 deletions ReactCommon/react/renderer/core/ReactPrimitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace facebook {
namespace react {

using Status = SurfaceHandler::Status;
using DisplayMode = SurfaceHandler::DisplayMode;

SurfaceHandler::SurfaceHandler(
std::string const &moduleName,
Expand Down
34 changes: 0 additions & 34 deletions ReactCommon/react/renderer/scheduler/SurfaceHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
*/
Expand Down

0 comments on commit 2793bba

Please sign in to comment.