1 /* 2 * Copyright 2016 The Android Open Source Project 3 * * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #pragma once 17 18 #include <mapper-hal/2.1/MapperHal.h> 19 #include <mapper-passthrough/2.0/Gralloc0Hal.h> 20 21 namespace android { 22 namespace hardware { 23 namespace graphics { 24 namespace mapper { 25 namespace V2_1 { 26 namespace passthrough { 27 28 namespace detail { 29 30 using V2_0::BufferDescriptor; 31 using V2_0::Error; 32 33 // Gralloc0HalImpl implements V2_*::hal::MapperHal on top of gralloc0 34 template <typename Hal> 35 class Gralloc0HalImpl : public V2_0::passthrough::detail::Gralloc0HalImpl<Hal> { 36 public: validateBufferSize(const native_handle_t *,const IMapper::BufferDescriptorInfo &,uint32_t)37 Error validateBufferSize(const native_handle_t* /*bufferHandle*/, 38 const IMapper::BufferDescriptorInfo& /*descriptorInfo*/, 39 uint32_t /*stride*/) override { 40 // need a gralloc0 extension to really validate 41 return Error::NONE; 42 } 43 getTransportSize(const native_handle_t * bufferHandle,uint32_t * outNumFds,uint32_t * outNumInts)44 Error getTransportSize(const native_handle_t* bufferHandle, uint32_t* outNumFds, 45 uint32_t* outNumInts) override { 46 // need a gralloc0 extension to get the transport size 47 *outNumFds = bufferHandle->numFds; 48 *outNumInts = bufferHandle->numInts; 49 return Error::NONE; 50 } 51 createDescriptor_2_1(const IMapper::BufferDescriptorInfo & descriptorInfo,BufferDescriptor * outDescriptor)52 Error createDescriptor_2_1(const IMapper::BufferDescriptorInfo& descriptorInfo, 53 BufferDescriptor* outDescriptor) override { 54 return createDescriptor( 55 V2_0::IMapper::BufferDescriptorInfo{ 56 descriptorInfo.width, descriptorInfo.height, descriptorInfo.layerCount, 57 static_cast<common::V1_0::PixelFormat>(descriptorInfo.format), descriptorInfo.usage, 58 }, 59 outDescriptor); 60 } 61 62 private: 63 using BaseType2_0 = V2_0::passthrough::detail::Gralloc0HalImpl<Hal>; 64 using BaseType2_0::createDescriptor; 65 }; 66 67 } // namespace detail 68 69 using Gralloc0Hal = detail::Gralloc0HalImpl<hal::MapperHal>; 70 71 } // namespace passthrough 72 } // namespace V2_1 73 } // namespace mapper 74 } // namespace graphics 75 } // namespace hardware 76 } // namespace android 77