Flutter Impeller
aiks_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 
7 #include <memory>
8 
12 
13 namespace impeller {
14 
16  : typographer_context_(TypographerContextSkia::Make()) {}
17 
19 
21  std::shared_ptr<TypographerContext> typographer_context) {
22  typographer_context_ = std::move(typographer_context);
23 }
24 
26  inspector_.HackResetDueToTextureLeaks();
28 }
29 
31  return OpenPlaygroundHere([&picture](AiksContext& renderer) -> Picture {
32  return std::move(picture);
33  });
34 }
35 
38  return true;
39  }
40 
41  AiksContext renderer(GetContext(), typographer_context_);
42 
43  if (!renderer.IsValid()) {
44  return false;
45  }
46 
48  [this, &renderer, &callback](RenderTarget& render_target) -> bool {
49  const std::optional<Picture>& picture = inspector_.RenderInspector(
50  renderer, [&]() { return callback(renderer); });
51 
52  if (!picture.has_value()) {
53  return false;
54  }
55  return renderer.Render(*picture, render_target, true);
56  });
57 }
58 
59 bool AiksPlayground::ImGuiBegin(const char* name,
60  bool* p_open,
61  ImGuiWindowFlags flags) {
62  ImGui::Begin(name, p_open, flags);
63  return true;
64 }
65 
66 } // namespace impeller
impeller::AiksContext
Definition: aiks_context.h:20
impeller::AiksInspector::RenderInspector
const std::optional< Picture > & RenderInspector(AiksContext &aiks_context, const std::function< std::optional< Picture >()> &picture_callback)
Definition: aiks_playground_inspector.cc:25
impeller::AiksInspector::HackResetDueToTextureLeaks
void HackResetDueToTextureLeaks()
Definition: aiks_playground_inspector.cc:66
aiks_context.h
impeller::AiksContext::Render
bool Render(const Picture &picture, RenderTarget &render_target, bool reset_host_buffer)
Definition: aiks_context.cc:48
typographer_context.h
impeller::AiksPlayground::AiksPlayground
AiksPlayground()
Definition: aiks_playground.cc:15
impeller::AiksPlayground::SetTypographerContext
void SetTypographerContext(std::shared_ptr< TypographerContext > typographer_context)
Definition: aiks_playground.cc:20
typographer_context_skia.h
impeller::AiksPlayground::TearDown
void TearDown() override
Definition: aiks_playground.cc:25
impeller::Picture
Definition: picture.h:20
impeller::AiksPlayground::AiksPlaygroundCallback
std::function< std::optional< Picture >(AiksContext &renderer)> AiksPlaygroundCallback
Definition: aiks_playground.h:21
impeller::PlaygroundTest::TearDown
void TearDown() override
Definition: playground_test.cc:39
impeller::Playground::switches_
const PlaygroundSwitches switches_
Definition: playground.h:117
impeller::RenderTarget
Definition: render_target.h:38
impeller::TypographerContextSkia
Definition: typographer_context_skia.h:12
aiks_playground.h
impeller::AiksPlayground::OpenPlaygroundHere
bool OpenPlaygroundHere(Picture picture)
Definition: aiks_playground.cc:30
impeller::AiksPlayground::ImGuiBegin
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
Definition: aiks_playground.cc:59
impeller::Playground::OpenPlaygroundHere
bool OpenPlaygroundHere(const Renderer::RenderCallback &render_callback)
Definition: playground.cc:198
impeller::Playground::GetContext
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:89
impeller::AiksPlayground::~AiksPlayground
~AiksPlayground()
impeller
Definition: aiks_blur_unittests.cc:20
impeller::PlaygroundSwitches::enable_playground
bool enable_playground
Definition: switches.h:17
impeller::AiksContext::IsValid
bool IsValid() const
Definition: aiks_context.cc:36