| 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
5 #include "impeller/display_list/aiks_playground.h"
6
7 #include <memory>
8
9 #include "impeller/display_list/aiks_context.h"
10 #include "impeller/display_list/dl_dispatcher.h"
11 #include "impeller/typographer/backends/skia/typographer_context_skia.h"
12 #include "impeller/typographer/typographer_context.h"
13
14 namespace impeller {
15
16 AiksPlayground::AiksPlayground()
17 : typographer_context_(TypographerContextSkia::Make()) {}
18
19 AiksPlayground::~AiksPlayground() = default;
20
21 void AiksPlayground::SetTypographerContext(
22 std::shared_ptr<TypographerContext> typographer_context) {
23 typographer_context_ = std::move(typographer_context);
24 }
25
26 void AiksPlayground::TearDown() {
27 PlaygroundTest::TearDown();
28 }
29
30 bool AiksPlayground::ImGuiBegin(const char* name,
31 bool* p_open,
32 ImGuiWindowFlags flags) {
33 ImGui::Begin(name, p_open, flags);
34 return true;
35 }
36
37 bool AiksPlayground::OpenPlaygroundHere(
38 const sk_sp<flutter::DisplayList>& list) {
39 return OpenPlaygroundHere([list]() { return list; });
40 }
41
42 bool AiksPlayground::OpenPlaygroundHere(
43 const AiksDlPlaygroundCallback& callback) {
44 AiksContext renderer(GetContext(), typographer_context_);
45
46 if (!renderer.IsValid()) {
47 return false;
48 }
49
50 return Playground::OpenPlaygroundHere(
51 [&renderer, &callback](RenderTarget& render_target) -> bool {
52 auto display_list = callback();
53 TextFrameDispatcher collector(renderer.GetContentContext(), //
54 Matrix(), //
55 Rect::MakeMaximum() //
56 );
57 display_list->Dispatch(collector);
58
59 CanvasDlDispatcher impeller_dispatcher(
60 renderer.GetContentContext(), render_target,
61 display_list->root_has_backdrop_filter(),
62 display_list->max_root_blend_mode(), IRect::MakeMaximum());
63 display_list->Dispatch(impeller_dispatcher);
64 impeller_dispatcher.FinishRecording();
65 renderer.GetContentContext().GetTransientsBuffer().Reset();
66 renderer.GetContentContext().GetLazyGlyphAtlas()->ResetTextFrames();
67 return true;
68 });
69 }
70
71 } // namespace impeller
impeller::CanvasDlDispatcher
Definition: dl_dispatcher.h:246
impeller::CanvasDlDispatcher::FinishRecording
void FinishRecording()
Definition: dl_dispatcher.h:274
impeller::AiksContext
Definition: aiks_context.h:19
impeller::ContentContext::GetLazyGlyphAtlas
const std::shared_ptr< LazyGlyphAtlas > & GetLazyGlyphAtlas() const
Definition: content_context.h:721
impeller::AiksContext::GetContentContext
ContentContext & GetContentContext() const
Definition: aiks_context.cc:42
aiks_context.h
dl_dispatcher.h
impeller::AiksPlayground::OpenPlaygroundHere
bool OpenPlaygroundHere(const AiksDlPlaygroundCallback &callback)
Definition: aiks_playground.cc:42
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::Playground::OpenPlaygroundHere
bool OpenPlaygroundHere(const RenderCallback &render_callback)
Definition: playground.cc:197
impeller::PlaygroundTest::TearDown
void TearDown() override
Definition: playground_test.cc:76
impeller::RenderTarget
Definition: render_target.h:38
impeller::TypographerContextSkia
Definition: typographer_context_skia.h:12
aiks_playground.h
impeller::AiksPlayground::AiksDlPlaygroundCallback
std::function< sk_sp< flutter::DisplayList >()> AiksDlPlaygroundCallback
Definition: aiks_playground.h:18
impeller::HostBuffer::Reset
void Reset()
Resets the contents of the HostBuffer to nothing so it can be reused.
Definition: host_buffer.cc:208
impeller::TRect< Scalar >::MakeMaximum
constexpr static TRect MakeMaximum()
Definition: rect.h:178
impeller::AiksPlayground::ImGuiBegin
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
Definition: aiks_playground.cc:30
impeller::TextFrameDispatcher
Performs a first pass over the display list to collect all text frames.
Definition: dl_dispatcher.h:288
impeller::Playground::GetContext
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:90
impeller::AiksPlayground::~AiksPlayground
~AiksPlayground()
impeller
Definition: allocation.cc:12
impeller::AiksContext::IsValid
bool IsValid() const
Definition: aiks_context.cc:34
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::ContentContext::GetTransientsBuffer
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
Definition: content_context.h:753