Flutter Engine
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)
 
 ~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
 
sk_sp< GrDirectContext > GetSharedResourceContext () const
 
- Public Member Functions inherited from flutter::IOManager
virtual ~IOManager ()=default
 

Static Public Member Functions

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

Detailed Description

Definition at line 18 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 
)

Definition at line 36 of file shell_io_manager.cc.

References FML_DLOG.

40  : resource_context_(std::move(resource_context)),
41  resource_context_weak_factory_(
42  resource_context_
43  ? std::make_unique<fml::WeakPtrFactory<GrDirectContext>>(
44  resource_context_.get())
45  : nullptr),
46  unref_queue_(fml::MakeRefCounted<flutter::SkiaUnrefQueue>(
47  std::move(unref_queue_task_runner),
50  is_gpu_disabled_sync_switch_(is_gpu_disabled_sync_switch),
51  weak_factory_(this) {
52  if (!resource_context_) {
53 #ifndef OS_FUCHSIA
54  FML_DLOG(WARNING) << "The IO manager was initialized without a resource "
55  "context. Async texture uploads will be disabled. "
56  "Expect performance degradation.";
57 #endif // OS_FUCHSIA
58  }
59 }
fml::WeakPtr< GrDirectContext > GetResourceContext() const override
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition: time_delta.h:46
#define FML_DLOG(severity)
Definition: logging.h:85

◆ ~ShellIOManager()

flutter::ShellIOManager::~ShellIOManager ( )
override

Definition at line 61 of file shell_io_manager.cc.

References flutter::SkiaUnrefQueue::Drain().

61  {
62  // Last chance to drain the IO queue as the platform side reference to the
63  // underlying OpenGL context may be going away.
64  is_gpu_disabled_sync_switch_->Execute(
65  fml::SyncSwitch::Handlers().SetIfFalse([&] { unref_queue_->Drain(); }));
66 }
Represents the 2 code paths available when calling |SyncSwitch::Execute|.
Definition: sync_switch.h:24

Member Function Documentation

◆ CreateCompatibleResourceLoadingContext()

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

Definition at line 15 of file shell_io_manager.cc.

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

Referenced by flutter::IOSContextGL::CreateResourceContext(), flutter::EmbedderSurfaceGL::EmbedderSurfaceGL(), and flutter::PlatformViewAndroid::RegisterExternalTexture().

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

◆ GetIsGpuDisabledSyncSwitch()

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

Implements flutter::IOManager.

Definition at line 111 of file shell_io_manager.cc.

111  {
112  return is_gpu_disabled_sync_switch_;
113 }

◆ GetResourceContext()

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

Implements flutter::IOManager.

Definition at line 93 of file shell_io_manager.cc.

93  {
94  return resource_context_weak_factory_
95  ? resource_context_weak_factory_->GetWeakPtr()
97 }

◆ GetSharedResourceContext()

sk_sp<GrDirectContext> flutter::ShellIOManager::GetSharedResourceContext ( ) const
inline

Definition at line 59 of file shell_io_manager.h.

59  {
60  return resource_context_;
61  };

◆ GetSkiaUnrefQueue()

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

Implements flutter::IOManager.

Definition at line 100 of file shell_io_manager.cc.

100  {
101  return unref_queue_;
102 }

◆ GetWeakIOManager()

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

Implements flutter::IOManager.

Definition at line 105 of file shell_io_manager.cc.

105  {
106  return weak_factory_.GetWeakPtr();
107 }

◆ GetWeakPtr()

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

Definition at line 88 of file shell_io_manager.cc.

88  {
89  return weak_factory_.GetWeakPtr();
90 }

◆ NotifyResourceContextAvailable()

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

Definition at line 68 of file shell_io_manager.cc.

References UpdateResourceContext().

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

◆ UpdateResourceContext()

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

Definition at line 78 of file shell_io_manager.cc.

Referenced by NotifyResourceContextAvailable().

79  {
80  resource_context_ = std::move(resource_context);
81  resource_context_weak_factory_ =
82  resource_context_
83  ? std::make_unique<fml::WeakPtrFactory<GrDirectContext>>(
84  resource_context_.get())
85  : nullptr;
86 }

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