| Flutter Impeller |

aiks_context.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_context.h"
6
7 #include "fml/closure.h"
8 #include "impeller/aiks/picture.h"
9 #include "impeller/typographer/typographer_context.h"
10
11 namespace impeller {
12
13 AiksContext::AiksContext(
14 std::shared_ptr<Context> context,
15 std::shared_ptr<TypographerContext> typographer_context,
16 std::optional<std::shared_ptr<RenderTargetAllocator>>
17 render_target_allocator)
18 : context_(std::move(context)) {
19 if (!context_ || !context_->IsValid()) {
20 return;
21 }
22
23 content_context_ = std::make_unique<ContentContext>(
24 context_, std::move(typographer_context),
25 render_target_allocator.has_value() ? render_target_allocator.value()
26 : nullptr);
27 if (!content_context_->IsValid()) {
28 return;
29 }
30
31 is_valid_ = true;
32 }
33
34 AiksContext::~AiksContext() = default;
35
36 bool AiksContext::IsValid() const {
37 return is_valid_;
38 }
39
40 std::shared_ptr<Context> AiksContext::GetContext() const {
41 return context_;
42 }
43
44 ContentContext& AiksContext::GetContentContext() const {
45 return *content_context_;
46 }
47
48 bool AiksContext::Render(const Picture& picture,
49 RenderTarget& render_target,
50 bool reset_host_buffer) {
51 if (!IsValid()) {
52 return false;
53 }
54
55 fml::ScopedCleanupClosure closure([&]() {
56 if (reset_host_buffer) {
57 content_context_->GetTransientsBuffer().Reset();
58 }
59 });
60 if (picture.pass) {
61 return picture.pass->Render(*content_context_, render_target);
62 }
63
64 return true;
65 }
66
67 } // namespace impeller
impeller::Picture::pass
std::unique_ptr< EntityPass > pass
Definition: picture.h:18
impeller::AiksContext::GetContentContext
ContentContext & GetContentContext() const
Definition: aiks_context.cc:44
impeller::AiksContext::~AiksContext
~AiksContext()
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
picture.h
impeller::AiksContext::AiksContext
AiksContext(std::shared_ptr< Context > context, std::shared_ptr< TypographerContext > typographer_context, std::optional< std::shared_ptr< RenderTargetAllocator >> render_target_allocator=std::nullopt)
Definition: aiks_context.cc:13
impeller::Picture
Definition: picture.h:17
impeller::RenderTarget
Definition: render_target.h:38
impeller::AiksContext::GetContext
std::shared_ptr< Context > GetContext() const
Definition: aiks_context.cc:40
std
Definition: comparable.h:95
impeller
Definition: aiks_blend_unittests.cc:18
impeller::ContentContext
Definition: content_context.h:366
impeller::AiksContext::IsValid
bool IsValid() const
Definition: aiks_context.cc:36