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/aiks/aiks_playground.h
"
6
7
#include <memory>
8
#include <optional>
9
10
#include "
impeller/aiks/aiks_context.h
"
11
#include "
impeller/display_list/dl_dispatcher.h
"
12
#include "
impeller/typographer/backends/skia/typographer_context_skia.h
"
13
#include "
impeller/typographer/typographer_context.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::OpenPlaygroundHere
(
Picture
picture) {
32
if
(!
switches_
.
enable_playground
) {
33
return
true
;
34
}
35
36
AiksContext
renderer(
GetContext
(), typographer_context_);
37
38
if
(!renderer.
IsValid
()) {
39
return
false
;
40
}
41
42
return
Playground::OpenPlaygroundHere
(
43
[&renderer, &picture](
RenderTarget
& render_target) ->
bool
{
44
return
renderer.
Render
(picture, render_target,
true
);
45
});
46
}
47
48
bool
AiksPlayground::OpenPlaygroundHere
(
AiksPlaygroundCallback
callback) {
49
if
(!
switches_
.
enable_playground
) {
50
return
true
;
51
}
52
53
AiksContext
renderer(
GetContext
(), typographer_context_);
54
55
if
(!renderer.
IsValid
()) {
56
return
false
;
57
}
58
59
return
Playground::OpenPlaygroundHere
(
60
[&renderer, &callback](
RenderTarget
& render_target) ->
bool
{
61
std::optional<Picture> picture = callback(renderer);
62
if
(!picture.has_value()) {
63
return
false
;
64
}
65
return
renderer.
Render
(*picture, render_target,
true
);
66
});
67
}
68
69
bool
AiksPlayground::ImGuiBegin
(
const
char
* name,
70
bool
* p_open,
71
ImGuiWindowFlags flags) {
72
ImGui::Begin(name, p_open, flags);
73
return
true
;
74
}
75
76
bool
AiksPlayground::OpenPlaygroundHere
(
77
const
sk_sp<flutter::DisplayList>& list) {
78
DlDispatcher
dispatcher;
79
list->Dispatch(dispatcher);
80
Picture
picture = dispatcher.
EndRecordingAsPicture
();
81
return
OpenPlaygroundHere
(std::move(picture));
82
}
83
84
bool
AiksPlayground::OpenPlaygroundHere
(
85
const
AiksDlPlaygroundCallback
& callback) {
86
AiksContext
renderer(
GetContext
(), typographer_context_);
87
88
if
(!renderer.
IsValid
()) {
89
return
false
;
90
}
91
92
return
Playground::OpenPlaygroundHere
(
93
[&renderer, &callback](
RenderTarget
& render_target) ->
bool
{
94
auto
display_list = callback();
95
DlDispatcher
dispatcher;
96
display_list->Dispatch(dispatcher);
97
Picture
picture = dispatcher.
EndRecordingAsPicture
();
98
99
return
renderer.
Render
(picture, render_target,
true
);
100
});
101
}
102
103
}
// namespace impeller
impeller::DlDispatcherBase::EndRecordingAsPicture
Picture EndRecordingAsPicture()
Definition:
dl_dispatcher.cc:1203
impeller::AiksContext
Definition:
aiks_context.h:19
impeller::DlDispatcher
Definition:
dl_dispatcher.h:261
aiks_context.h
dl_dispatcher.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:17
impeller::AiksPlayground::SetTypographerContext
void SetTypographerContext(std::shared_ptr< TypographerContext > typographer_context)
Definition:
aiks_playground.cc:22
typographer_context_skia.h
impeller::AiksPlayground::TearDown
void TearDown() override
Definition:
aiks_playground.cc:27
impeller::Picture
Definition:
picture.h:17
impeller::AiksPlayground::AiksPlaygroundCallback
std::function< std::optional< Picture >(AiksContext &renderer)> AiksPlaygroundCallback
Definition:
aiks_playground.h:20
impeller::PlaygroundTest::TearDown
void TearDown() override
Definition:
playground_test.cc:61
impeller::Playground::switches_
const PlaygroundSwitches switches_
Definition:
playground.h:118
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:31
impeller::AiksPlayground::AiksDlPlaygroundCallback
std::function< sk_sp< flutter::DisplayList >()> AiksDlPlaygroundCallback
Definition:
aiks_playground.h:22
impeller::AiksPlayground::ImGuiBegin
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
Definition:
aiks_playground.cc:69
impeller::Playground::OpenPlaygroundHere
bool OpenPlaygroundHere(const Renderer::RenderCallback &render_callback)
Definition:
playground.cc:204
impeller::Playground::GetContext
std::shared_ptr< Context > GetContext() const
Definition:
playground.cc:90
impeller::AiksPlayground::~AiksPlayground
~AiksPlayground()
impeller
Definition:
aiks_blend_unittests.cc:18
impeller::PlaygroundSwitches::enable_playground
bool enable_playground
Definition:
switches.h:16
impeller::AiksContext::IsValid
bool IsValid() const
Definition:
aiks_context.cc:36
impeller
aiks
aiks_playground.cc
Generated by
1.8.17