mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
There was a compile error when trying to roll in http://review.skia.org/764970, and this addresses that. While I was here, I noticed some uses of the old-named `GrBackend` enum and updated it to the non-deprecated enum class. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
85 lines
3.0 KiB
C++
85 lines
3.0 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef FLUTTER_SHELL_COMMON_SHELL_IO_MANAGER_H_
|
|
#define FLUTTER_SHELL_COMMON_SHELL_IO_MANAGER_H_
|
|
|
|
#include <memory>
|
|
|
|
#include "flutter/flow/skia_gpu_object.h"
|
|
#include "flutter/fml/macros.h"
|
|
#include "flutter/fml/memory/weak_ptr.h"
|
|
#include "flutter/lib/ui/io_manager.h"
|
|
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
|
#include "third_party/skia/include/gpu/GrTypes.h"
|
|
|
|
struct GrGLInterface;
|
|
|
|
namespace flutter {
|
|
|
|
class ShellIOManager final : public IOManager {
|
|
public:
|
|
// Convenience methods for platforms to create a GrDirectContext used to
|
|
// supply to the IOManager. The platforms may create the context themselves if
|
|
// they so desire.
|
|
static sk_sp<GrDirectContext> CreateCompatibleResourceLoadingContext(
|
|
GrBackendApi backend,
|
|
const sk_sp<const GrGLInterface>& gl_interface);
|
|
|
|
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;
|
|
|
|
// This method should be called when a resource_context first becomes
|
|
// available. It is safe to call multiple times, and will only update
|
|
// the held resource context if it has not already been set.
|
|
void NotifyResourceContextAvailable(sk_sp<GrDirectContext> resource_context);
|
|
|
|
// This method should be called if you want to force the IOManager to
|
|
// update its resource context reference. It should not be called
|
|
// if there are any Dart objects that have a reference to the old
|
|
// resource context, but may be called if the Dart VM is restarted.
|
|
void UpdateResourceContext(sk_sp<GrDirectContext> resource_context);
|
|
|
|
fml::WeakPtr<ShellIOManager> GetWeakPtr();
|
|
|
|
// |IOManager|
|
|
fml::WeakPtr<IOManager> GetWeakIOManager() const override;
|
|
|
|
// |IOManager|
|
|
fml::WeakPtr<GrDirectContext> GetResourceContext() const override;
|
|
|
|
// |IOManager|
|
|
fml::RefPtr<flutter::SkiaUnrefQueue> GetSkiaUnrefQueue() const override;
|
|
|
|
// |IOManager|
|
|
std::shared_ptr<const fml::SyncSwitch> GetIsGpuDisabledSyncSwitch() override;
|
|
|
|
// |IOManager|
|
|
std::shared_ptr<impeller::Context> GetImpellerContext() const override;
|
|
|
|
private:
|
|
// Resource context management.
|
|
sk_sp<GrDirectContext> resource_context_;
|
|
std::unique_ptr<fml::WeakPtrFactory<GrDirectContext>>
|
|
resource_context_weak_factory_;
|
|
// Unref queue management.
|
|
fml::RefPtr<flutter::SkiaUnrefQueue> unref_queue_;
|
|
std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch_;
|
|
std::shared_ptr<impeller::Context> impeller_context_;
|
|
fml::WeakPtrFactory<ShellIOManager> weak_factory_;
|
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(ShellIOManager);
|
|
};
|
|
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_SHELL_COMMON_SHELL_IO_MANAGER_H_
|