xref: /aosp_15_r20/external/mesa3d/src/gfxstream/guest/android/GrallocGoldfish.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright 2023 Google LLC
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #pragma once
7 
8 #include "gfxstream/guest/GfxStreamGralloc.h"
9 
10 namespace gfxstream {
11 
12 class GoldfishGralloc : public Gralloc {
13    public:
14     GrallocType getGrallocType() override;
15     uint32_t createColorBuffer(int width, int height, uint32_t glformat) override;
16 
17     int allocate(uint32_t width, uint32_t height, uint32_t format, uint64_t usage,
18                  AHardwareBuffer** outputAhb) override;
19 
20     void acquire(AHardwareBuffer* ahb) override;
21     void release(AHardwareBuffer* ahb) override;
22 
23     int lock(AHardwareBuffer* ahb, uint8_t** ptr) override;
24     int lockPlanes(AHardwareBuffer* ahb, std::vector<LockedPlane>* ahbPlanes) override;
25     int unlock(AHardwareBuffer* ahb) override;
26 
27     uint32_t getHostHandle(native_handle_t const* handle) override;
28     uint32_t getHostHandle(const AHardwareBuffer* handle) override;
29 
30     const native_handle_t* getNativeHandle(const AHardwareBuffer* ahb) override;
31 
32     int getFormat(const native_handle_t* handle) override;
33     int getFormat(const AHardwareBuffer* handle) override;
34 
35     uint32_t getFormatDrmFourcc(const native_handle_t* handle) override;
36     uint32_t getFormatDrmFourcc(const AHardwareBuffer* handle) override;
37 
38     uint32_t getWidth(const AHardwareBuffer* ahb) override;
39     uint32_t getHeight(const AHardwareBuffer* ahb) override;
40 
41     size_t getAllocatedSize(const native_handle_t* handle) override;
42     size_t getAllocatedSize(const AHardwareBuffer* handle) override;
43 
44     int getId(const AHardwareBuffer* ahb, uint64_t* id) override;
45 
46     bool treatBlobAsImage() override;
47 };
48 
49 }  // namespace gfxstream
50