1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// Copyright 2014 The Chromium 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 UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACE_FACTORY_H_
#define UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACE_FACTORY_H_
#include <stdint.h>
#include <map>
#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/threading/thread_checker.h"
#include "gpu/vulkan/buildflags.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/ozone/common/gl_ozone_egl.h"
#include "ui/ozone/public/surface_factory_ozone.h"
namespace ui {
class DrmThreadProxy;
class GbmSurfaceless;
class GbmOverlaySurface;
class GbmSurfaceFactory : public SurfaceFactoryOzone {
public:
explicit GbmSurfaceFactory(DrmThreadProxy* drm_thread_proxy);
~GbmSurfaceFactory() override;
void RegisterSurface(gfx::AcceleratedWidget widget, GbmSurfaceless* surface);
void UnregisterSurface(gfx::AcceleratedWidget widget);
GbmSurfaceless* GetSurface(gfx::AcceleratedWidget widget) const;
// SurfaceFactoryOzone:
std::vector<gl::GLImplementation> GetAllowedGLImplementations() override;
GLOzone* GetGLOzone(gl::GLImplementation implementation) override;
#if BUILDFLAG(ENABLE_VULKAN)
std::unique_ptr<gpu::VulkanImplementation> CreateVulkanImplementation(
bool allow_protected_memory,
bool enforce_protected_memory) override;
scoped_refptr<gfx::NativePixmap> CreateNativePixmapForVulkan(
gfx::AcceleratedWidget widget,
gfx::Size size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
VkDevice vk_device,
VkDeviceMemory* vk_device_memory,
VkImage* vk_image) override;
#endif
std::unique_ptr<OverlaySurface> CreateOverlaySurface(
gfx::AcceleratedWidget window) override;
std::unique_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget(
gfx::AcceleratedWidget widget) override;
scoped_refptr<gfx::NativePixmap> CreateNativePixmap(
gfx::AcceleratedWidget widget,
VkDevice vk_device,
gfx::Size size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
base::Optional<gfx::Size> framebuffer_size = base::nullopt) override;
void CreateNativePixmapAsync(gfx::AcceleratedWidget widget,
VkDevice vk_device,
gfx::Size size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
NativePixmapCallback callback) override;
scoped_refptr<gfx::NativePixmap> CreateNativePixmapFromHandle(
gfx::AcceleratedWidget widget,
gfx::Size size,
gfx::BufferFormat format,
gfx::NativePixmapHandle handle) override;
void SetGetProtectedNativePixmapDelegate(
const GetProtectedNativePixmapCallback&
get_protected_native_pixmap_callback) override;
scoped_refptr<gfx::NativePixmap> CreateNativePixmapForProtectedBufferHandle(
gfx::AcceleratedWidget widget,
gfx::Size size,
gfx::BufferFormat format,
gfx::NativePixmapHandle handle) override;
std::vector<gfx::BufferFormat> GetSupportedFormatsForTexturing()
const override;
private:
scoped_refptr<gfx::NativePixmap> CreateNativePixmapFromHandleInternal(
gfx::AcceleratedWidget widget,
gfx::Size size,
gfx::BufferFormat format,
gfx::NativePixmapHandle handle);
std::unique_ptr<GLOzone> egl_implementation_;
base::ThreadChecker thread_checker_;
DrmThreadProxy* const drm_thread_proxy_;
std::map<gfx::AcceleratedWidget, GbmSurfaceless*> widget_to_surface_map_;
GetProtectedNativePixmapCallback get_protected_native_pixmap_callback_;
base::WeakPtrFactory<GbmSurfaceFactory> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(GbmSurfaceFactory);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACE_FACTORY_H_
|