Flutter Engine
The 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
10#include "flutter/flow/skia_gpu_object.h"
11#include "flutter/fml/macros.h"
12#include "flutter/fml/memory/weak_ptr.h"
13#include "flutter/lib/ui/io_manager.h"
16
17struct GrGLInterface;
18
19namespace flutter {
20
21class ShellIOManager final : public IOManager {
22 public:
23 // Convenience methods for platforms to create a GrDirectContext used to
24 // supply to the IOManager. The platforms may create the context themselves if
25 // they so desire.
28 const sk_sp<const GrGLInterface>& gl_interface);
29
31 sk_sp<GrDirectContext> resource_context,
32 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch,
33 fml::RefPtr<fml::TaskRunner> unref_queue_task_runner,
34 std::shared_ptr<impeller::Context> impeller_context,
35 fml::TimeDelta unref_queue_drain_delay =
37
38 ~ShellIOManager() override;
39
40 // This method should be called when a resource_context first becomes
41 // available. It is safe to call multiple times, and will only update
42 // the held resource context if it has not already been set.
44
45 // This method should be called if you want to force the IOManager to
46 // update its resource context reference. It should not be called
47 // if there are any Dart objects that have a reference to the old
48 // resource context, but may be called if the Dart VM is restarted.
49 void UpdateResourceContext(sk_sp<GrDirectContext> resource_context);
50
52
53 // |IOManager|
55
56 // |IOManager|
58
59 // |IOManager|
61
62 // |IOManager|
63 std::shared_ptr<const fml::SyncSwitch> GetIsGpuDisabledSyncSwitch() override;
64
65 // |IOManager|
66 std::shared_ptr<impeller::Context> GetImpellerContext() const override;
67
68 private:
69 // Resource context management.
70 sk_sp<GrDirectContext> resource_context_;
71 std::unique_ptr<fml::WeakPtrFactory<GrDirectContext>>
72 resource_context_weak_factory_;
73 // Unref queue management.
75 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch_;
76 std::shared_ptr<impeller::Context> impeller_context_;
78
80};
81
82} // namespace flutter
83
84#endif // FLUTTER_SHELL_COMMON_SHELL_IO_MANAGER_H_
const char * backend
GrBackendApi
Definition GrTypes.h:95
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
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