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
gpu / command_buffer / service / shared_image / dawn_ozone_image_representation.h [blame]
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_DAWN_OZONE_IMAGE_REPRESENTATION_H_
#define GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_DAWN_OZONE_IMAGE_REPRESENTATION_H_
#include <dawn/dawn_proc_table.h>
#include <dawn/webgpu.h>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "gpu/command_buffer/service/shared_image/ozone_image_backing.h"
#include "gpu/command_buffer/service/shared_image/shared_image_backing.h"
#include "gpu/command_buffer/service/shared_image/shared_image_manager.h"
#include "gpu/command_buffer/service/shared_image/shared_image_representation.h"
#include "ui/gfx/native_pixmap.h"
namespace gpu {
// SharedImageRepresentation of a Ozone-backed SharedImage to be used by Dawn.
// On access, the pixmap backing the SharedImage is imported into Dawn for
// rendering.
class DawnOzoneImageRepresentation : public DawnImageRepresentation {
public:
DawnOzoneImageRepresentation(SharedImageManager* manager,
SharedImageBacking* backing,
MemoryTypeTracker* tracker,
wgpu::Device device,
wgpu::TextureFormat format,
std::vector<wgpu::TextureFormat> view_formats,
scoped_refptr<gfx::NativePixmap> pixmap);
DawnOzoneImageRepresentation(const DawnOzoneImageRepresentation&) = delete;
DawnOzoneImageRepresentation& operator=(const DawnOzoneImageRepresentation&) =
delete;
~DawnOzoneImageRepresentation() override;
wgpu::Texture BeginAccess(wgpu::TextureUsage usage,
wgpu::TextureUsage internal_usage) override;
void EndAccess() override;
private:
// TODO(andrescj): move other shared image representations into
// OzoneImageBacking.
OzoneImageBacking* ozone_backing() {
return static_cast<OzoneImageBacking*>(backing());
}
const wgpu::Device device_;
const wgpu::TextureFormat format_;
std::vector<wgpu::TextureFormat> view_formats_;
scoped_refptr<gfx::NativePixmap> pixmap_;
wgpu::Texture texture_;
bool is_readonly_ = false;
};
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_DAWN_OZONE_IMAGE_REPRESENTATION_H_