mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add entity playground callback (flutter/engine#27)
This commit is contained in:
parent
55b7b49549
commit
1b50769d71
@ -17,14 +17,29 @@ bool EntityPlayground::OpenPlaygroundHere(Entity entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ContentContext context_context(GetContext());
|
||||
if (!context_context.IsValid()) {
|
||||
ContentContext content_context(GetContext());
|
||||
if (!content_context.IsValid()) {
|
||||
return false;
|
||||
}
|
||||
Renderer::RenderCallback callback = [&](RenderPass& pass) -> bool {
|
||||
return entity.Render(context_context, pass);
|
||||
return entity.Render(content_context, pass);
|
||||
};
|
||||
return Playground::OpenPlaygroundHere(callback);
|
||||
}
|
||||
|
||||
bool EntityPlayground::OpenPlaygroundHere(EntityPlaygroundCallback callback) {
|
||||
if (!Playground::is_enabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ContentContext content_context(GetContext());
|
||||
if (!content_context.IsValid()) {
|
||||
return false;
|
||||
}
|
||||
Renderer::RenderCallback render_callback = [&](RenderPass& pass) -> bool {
|
||||
return callback(content_context, pass);
|
||||
};
|
||||
return Playground::OpenPlaygroundHere(render_callback);
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/entity/content_context.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/playground/playground.h"
|
||||
|
||||
@ -12,12 +13,17 @@ namespace impeller {
|
||||
|
||||
class EntityPlayground : public Playground {
|
||||
public:
|
||||
using EntityPlaygroundCallback =
|
||||
std::function<bool(ContentContext& context, RenderPass& pass)>;
|
||||
|
||||
EntityPlayground();
|
||||
|
||||
~EntityPlayground();
|
||||
|
||||
bool OpenPlaygroundHere(Entity entity);
|
||||
|
||||
bool OpenPlaygroundHere(EntityPlaygroundCallback callback);
|
||||
|
||||
private:
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EntityPlayground);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user