1 /* 2 * Copyright 2018 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 <android/hardware/graphics/mapper/2.1/IMapper.h> 20 #include <mapper-hal/2.0/MapperHal.h> 21 22 namespace android { 23 namespace hardware { 24 namespace graphics { 25 namespace mapper { 26 namespace V2_1 { 27 namespace hal { 28 29 using V2_0::BufferDescriptor; 30 using V2_0::Error; 31 32 class MapperHal : public V2_0::hal::MapperHal { 33 public: 34 virtual ~MapperHal() = default; 35 36 // superceded by createDescriptor_2_1 createDescriptor(const V2_0::IMapper::BufferDescriptorInfo & descriptorInfo,BufferDescriptor * outDescriptor)37 Error createDescriptor(const V2_0::IMapper::BufferDescriptorInfo& descriptorInfo, 38 BufferDescriptor* outDescriptor) override { 39 return createDescriptor_2_1( 40 IMapper::BufferDescriptorInfo{ 41 descriptorInfo.width, descriptorInfo.height, descriptorInfo.layerCount, 42 static_cast<common::V1_1::PixelFormat>(descriptorInfo.format), descriptorInfo.usage, 43 }, 44 outDescriptor); 45 } 46 47 // validate the buffer can be safely accessed with the specified 48 // descriptorInfo and stride 49 virtual Error validateBufferSize(const native_handle_t* bufferHandle, 50 const IMapper::BufferDescriptorInfo& descriptorInfo, 51 uint32_t stride) = 0; 52 53 // get the transport size of a buffer handle. It can be smaller than or 54 // equal to the size of the buffer handle. 55 virtual Error getTransportSize(const native_handle_t* bufferHandle, uint32_t* outNumFds, 56 uint32_t* outNumInts) = 0; 57 58 // create a BufferDescriptor 59 virtual Error createDescriptor_2_1(const IMapper::BufferDescriptorInfo& descriptorInfo, 60 BufferDescriptor* outDescriptor) = 0; 61 }; 62 63 } // namespace hal 64 } // namespace V2_1 65 } // namespace mapper 66 } // namespace graphics 67 } // namespace hardware 68 } // namespace android 69