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 #include "third_party/imgui/imgui.h"
13 
14 namespace impeller {
15 
17  : typographer_context_(TypographerContextSkia::Make()) {}
18 
20 
22  std::shared_ptr<TypographerContext> typographer_context) {
23  typographer_context_ = std::move(typographer_context);
24 }
25 
27  inspector_.HackResetDueToTextureLeaks();
29 }
30 
32  return OpenPlaygroundHere([&picture](AiksContext& renderer) -> Picture {
33  return std::move(picture);
34  });
35 }
36 
39  return true;
40  }
41 
42  AiksContext renderer(GetContext(), typographer_context_);
43 
44  if (!renderer.IsValid()) {
45  return false;
46  }
47 
49  [this, &renderer, &callback](RenderTarget& render_target) -> bool {
50  const std::optional<Picture>& picture = inspector_.RenderInspector(
51  renderer, [&]() { return callback(renderer); });
52 
53  if (!picture.has_value()) {
54  return false;
55  }
56  return renderer.Render(*picture, render_target);
57  });
58 }
59 
60 } // 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
typographer_context.h
impeller::AiksPlayground::AiksPlayground
AiksPlayground()
Definition: aiks_playground.cc:16
impeller::AiksPlayground::SetTypographerContext
void SetTypographerContext(std::shared_ptr< TypographerContext > typographer_context)
Definition: aiks_playground.cc:21
typographer_context_skia.h
impeller::AiksPlayground::TearDown
void TearDown() override
Definition: aiks_playground.cc:26
impeller::Picture
Definition: picture.h:19
impeller::AiksPlayground::AiksPlaygroundCallback
std::function< std::optional< Picture >(AiksContext &renderer)> AiksPlaygroundCallback
Definition: aiks_playground.h:19
impeller::PlaygroundTest::TearDown
void TearDown() override
Definition: playground_test.cc:39
impeller::Playground::switches_
const PlaygroundSwitches switches_
Definition: playground.h:91
impeller::RenderTarget
Definition: render_target.h:48
impeller::TypographerContextSkia
Definition: typographer_context_skia.h:12
aiks_playground.h
impeller::AiksPlayground::OpenPlaygroundHere
bool OpenPlaygroundHere(Picture picture)
Definition: aiks_playground.cc:31
impeller::AiksContext::Render
bool Render(const Picture &picture, RenderTarget &render_target)
Definition: aiks_context.cc:43
impeller::Playground::OpenPlaygroundHere
bool OpenPlaygroundHere(const Renderer::RenderCallback &render_callback)
Definition: playground.cc:189
impeller::Playground::GetContext
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:86
impeller::AiksPlayground::~AiksPlayground
~AiksPlayground()
impeller
Definition: aiks_context.cc:10
impeller::PlaygroundSwitches::enable_playground
bool enable_playground
Definition: switches.h:16
impeller::AiksContext::IsValid
bool IsValid() const
Definition: aiks_context.cc:31