Flutter Engine
 
Loading...
Searching...
No Matches
flutter::ShellIOManager Class Referencefinal

#include <shell_io_manager.h>

Inheritance diagram for flutter::ShellIOManager:
flutter::IOManager

Public Member Functions

 ShellIOManager (sk_sp< GrDirectContext > resource_context, std::shared_ptr< const fml::SyncSwitch > is_gpu_disabled_sync_switch, fml::RefPtr< fml::TaskRunner > unref_queue_task_runner, std::shared_ptr< impeller::ImpellerContextFuture > impeller_context, bool impeller_enabled, fml::TimeDelta unref_queue_drain_delay=fml::TimeDelta::FromMilliseconds(8))
 
 ~ShellIOManager () override
 
void NotifyResourceContextAvailable (sk_sp< GrDirectContext > resource_context)
 
void UpdateResourceContext (sk_sp< GrDirectContext > resource_context)
 
fml::WeakPtr< ShellIOManagerGetWeakPtr ()
 
fml::WeakPtr< IOManagerGetWeakIOManager () const override
 
fml::WeakPtr< GrDirectContext > GetResourceContext () const override
 
fml::RefPtr< flutter::SkiaUnrefQueueGetSkiaUnrefQueue () const override
 
std::shared_ptr< const fml::SyncSwitchGetIsGpuDisabledSyncSwitch () override
 
std::shared_ptr< impeller::ContextGetImpellerContext () const override
 Retrieve the impeller::Context.
 
- Public Member Functions inherited from flutter::IOManager
virtual ~IOManager ()=default
 

Static Public Member Functions

static sk_sp< GrDirectContext > CreateCompatibleResourceLoadingContext (GrBackendApi backend, const sk_sp< const GrGLInterface > &gl_interface)
 

Detailed Description

Definition at line 22 of file shell_io_manager.h.

Constructor & Destructor Documentation

◆ ShellIOManager()

flutter::ShellIOManager::ShellIOManager ( sk_sp< GrDirectContext >  resource_context,
std::shared_ptr< const fml::SyncSwitch is_gpu_disabled_sync_switch,
fml::RefPtr< fml::TaskRunner unref_queue_task_runner,
std::shared_ptr< impeller::ImpellerContextFuture impeller_context,
bool  impeller_enabled,
fml::TimeDelta  unref_queue_drain_delay = fml::TimeDelta::FromMilliseconds(8) 
)

Definition at line 38 of file shell_io_manager.cc.

45 : resource_context_(std::move(resource_context)),
46 resource_context_weak_factory_(
47 resource_context_
48 ? std::make_unique<fml::WeakPtrFactory<GrDirectContext>>(
49 resource_context_.get())
50 : nullptr),
52 std::move(unref_queue_task_runner),
53 unref_queue_drain_delay,
54 resource_context_,
55 /*drain_immediate=*/impeller_enabled)),
56 is_gpu_disabled_sync_switch_(std::move(is_gpu_disabled_sync_switch)),
57 impeller_context_(std::move(impeller_context)),
58 weak_factory_(this) {
59 if (!resource_context_ && !impeller_enabled) {
60#ifndef OS_FUCHSIA
61 FML_DLOG(WARNING) << "The IO manager was initialized without a resource "
62 "context. Async texture uploads will be disabled. "
63 "Expect performance degradation.";
64#endif // OS_FUCHSIA
65 }
66}
#define FML_DLOG(severity)
Definition logging.h:121
UnrefQueue< GrDirectContext > SkiaUnrefQueue
RefPtr< T > MakeRefCounted(Args &&... args)
Definition ref_ptr.h:253
Definition ref_ptr.h:261

References FML_DLOG.

◆ ~ShellIOManager()

flutter::ShellIOManager::~ShellIOManager ( )
override

Definition at line 68 of file shell_io_manager.cc.

68 {
69 // Last chance to drain the IO queue as the platform side reference to the
70 // underlying OpenGL context may be going away.
71 is_gpu_disabled_sync_switch_->Execute(
72 fml::SyncSwitch::Handlers().SetIfFalse([&] { unref_queue_->Drain(); }));
73}
Represents the 2 code paths available when calling |SyncSwitchExecute|.
Definition sync_switch.h:35

Member Function Documentation

◆ CreateCompatibleResourceLoadingContext()

sk_sp< GrDirectContext > flutter::ShellIOManager::CreateCompatibleResourceLoadingContext ( GrBackendApi  backend,
const sk_sp< const GrGLInterface > &  gl_interface 
)
static

Definition at line 17 of file shell_io_manager.cc.

19 {
20#if SK_GL
21 if (backend != GrBackendApi::kOpenGL) {
22 return nullptr;
23 }
24
26
27 if (auto context = GrDirectContexts::MakeGL(gl_interface, options)) {
28 // Do not cache textures created by the image decoder. These textures
29 // should be deleted when they are no longer referenced by an SkImage.
30 context->setResourceCacheLimit(0);
31 return context;
32 }
33#endif // SK_GL
34
35 return nullptr;
36}
GrContextOptions MakeDefaultContextOptions(ContextType type, std::optional< GrBackendApi > api)
Initializes GrContextOptions with values suitable for Flutter. The options can be further tweaked bef...

References flutter::kResource, and flutter::MakeDefaultContextOptions().

◆ GetImpellerContext()

std::shared_ptr< impeller::Context > flutter::ShellIOManager::GetImpellerContext ( ) const
overridevirtual

Retrieve the impeller::Context.

Call may block until context is availabe.

Implements flutter::IOManager.

Definition at line 124 of file shell_io_manager.cc.

124 {
125 return impeller_context_->GetContext();
126}

◆ GetIsGpuDisabledSyncSwitch()

std::shared_ptr< const fml::SyncSwitch > flutter::ShellIOManager::GetIsGpuDisabledSyncSwitch ( )
overridevirtual

Implements flutter::IOManager.

Definition at line 119 of file shell_io_manager.cc.

119 {
120 return is_gpu_disabled_sync_switch_;
121}

◆ GetResourceContext()

fml::WeakPtr< GrDirectContext > flutter::ShellIOManager::GetResourceContext ( ) const
overridevirtual

Implements flutter::IOManager.

Definition at line 101 of file shell_io_manager.cc.

101 {
102 return resource_context_weak_factory_
103 ? resource_context_weak_factory_->GetWeakPtr()
105}

◆ GetSkiaUnrefQueue()

fml::RefPtr< flutter::SkiaUnrefQueue > flutter::ShellIOManager::GetSkiaUnrefQueue ( ) const
overridevirtual

Implements flutter::IOManager.

Definition at line 108 of file shell_io_manager.cc.

108 {
109 return unref_queue_;
110}

◆ GetWeakIOManager()

fml::WeakPtr< IOManager > flutter::ShellIOManager::GetWeakIOManager ( ) const
overridevirtual

Implements flutter::IOManager.

Definition at line 113 of file shell_io_manager.cc.

113 {
114 return weak_factory_.GetWeakPtr();
115}

◆ GetWeakPtr()

fml::WeakPtr< ShellIOManager > flutter::ShellIOManager::GetWeakPtr ( )

Definition at line 96 of file shell_io_manager.cc.

96 {
97 return weak_factory_.GetWeakPtr();
98}

◆ NotifyResourceContextAvailable()

void flutter::ShellIOManager::NotifyResourceContextAvailable ( sk_sp< GrDirectContext >  resource_context)

Definition at line 75 of file shell_io_manager.cc.

76 {
77 // The resource context needs to survive as long as we have Dart objects
78 // referencing. We shouldn't ever need to replace it if we have one - unless
79 // we've somehow shut down the Dart VM and started a new one fresh.
80 if (!resource_context_) {
81 UpdateResourceContext(std::move(resource_context));
82 }
83}
void UpdateResourceContext(sk_sp< GrDirectContext > resource_context)

References UpdateResourceContext().

◆ UpdateResourceContext()

void flutter::ShellIOManager::UpdateResourceContext ( sk_sp< GrDirectContext >  resource_context)

Definition at line 85 of file shell_io_manager.cc.

86 {
87 resource_context_ = std::move(resource_context);
88 resource_context_weak_factory_ =
89 resource_context_
90 ? std::make_unique<fml::WeakPtrFactory<GrDirectContext>>(
91 resource_context_.get())
92 : nullptr;
93 unref_queue_->UpdateResourceContext(resource_context_);
94}

Referenced by NotifyResourceContextAvailable().


The documentation for this class was generated from the following files: