Skip to content

Commit 14ec50a

Browse files
zandersodnfield
authored andcommitted
Adds a GN flag for playgrounds (#7)
1 parent e982526 commit 14ec50a

File tree

6 files changed

+33
-0
lines changed

6 files changed

+33
-0
lines changed

impeller/aiks/aiks_playground.cc

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ AiksPlayground::AiksPlayground() = default;
1313
AiksPlayground::~AiksPlayground() = default;
1414

1515
bool AiksPlayground::OpenPlaygroundHere(const Picture& picture) {
16+
if (!Playground::is_enabled()) {
17+
return true;
18+
}
19+
1620
AiksContext renderer(GetContext());
1721

1822
if (!renderer.IsValid()) {

impeller/entity/entity_playground.cc

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ EntityPlayground::EntityPlayground() = default;
1313
EntityPlayground::~EntityPlayground() = default;
1414

1515
bool EntityPlayground::OpenPlaygroundHere(Entity entity) {
16+
if (!Playground::is_enabled()) {
17+
return true;
18+
}
19+
1620
ContentContext context_context(GetContext());
1721
if (!context_context.IsValid()) {
1822
return false;

impeller/playground/BUILD.gn

+8
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,18 @@ impeller_component("playground") {
2121
"//third_party/glfw",
2222
]
2323

24+
public_configs = [ ":playground_config" ]
25+
2426
if (is_mac) {
2527
frameworks = [
2628
"AppKit.framework",
2729
"QuartzCore.framework",
2830
]
2931
}
3032
}
33+
34+
config("playground_config") {
35+
if (impeller_enable_playground) {
36+
defines = [ "IMPELLER_ENABLE_PLAYGROUND" ]
37+
}
38+
}

impeller/playground/playground.h

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Playground : public ::testing::Test {
1919

2020
~Playground();
2121

22+
static constexpr bool is_enabled() { return is_enabled_; }
23+
2224
Point GetCursorPosition() const;
2325

2426
ISize GetWindowSize() const;
@@ -31,6 +33,12 @@ class Playground : public ::testing::Test {
3133
const char* fixture_name) const;
3234

3335
private:
36+
#if IMPELLER_ENABLE_PLAYGROUND
37+
static const bool is_enabled_ = true;
38+
#else
39+
static const bool is_enabled_ = false;
40+
#endif // IMPELLER_ENABLE_PLAYGROUND
41+
3442
Renderer renderer_;
3543
Point cursor_position_;
3644
ISize window_size_ = ISize{1024, 768};

impeller/playground/playground.mm

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
8181
}
8282

8383
bool Playground::OpenPlaygroundHere(Renderer::RenderCallback render_callback) {
84+
if (!is_enabled()) {
85+
return true;
86+
}
87+
8488
if (!render_callback) {
8589
return true;
8690
}

impeller/tools/impeller.gni

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import("//build/compiled_action.gni")
66
import("//flutter/common/config.gni")
77

8+
declare_args() {
9+
# Whether playgrounds are enabled for unit tests.
10+
impeller_enable_playground = false
11+
}
12+
813
template("impeller_component") {
914
source_set(target_name) {
1015
forward_variables_from(invoker, "*")

0 commit comments

Comments
 (0)