11#include "third_party/skia/include/gpu/ganesh/gl/GrGLDirectContext.h"
12#include "third_party/skia/include/gpu/ganesh/gl/GrGLInterface.h"
13#include "third_party/skia/include/gpu/ganesh/gl/GrGLTypes.h"
19 const sk_sp<const GrGLInterface>& gl_interface) {
21 if (backend != GrBackendApi::kOpenGL) {
27 if (
auto context = GrDirectContexts::MakeGL(gl_interface, options)) {
30 context->setResourceCacheLimit(0);
39 sk_sp<GrDirectContext> resource_context,
40 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch,
42 std::shared_ptr<impeller::ImpellerContextFuture> impeller_context,
43 bool impeller_enabled,
45 : resource_context_(
std::move(resource_context)),
46 resource_context_weak_factory_(
48 ?
std::make_unique<
fml::WeakPtrFactory<GrDirectContext>>(
49 resource_context_.get())
52 std::move(unref_queue_task_runner),
53 unref_queue_drain_delay,
56 is_gpu_disabled_sync_switch_(
std::move(is_gpu_disabled_sync_switch)),
57 impeller_context_(
std::move(impeller_context)),
59 if (!resource_context_ && !impeller_enabled) {
61 FML_DLOG(WARNING) <<
"The IO manager was initialized without a resource "
62 "context. Async texture uploads will be disabled. "
63 "Expect performance degradation.";
71 is_gpu_disabled_sync_switch_->Execute(
76 sk_sp<GrDirectContext> resource_context) {
80 if (!resource_context_) {
86 sk_sp<GrDirectContext> resource_context) {
87 resource_context_ = std::move(resource_context);
88 resource_context_weak_factory_ =
90 ? std::make_unique<fml::WeakPtrFactory<GrDirectContext>>(
91 resource_context_.get())
93 unref_queue_->UpdateResourceContext(resource_context_);
97 return weak_factory_.GetWeakPtr();
102 return resource_context_weak_factory_
103 ? resource_context_weak_factory_->GetWeakPtr()
114 return weak_factory_.GetWeakPtr();
118std::shared_ptr<const fml::SyncSwitch>
120 return is_gpu_disabled_sync_switch_;
125 return impeller_context_->GetContext();
fml::WeakPtr< ShellIOManager > GetWeakPtr()
static sk_sp< GrDirectContext > CreateCompatibleResourceLoadingContext(GrBackendApi backend, const sk_sp< const GrGLInterface > &gl_interface)
fml::RefPtr< flutter::SkiaUnrefQueue > GetSkiaUnrefQueue() const override
void UpdateResourceContext(sk_sp< GrDirectContext > resource_context)
~ShellIOManager() override
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))
std::shared_ptr< const fml::SyncSwitch > GetIsGpuDisabledSyncSwitch() override
void NotifyResourceContextAvailable(sk_sp< GrDirectContext > resource_context)
std::shared_ptr< impeller::Context > GetImpellerContext() const override
Retrieve the impeller::Context.
fml::WeakPtr< IOManager > GetWeakIOManager() const override
fml::WeakPtr< GrDirectContext > GetResourceContext() const override
#define FML_DLOG(severity)
GrContextOptions MakeDefaultContextOptions(ContextType type, std::optional< GrBackendApi > api)
Initializes GrContextOptions with values suitable for Flutter. The options can be further tweaked bef...
Represents the 2 code paths available when calling |SyncSwitchExecute|.