Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
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::Context > impeller_context, 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< GrDirectContextGetResourceContext () const override
 
fml::RefPtr< flutter::SkiaUnrefQueueGetSkiaUnrefQueue () const override
 
std::shared_ptr< const fml::SyncSwitchGetIsGpuDisabledSyncSwitch () override
 
std::shared_ptr< impeller::ContextGetImpellerContext () const override
 
- Public Member Functions inherited from flutter::IOManager
virtual ~IOManager ()=default
 
virtual fml::WeakPtr< IOManagerGetWeakIOManager () const =0
 
virtual fml::WeakPtr< GrDirectContextGetResourceContext () const =0
 
virtual fml::RefPtr< flutter::SkiaUnrefQueueGetSkiaUnrefQueue () const =0
 
virtual std::shared_ptr< const fml::SyncSwitchGetIsGpuDisabledSyncSwitch ()=0
 
virtual std::shared_ptr< impeller::ContextGetImpellerContext () const
 

Static Public Member Functions

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

Detailed Description

Definition at line 21 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::Context impeller_context,
fml::TimeDelta  unref_queue_drain_delay = fml::TimeDelta::FromMilliseconds(8) 
)

Definition at line 38 of file shell_io_manager.cc.

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

◆ ~ShellIOManager()

flutter::ShellIOManager::~ShellIOManager ( )
override

Definition at line 67 of file shell_io_manager.cc.

67 {
68 // Last chance to drain the IO queue as the platform side reference to the
69 // underlying OpenGL context may be going away.
70 is_gpu_disabled_sync_switch_->Execute(
71 fml::SyncSwitch::Handlers().SetIfFalse([&] { unref_queue_->Drain(); }));
72}
Represents the 2 code paths available when calling |SyncSwitch::Execute|.
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
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}
const char * options
const char * backend
SK_API sk_sp< GrDirectContext > MakeGL(sk_sp< const GrGLInterface >, const GrContextOptions &)
GrContextOptions MakeDefaultContextOptions(ContextType type, std::optional< GrBackendApi > api)
Initializes GrContextOptions with values suitable for Flutter. The options can be further tweaked bef...

◆ GetImpellerContext()

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

Reimplemented from flutter::IOManager.

Definition at line 123 of file shell_io_manager.cc.

123 {
124 return impeller_context_;
125}

◆ GetIsGpuDisabledSyncSwitch()

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

Implements flutter::IOManager.

Definition at line 118 of file shell_io_manager.cc.

118 {
119 return is_gpu_disabled_sync_switch_;
120}

◆ GetResourceContext()

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

Implements flutter::IOManager.

Definition at line 100 of file shell_io_manager.cc.

100 {
101 return resource_context_weak_factory_
102 ? resource_context_weak_factory_->GetWeakPtr()
104}

◆ GetSkiaUnrefQueue()

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

Implements flutter::IOManager.

Definition at line 107 of file shell_io_manager.cc.

107 {
108 return unref_queue_;
109}

◆ GetWeakIOManager()

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

Implements flutter::IOManager.

Definition at line 112 of file shell_io_manager.cc.

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

◆ GetWeakPtr()

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

Definition at line 95 of file shell_io_manager.cc.

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

◆ NotifyResourceContextAvailable()

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

Definition at line 74 of file shell_io_manager.cc.

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

◆ UpdateResourceContext()

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

Definition at line 84 of file shell_io_manager.cc.

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

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