1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include "VirtGpu.h" 20 21 class FuchsiaVirtGpuBlob : public std::enable_shared_from_this<FuchsiaVirtGpuBlob>, 22 public VirtGpuBlob { 23 public: 24 FuchsiaVirtGpuBlob(int64_t deviceHandle, uint32_t blobHandle, uint32_t resourceHandle, 25 uint64_t size); 26 ~FuchsiaVirtGpuBlob(); 27 28 uint32_t getResourceHandle() const override; 29 uint32_t getBlobHandle() const override; 30 int wait() override; 31 32 int exportBlob(struct VirtGpuExternalHandle& handle) override; 33 int transferFromHost(uint32_t offset, uint32_t size) override; 34 int transferToHost(uint32_t offset, uint32_t size) override; 35 36 VirtGpuBlobMappingPtr createMapping(void) override; 37 }; 38 39 class FuchsiaVirtGpuBlobMapping : public VirtGpuBlobMapping { 40 public: 41 FuchsiaVirtGpuBlobMapping(VirtGpuBlobPtr blob, uint8_t* ptr, uint64_t size); 42 ~FuchsiaVirtGpuBlobMapping(void); 43 44 uint8_t* asRawPtr(void) override; 45 }; 46 47 class FuchsiaVirtGpuDevice : public VirtGpuDevice { 48 public: 49 FuchsiaVirtGpuDevice(enum VirtGpuCapset capset); 50 ~FuchsiaVirtGpuDevice(); 51 52 int64_t getDeviceHandle(void) override; 53 54 struct VirtGpuCaps getCaps(void) override; 55 56 VirtGpuBlobPtr createBlob(const struct VirtGpuCreateBlob& blobCreate) override; 57 VirtGpuBlobPtr createVirglBlob(uint32_t width, uint32_t height, uint32_t format) override; 58 VirtGpuBlobPtr importBlob(const struct VirtGpuExternalHandle& handle) override; 59 60 int execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuBlob* blob) override; 61 }; 62