Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
entity_playground.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
9#include "third_party/imgui/imgui.h"
10
11namespace impeller {
12
15
17
19 std::shared_ptr<TypographerContext> typographer_context) {
20 typographer_context_ = std::move(typographer_context);
21}
22
25 return true;
26 }
27
28 ContentContext content_context(GetContext(), typographer_context_);
29 if (!content_context.IsValid()) {
30 return false;
31 }
32
33 // Resolve any lingering tracked clips by assigning an arbitrarily high
34 // number. The number to assign just needs to be at least as high as larger
35 // any previously assigned clip depth in the scene. Normally, Aiks handles
36 // this correctly when wrapping up the base pass as an `impeller::Picture`.
37 entity_pass.PopAllClips(99999);
38
39 auto callback = [&](RenderTarget& render_target) -> bool {
40 return entity_pass.Render(content_context, render_target);
41 };
43}
44
45std::shared_ptr<ContentContext> EntityPlayground::GetContentContext() const {
46 return std::make_shared<ContentContext>(GetContext(), typographer_context_);
47}
48
51 return true;
52 }
53
54 auto content_context = GetContentContext();
55 if (!content_context->IsValid()) {
56 return false;
57 }
58 SinglePassCallback callback = [&](RenderPass& pass) -> bool {
59 content_context->GetRenderTargetCache()->Start();
60 bool result = entity.Render(*content_context, pass);
61 content_context->GetRenderTargetCache()->End();
62 content_context->GetTransientsBuffer().Reset();
63 return result;
64 };
66}
67
70 return true;
71 }
72
73 ContentContext content_context(GetContext(), typographer_context_);
74 if (!content_context.IsValid()) {
75 return false;
76 }
77 SinglePassCallback pass_callback = [&](RenderPass& pass) -> bool {
78 static bool wireframe = false;
79 if (ImGui::IsKeyPressed(ImGuiKey_Z)) {
80 wireframe = !wireframe;
81 content_context.SetWireframe(wireframe);
82 }
83 content_context.GetRenderTargetCache()->Start();
84 bool result = callback(content_context, pass);
85 content_context.GetRenderTargetCache()->End();
86 content_context.GetTransientsBuffer().Reset();
87 return result;
88 };
89 return Playground::OpenPlaygroundHere(pass_callback);
90}
91
92} // namespace impeller
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
void SetWireframe(bool wireframe)
void PopAllClips(uint64_t depth)
bool Render(ContentContext &renderer, const RenderTarget &render_target) const
bool OpenPlaygroundHere(Entity entity)
std::shared_ptr< ContentContext > GetContentContext() const
std::function< bool(ContentContext &context, RenderPass &pass)> EntityPlaygroundCallback
void SetTypographerContext(std::shared_ptr< TypographerContext > typographer_context)
bool Render(const ContentContext &renderer, RenderPass &parent_pass) const
Definition entity.cc:173
void Reset()
Resets the contents of the HostBuffer to nothing so it can be reused.
std::function< bool(RenderPass &pass)> SinglePassCallback
Definition playground.h:52
const PlaygroundSwitches switches_
Definition playground.h:120
std::shared_ptr< Context > GetContext() const
Definition playground.cc:89
bool OpenPlaygroundHere(const Renderer::RenderCallback &render_callback)
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:33
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
GAsyncResult * result