Skip to content

Commit 2373da8

Browse files
bderodnfield
authored andcommitted
Add entity playground callback (flutter#27)
1 parent bafa73b commit 2373da8

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

impeller/entity/entity_playground.cc

+18-3
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,29 @@ bool EntityPlayground::OpenPlaygroundHere(Entity entity) {
1717
return true;
1818
}
1919

20-
ContentContext context_context(GetContext());
21-
if (!context_context.IsValid()) {
20+
ContentContext content_context(GetContext());
21+
if (!content_context.IsValid()) {
2222
return false;
2323
}
2424
Renderer::RenderCallback callback = [&](RenderPass& pass) -> bool {
25-
return entity.Render(context_context, pass);
25+
return entity.Render(content_context, pass);
2626
};
2727
return Playground::OpenPlaygroundHere(callback);
2828
}
2929

30+
bool EntityPlayground::OpenPlaygroundHere(EntityPlaygroundCallback callback) {
31+
if (!Playground::is_enabled()) {
32+
return true;
33+
}
34+
35+
ContentContext content_context(GetContext());
36+
if (!content_context.IsValid()) {
37+
return false;
38+
}
39+
Renderer::RenderCallback render_callback = [&](RenderPass& pass) -> bool {
40+
return callback(content_context, pass);
41+
};
42+
return Playground::OpenPlaygroundHere(render_callback);
43+
}
44+
3045
} // namespace impeller

impeller/entity/entity_playground.h

+6
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@
55
#pragma once
66

77
#include "flutter/fml/macros.h"
8+
#include "impeller/entity/content_context.h"
89
#include "impeller/entity/entity.h"
910
#include "impeller/playground/playground.h"
1011

1112
namespace impeller {
1213

1314
class EntityPlayground : public Playground {
1415
public:
16+
using EntityPlaygroundCallback =
17+
std::function<bool(ContentContext& context, RenderPass& pass)>;
18+
1519
EntityPlayground();
1620

1721
~EntityPlayground();
1822

1923
bool OpenPlaygroundHere(Entity entity);
2024

25+
bool OpenPlaygroundHere(EntityPlaygroundCallback callback);
26+
2127
private:
2228
FML_DISALLOW_COPY_AND_ASSIGN(EntityPlayground);
2329
};

0 commit comments

Comments
 (0)