| 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 #include "include/core/SkRect.h"
14
15 namespace impeller {
16
17 AiksPlayground::AiksPlayground()
18 : typographer_context_(TypographerContextSkia::Make()) {}
19
20 AiksPlayground::~AiksPlayground() = default;
21
22 void AiksPlayground::SetTypographerContext(
23 std::shared_ptr<TypographerContext> typographer_context) {
24 typographer_context_ = std::move(typographer_context);
25 }
26
27 void AiksPlayground::TearDown() {
28 PlaygroundTest::TearDown();
29 }
30
31 bool AiksPlayground::ImGuiBegin(const char* name,
32 bool* p_open,
33 ImGuiWindowFlags flags) {
34 ImGui::Begin(name, p_open, flags);
35 return true;
36 }
37
38 bool AiksPlayground::OpenPlaygroundHere(
39 const sk_sp<flutter::DisplayList>& list) {
40 return OpenPlaygroundHere([list]() { return list; });
41 }
42
43 bool AiksPlayground::OpenPlaygroundHere(
44 const AiksDlPlaygroundCallback& callback) {
45 AiksContext renderer(GetContext(), typographer_context_);
46
47 if (!renderer.IsValid()) {
48 return false;
49 }
50
51 return Playground::OpenPlaygroundHere(
52 [&renderer, &callback](RenderTarget& render_target) -> bool {
53 return RenderToTarget(
54 renderer.GetContentContext(), //
55 render_target, //
56 callback(), //
57 SkIRect::MakeWH(render_target.GetRenderTargetSize().width,
58 render_target.GetRenderTargetSize().height), //
59 /*reset_host_buffer=*/true, //
60 /*is_onscreen=*/false);
61 });
62 }
63
64 } // namespace impeller
aiks_context.h
aiks_playground.h
impeller::AiksContext
Definition: aiks_context.h:19
impeller::AiksContext::GetContentContext
ContentContext & GetContentContext() const
Definition: aiks_context.cc:42
impeller::AiksContext::IsValid
bool IsValid() const
Definition: aiks_context.cc:34
impeller::AiksPlayground::AiksPlayground
AiksPlayground()
Definition: aiks_playground.cc:17
impeller::AiksPlayground::AiksDlPlaygroundCallback
std::function< sk_sp< flutter::DisplayList >()> AiksDlPlaygroundCallback
Definition: aiks_playground.h:18
impeller::AiksPlayground::OpenPlaygroundHere
bool OpenPlaygroundHere(const AiksDlPlaygroundCallback &callback)
Definition: aiks_playground.cc:43
impeller::AiksPlayground::SetTypographerContext
void SetTypographerContext(std::shared_ptr< TypographerContext > typographer_context)
Definition: aiks_playground.cc:22
impeller::AiksPlayground::~AiksPlayground
~AiksPlayground()
impeller::AiksPlayground::TearDown
void TearDown() override
Definition: aiks_playground.cc:27
impeller::AiksPlayground::ImGuiBegin
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
Definition: aiks_playground.cc:31
impeller::Playground::OpenPlaygroundHere
bool OpenPlaygroundHere(const RenderCallback &render_callback)
Definition: playground.cc:201
impeller::Playground::GetContext
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:91
impeller::PlaygroundTest::TearDown
void TearDown() override
Definition: playground_test.cc:76
impeller::RenderTarget
Definition: render_target.h:38
impeller::RenderTarget::GetRenderTargetSize
ISize GetRenderTargetSize() const
Definition: render_target.cc:171
impeller::TypographerContextSkia
Definition: typographer_context_skia.h:12
dl_dispatcher.h
impeller
Definition: allocation.cc:12
impeller::RenderToTarget
bool RenderToTarget(ContentContext &context, RenderTarget render_target, const sk_sp< flutter::DisplayList > &display_list, SkIRect cull_rect, bool reset_host_buffer, bool is_onscreen)
Render the provided display list to the render target.
Definition: dl_dispatcher.cc:1314
impeller::TSize::height
Type height
Definition: size.h:29
impeller::TSize::width
Type width
Definition: size.h:28
typographer_context.h
typographer_context_skia.h