Flutter Engine
The Flutter Engine
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
6
7#include "fml/closure.h"
10
11namespace impeller {
12
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
35
37 return is_valid_;
38}
39
40std::shared_ptr<Context> AiksContext::GetContext() const {
41 return context_;
42}
43
45 return *content_context_;
46}
47
49 RenderTarget& render_target,
50 bool reset_host_buffer) {
51 if (!IsValid()) {
52 return false;
53 }
54
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
Wraps a closure that is invoked in the destructor unless released by the caller.
Definition: closure.h:32
ContentContext & GetContentContext() const
Definition: aiks_context.cc:44
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
bool IsValid() const
Definition: aiks_context.cc:36
bool Render(const Picture &picture, RenderTarget &render_target, bool reset_host_buffer)
Definition: aiks_context.cc:48
std::shared_ptr< Context > GetContext() const
Definition: aiks_context.cc:40
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
void Reset(SkPath *path)
Definition: path_ops.cc:40
std::function< void()> closure
Definition: closure.h:14
Definition: ref_ptr.h:256