Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (C) 2017 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 #ifndef ANDROID_PRIVATE_NATIVE_AHARDWARE_BUFFER_HELPERS_H
     18 #define ANDROID_PRIVATE_NATIVE_AHARDWARE_BUFFER_HELPERS_H
     19 
     20 /*
     21  * This file contains utility functions related to AHardwareBuffer, mostly to
     22  * convert to/from HAL formats.
     23  *
     24  * These are PRIVATE methods, so this file can NEVER appear in a public NDK
     25  * header. They are used by higher level libraries such as core/jni.
     26  */
     27 
     28 #include <stdint.h>
     29 
     30 struct AHardwareBuffer;
     31 struct ANativeWindowBuffer;
     32 
     33 namespace android {
     34 
     35 // whether this AHardwareBuffer format is valid
     36 bool AHardwareBuffer_isValidPixelFormat(uint32_t ahardwarebuffer_format);
     37 
     38 // convert AHardwareBuffer format to HAL format (note: this is a no-op)
     39 uint32_t AHardwareBuffer_convertFromPixelFormat(uint32_t format);
     40 
     41 // convert HAL format to AHardwareBuffer format (note: this is a no-op)
     42 uint32_t AHardwareBuffer_convertToPixelFormat(uint32_t format);
     43 
     44 // convert AHardwareBuffer usage bits to HAL usage bits (note: this is a no-op)
     45 uint64_t AHardwareBuffer_convertFromGrallocUsageBits(uint64_t usage);
     46 
     47 // convert HAL usage bits to AHardwareBuffer usage bits  (note: this is a no-op)
     48 uint64_t AHardwareBuffer_convertToGrallocUsageBits(uint64_t usage);
     49 
     50 class GraphicBuffer;
     51 const GraphicBuffer* AHardwareBuffer_to_GraphicBuffer(const AHardwareBuffer* buffer);
     52 GraphicBuffer* AHardwareBuffer_to_GraphicBuffer(AHardwareBuffer* buffer);
     53 
     54 const ANativeWindowBuffer* AHardwareBuffer_to_ANativeWindowBuffer(const AHardwareBuffer* buffer);
     55 ANativeWindowBuffer* AHardwareBuffer_to_ANativeWindowBuffer(AHardwareBuffer* buffer);
     56 
     57 AHardwareBuffer* AHardwareBuffer_from_GraphicBuffer(GraphicBuffer* buffer);
     58 } // namespace android
     59 
     60 #endif // ANDROID_PRIVATE_NATIVE_AHARDWARE_BUFFER_HELPERS_H
     61