Flutter Impeller
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 
11 namespace impeller {
12 
14 
16 
18  if (!IsPlaygroundEnabled()) {
19  return true;
20  }
21 
22  ContentContext& content_context = GetContentContext();
23  if (!content_context.IsValid()) {
24  return false;
25  }
26  SinglePassCallback callback = [&](RenderPass& pass) -> bool {
27  content_context.GetRenderTargetCache()->Start();
28  bool result = entity.Render(content_context, pass);
29  content_context.GetRenderTargetCache()->End();
30  content_context.GetTransientsDataBuffer().Reset();
31  content_context.GetTransientsIndexesBuffer().Reset();
32  return result;
33  };
34  return Playground::OpenPlaygroundHere(callback);
35 }
36 
38  if (!IsPlaygroundEnabled()) {
39  return true;
40  }
41 
42  ContentContext& content_context = GetContentContext();
43  if (!content_context.IsValid()) {
44  return false;
45  }
46  SinglePassCallback pass_callback = [&](RenderPass& pass) -> bool {
47  content_context.GetRenderTargetCache()->Start();
48  bool result = callback(content_context, pass);
49  content_context.GetRenderTargetCache()->End();
50  content_context.GetTransientsDataBuffer().Reset();
51  content_context.GetTransientsIndexesBuffer().Reset();
52  return result;
53  };
54  return Playground::OpenPlaygroundHere(pass_callback);
55 }
56 
57 } // namespace impeller
HostBuffer & GetTransientsIndexesBuffer() const
Retrieve the current host buffer for transient storage of indexes used for indexed draws.
HostBuffer & GetTransientsDataBuffer() const
Retrieve the current host buffer for transient storage of other non-index data.
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
bool Render(const ContentContext &renderer, RenderPass &parent_pass) const
Definition: entity.cc:145
bool OpenPlaygroundHere(Entity entity)
std::function< bool(ContentContext &context, RenderPass &pass)> EntityPlaygroundCallback
void Reset()
Resets the contents of the HostBuffer to nothing so it can be reused.
Definition: host_buffer.cc:229
bool OpenPlaygroundHere(const RenderCallback &render_callback)
Definition: playground.cc:287
bool IsPlaygroundEnabled() const
Definition: playground.cc:224
std::function< bool(RenderPass &pass)> SinglePassCallback
Definition: playground.h:39
ContentContext & GetContentContext() const
Definition: playground.cc:146
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30