Flutter Engine
 
Loading...
Searching...
No Matches
shell_io_manager.h
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#ifndef FLUTTER_SHELL_COMMON_SHELL_IO_MANAGER_H_
6#define FLUTTER_SHELL_COMMON_SHELL_IO_MANAGER_H_
7
8#include <memory>
9
11#include "flutter/fml/macros.h"
15#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
16#include "third_party/skia/include/gpu/ganesh/GrTypes.h"
17
18struct GrGLInterface;
19
20namespace flutter {
21
22class ShellIOManager final : public IOManager {
23 public:
24 // Convenience methods for platforms to create a GrDirectContext used to
25 // supply to the IOManager. The platforms may create the context themselves if
26 // they so desire.
27 static sk_sp<GrDirectContext> CreateCompatibleResourceLoadingContext(
28 GrBackendApi backend,
29 const sk_sp<const GrGLInterface>& gl_interface);
30
32 sk_sp<GrDirectContext> resource_context,
33 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch,
34 fml::RefPtr<fml::TaskRunner> unref_queue_task_runner,
35 std::shared_ptr<impeller::ImpellerContextFuture> impeller_context,
36 bool impeller_enabled,
37 fml::TimeDelta unref_queue_drain_delay =
39
40 ~ShellIOManager() override;
41
42 // This method should be called when a resource_context first becomes
43 // available. It is safe to call multiple times, and will only update
44 // the held resource context if it has not already been set.
45 void NotifyResourceContextAvailable(sk_sp<GrDirectContext> resource_context);
46
47 // This method should be called if you want to force the IOManager to
48 // update its resource context reference. It should not be called
49 // if there are any Dart objects that have a reference to the old
50 // resource context, but may be called if the Dart VM is restarted.
51 void UpdateResourceContext(sk_sp<GrDirectContext> resource_context);
52
54
55 // |IOManager|
57
58 // |IOManager|
60
61 // |IOManager|
63
64 // |IOManager|
65 std::shared_ptr<const fml::SyncSwitch> GetIsGpuDisabledSyncSwitch() override;
66
67 // |IOManager|
68 std::shared_ptr<impeller::Context> GetImpellerContext() const override;
69
70 private:
71 // Resource context management.
72 sk_sp<GrDirectContext> resource_context_;
73 std::unique_ptr<fml::WeakPtrFactory<GrDirectContext>>
74 resource_context_weak_factory_;
75 // Unref queue management.
77 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch_;
78 std::shared_ptr<impeller::ImpellerContextFuture> impeller_context_;
80
82};
83
84} // namespace flutter
85
86#endif // FLUTTER_SHELL_COMMON_SHELL_IO_MANAGER_H_
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)
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
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition time_delta.h:46
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27