Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 86d5521

Browse files
authored
[Impeller] Enable playgrounds using a runtime instead of a build time flag. (#40729)
[Impeller] Enable playgrounds using a runtime instead of a build time flag.
1 parent 3b58a4d commit 86d5521

11 files changed

Lines changed: 12 additions & 47 deletions

File tree

impeller/aiks/aiks_playground.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bool AiksPlayground::OpenPlaygroundHere(const Picture& picture) {
2222
}
2323

2424
bool AiksPlayground::OpenPlaygroundHere(AiksPlaygroundCallback callback) {
25-
if (!Playground::is_enabled()) {
25+
if (!switches_.enable_playground) {
2626
return true;
2727
}
2828

impeller/display_list/display_list_playground.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool DisplayListPlayground::OpenPlaygroundHere(
2929

3030
bool DisplayListPlayground::OpenPlaygroundHere(
3131
DisplayListPlaygroundCallback callback) {
32-
if (!Playground::is_enabled()) {
32+
if (!switches_.enable_playground) {
3333
return true;
3434
}
3535

impeller/docs/faq.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,4 @@
9999
* Impeller is compiled into the Flutter engine. It is currently behind a flag
100100
as development progresses.
101101
* How do you run `impeller_unittests` with Playgrounds enabled?
102-
* Playgrounds in the `impeller_unittests` harness can be enabled in one of
103-
three ways:
104-
* Edit `gn args` directly and add `impeller_enable_playground = true`.
105-
* Add the `--enable-impeller-playground` flag to your `./flutter/tools/gn`
106-
invocation.
107-
* Set the `FLUTTER_IMPELLER_ENABLE_PLAYGROUND` to `1` before invoking
108-
`./flutter/tools/gn`. Only do this if you frequently work with Playgrounds
109-
and don't want to have to set the flags manually. Also, it would be a bad
110-
idea to set this environment variable on CI.
102+
* Specify the `--enable_playground` command-line option.

impeller/entity/entity_playground.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ EntityPlayground::EntityPlayground() = default;
1515
EntityPlayground::~EntityPlayground() = default;
1616

1717
bool EntityPlayground::OpenPlaygroundHere(EntityPass& entity_pass) {
18-
if (!Playground::is_enabled()) {
18+
if (!switches_.enable_playground) {
1919
return true;
2020
}
2121

@@ -31,7 +31,7 @@ bool EntityPlayground::OpenPlaygroundHere(EntityPass& entity_pass) {
3131
}
3232

3333
bool EntityPlayground::OpenPlaygroundHere(Entity entity) {
34-
if (!Playground::is_enabled()) {
34+
if (!switches_.enable_playground) {
3535
return true;
3636
}
3737

@@ -46,7 +46,7 @@ bool EntityPlayground::OpenPlaygroundHere(Entity entity) {
4646
}
4747

4848
bool EntityPlayground::OpenPlaygroundHere(EntityPlaygroundCallback callback) {
49-
if (!Playground::is_enabled()) {
49+
if (!switches_.enable_playground) {
5050
return true;
5151
}
5252

impeller/playground/BUILD.gn

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ impeller_component("playground") {
5858
public_deps += [ "../fixtures:shader_subgroup_fixtures" ]
5959
}
6060

61-
public_configs = [ ":playground_config" ]
62-
6361
if (is_mac) {
6462
frameworks = [
6563
"AppKit.framework",
@@ -83,9 +81,3 @@ impeller_component("playground_test") {
8381
"//flutter/testing",
8482
]
8583
}
86-
87-
config("playground_config") {
88-
if (impeller_enable_playground) {
89-
defines = [ "IMPELLER_ENABLE_PLAYGROUND" ]
90-
}
91-
}

impeller/playground/playground.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class AutoReleasePool {
202202

203203
bool Playground::OpenPlaygroundHere(
204204
const Renderer::RenderCallback& render_callback) {
205-
if (!is_enabled()) {
205+
if (!switches_.enable_playground) {
206206
return true;
207207
}
208208

impeller/playground/playground.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class Playground {
3838

3939
virtual ~Playground();
4040

41-
static constexpr bool is_enabled() { return is_enabled_; }
42-
4341
static bool ShouldOpenNewPlaygrounds();
4442

4543
void SetupContext(PlaygroundBackend backend);
@@ -98,15 +96,9 @@ class Playground {
9896
virtual bool ShouldKeepRendering() const;
9997

10098
private:
101-
#if IMPELLER_ENABLE_PLAYGROUND
102-
static const bool is_enabled_ = true;
103-
#else
104-
static const bool is_enabled_ = false;
105-
#endif // IMPELLER_ENABLE_PLAYGROUND
99+
struct GLFWInitializer;
106100

107101
fml::TimeDelta start_time_;
108-
109-
struct GLFWInitializer;
110102
std::unique_ptr<GLFWInitializer> glfw_initializer_;
111103
std::unique_ptr<PlaygroundImpl> impl_;
112104
std::shared_ptr<Context> context_;

impeller/playground/switches.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ namespace impeller {
1111
PlaygroundSwitches::PlaygroundSwitches() = default;
1212

1313
PlaygroundSwitches::PlaygroundSwitches(const fml::CommandLine& args) {
14+
enable_playground = args.HasOption("enable_playground");
1415
std::string timeout_str;
1516
if (args.GetOptionValue("playground_timeout_ms", &timeout_str)) {
1617
timeout = std::chrono::milliseconds(atoi(timeout_str.c_str()));
18+
// Specifying a playground timeout implies you want to enable playgrounds.
19+
enable_playground = true;
1720
}
1821
enable_vulkan_validation = args.HasOption("enable_vulkan_validation");
1922
}

impeller/playground/switches.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace impeller {
1414

1515
struct PlaygroundSwitches {
16+
bool enable_playground = false;
1617
// If specified, the playgrounds will render for at least the duration
1718
// specified in the timeout. If the timeout is zero, exactly one frame will be
1819
// rendered in the playground.

impeller/tools/impeller.gni

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import("//flutter/impeller/tools/malioc.gni")
88
import("//flutter/testing/testing.gni")
99

1010
declare_args() {
11-
# Whether playgrounds are enabled for unit tests.
12-
impeller_enable_playground = false
13-
1411
# Whether the Metal backend is enabled.
1512
impeller_enable_metal = is_mac || is_ios
1613

0 commit comments

Comments
 (0)