| Flutter Impeller |

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/renderer/context.h"
6
7 #include <mutex>
8 #include <utility>
9
10 namespace impeller {
11
12 ImpellerContextFuture::ImpellerContextFuture(
13 std::future<std::shared_ptr<impeller::Context>> context)
14 : future_(std::move(context)) {}
15
16 std::shared_ptr<impeller::Context> ImpellerContextFuture::GetContext() {
17 std::scoped_lock<std::mutex> lock(mutex_);
18 if (!did_wait_ && future_.valid()) {
19 context_ = future_.get();
20 did_wait_ = true;
21 }
22 return context_;
23 }
24
25 Context::~Context() = default;
26
27 Context::Context(const Flags& flags) : flags_(flags) {}
28
29 bool Context::UpdateOffscreenLayerPixelFormat(PixelFormat format) {
30 return false;
31 }
32
33 bool Context::EnqueueCommandBuffer(
34 std::shared_ptr<CommandBuffer> command_buffer) {
35 return GetCommandQueue()->Submit({std::move(command_buffer)}).ok();
36 }
37
38 bool Context::FlushCommandBuffers() {
39 return true;
40 }
41
42 std::shared_ptr<const IdleWaiter> Context::GetIdleWaiter() const {
43 return nullptr;
44 }
45
46 void Context::ResetThreadLocalState() const {
47 // Nothing to do.
48 }
49
50 bool Context::AddTrackingFence(const std::shared_ptr<Texture>& texture) const {
51 return false;
52 }
53
54 bool Context::SubmitOnscreen(std::shared_ptr<CommandBuffer> cmd_buffer) {
55 return EnqueueCommandBuffer(std::move(cmd_buffer));
56 }
57
58 } // namespace impeller
impeller::Context::GetIdleWaiter
virtual std::shared_ptr< const IdleWaiter > GetIdleWaiter() const
Definition: context.cc:42
impeller::Context::AddTrackingFence
virtual bool AddTrackingFence(const std::shared_ptr< Texture > &texture) const
Definition: context.cc:50
impeller::Context::SubmitOnscreen
virtual bool SubmitOnscreen(std::shared_ptr< CommandBuffer > cmd_buffer)
Submit the command buffer that renders to the onscreen surface.
Definition: context.cc:54
impeller::Context::UpdateOffscreenLayerPixelFormat
virtual bool UpdateOffscreenLayerPixelFormat(PixelFormat format)
Definition: context.cc:29
impeller::Context::Context
Context(const Flags &flags)
Definition: context.cc:27
impeller::Context::FlushCommandBuffers
virtual bool FlushCommandBuffers()
Flush all pending command buffers.
Definition: context.cc:38
impeller::Context::GetCommandQueue
virtual std::shared_ptr< CommandQueue > GetCommandQueue() const =0
Return the graphics queue for submitting command buffers.
impeller::Context::~Context
virtual ~Context()
Destroys an Impeller context.
impeller::Context::ResetThreadLocalState
virtual void ResetThreadLocalState() const
Definition: context.cc:46
impeller::Context::EnqueueCommandBuffer
virtual bool EnqueueCommandBuffer(std::shared_ptr< CommandBuffer > command_buffer)
Enqueue command_buffer for submission by the end of the frame.
Definition: context.cc:33
impeller::ImpellerContextFuture::ImpellerContextFuture
ImpellerContextFuture(std::future< std::shared_ptr< impeller::Context >> context)
Definition: context.cc:12
impeller::ImpellerContextFuture::GetContext
std::shared_ptr< impeller::Context > GetContext()
Definition: context.cc:16
impeller
Definition: allocation.cc:12
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
std
Definition: comparable.h:95
context.h
impeller::Flags
Definition: flags.h:9