Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
vulkan_surface_producer.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_PLATFORM_FUCHSIA_FLUTTER_VULKAN_SURFACE_PRODUCER_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_VULKAN_SURFACE_PRODUCER_H_
7
8#include <lib/async/cpp/time.h>
9#include <lib/async/default.h>
10
12#include "flutter/fml/macros.h"
20#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
21
22namespace flutter_runner {
23
26 public:
27 explicit VulkanSurfaceProducer();
28 ~VulkanSurfaceProducer() override;
29
30 bool IsValid() const { return valid_; }
31
32 // |SurfaceProducer|
33 GrDirectContext* gr_context() const override { return context_.get(); }
34
35 // |SurfaceProducer|
36 std::unique_ptr<SurfaceProducerSurface> ProduceOffscreenSurface(
37 const SkISize& size) override;
38
39 // |SurfaceProducer|
40 std::unique_ptr<SurfaceProducerSurface> ProduceSurface(
41 const SkISize& size) override;
42
43 // |SurfaceProducer|
44 void SubmitSurfaces(
45 std::vector<std::unique_ptr<SurfaceProducerSurface>> surfaces) override;
46
47 private:
48 // VulkanProvider
49 const vulkan::VulkanProcTable& vk() override { return *vk_.get(); }
50 const vulkan::VulkanHandle<VkDevice>& vk_device() override {
51 return logical_device_->GetHandle();
52 }
53
54 bool Initialize();
55
56 void SubmitSurface(std::unique_ptr<SurfaceProducerSurface> surface);
57 bool TransitionSurfacesToExternal(
58 const std::vector<std::unique_ptr<SurfaceProducerSurface>>& surfaces);
59
60 // Keep track of the last time we produced a surface. This is used to
61 // determine whether it is safe to shrink |surface_pool_| or not.
62 zx::time last_produce_time_ = async::Now(async_get_default_dispatcher());
63
64 // Disallow copy and assignment.
66 VulkanSurfaceProducer& operator=(const VulkanSurfaceProducer&) = delete;
67
68 // Note: the order here is very important. The proctable must be destroyed
69 // last because it contains the function pointers for VkDestroyDevice and
70 // VkDestroyInstance.
72 std::unique_ptr<vulkan::VulkanApplication> application_;
73 std::unique_ptr<vulkan::VulkanDevice> logical_device_;
74 sk_sp<GrDirectContext> context_;
75 std::unique_ptr<VulkanSurfacePool> surface_pool_;
76 sk_sp<skgpu::VulkanMemoryAllocator> memory_allocator_;
77 bool valid_ = false;
78
79 // WeakPtrFactory must be the last member.
81};
82
83} // namespace flutter_runner
84
85#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_VULKAN_SURFACE_PRODUCER_H_
std::unique_ptr< SurfaceProducerSurface > ProduceOffscreenSurface(const SkISize &size) override
void SubmitSurfaces(std::vector< std::unique_ptr< SurfaceProducerSurface > > surfaces) override
GrDirectContext * gr_context() const override
std::unique_ptr< SurfaceProducerSurface > ProduceSurface(const SkISize &size) override
T * get() const
Definition ref_ptr.h:117