aboutsummaryrefslogtreecommitdiff
path: root/guest/android/GrallocGoldfish.h
blob: 560550ff89bee6063c9c04e0e157c1de4d74bc6b (plain)
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
// Copyright 2023 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expresso or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "gfxstream/guest/Gralloc.h"

namespace gfxstream {

class GoldfishGralloc : public Gralloc {
   public:
    uint32_t createColorBuffer(void* rcEnc, int width, int height, uint32_t glformat) override;

    int allocate(uint32_t width, uint32_t height, uint32_t format, uint64_t usage,
                 AHardwareBuffer** outputAhb) override;

    void acquire(AHardwareBuffer* ahb) override;
    void release(AHardwareBuffer* ahb) override;

    uint32_t getHostHandle(native_handle_t const* handle) override;
    uint32_t getHostHandle(const AHardwareBuffer* handle) override;

    const native_handle_t* getNativeHandle(const AHardwareBuffer* ahb) override;

    int getFormat(const native_handle_t* handle) override;
    int getFormat(const AHardwareBuffer* handle) override;

    size_t getAllocatedSize(const native_handle_t* handle) override;
    size_t getAllocatedSize(const AHardwareBuffer* handle) override;

    int getId(const AHardwareBuffer* ahb, uint64_t* id) override;

    bool treatBlobAsImage() override;
};

}  // namespace gfxstream