189ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian/* 289ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * Copyright (C) 2017 The Android Open Source Project 389ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * 489ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License"); 589ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * you may not use this file except in compliance with the License. 689ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * You may obtain a copy of the License at 789ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * 889ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * http://www.apache.org/licenses/LICENSE-2.0 989ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * 1089ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * Unless required by applicable law or agreed to in writing, software 1189ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS, 1289ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1389ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * See the License for the specific language governing permissions and 1489ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * limitations under the License. 1589ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian */ 1689ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian 1789ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian#ifndef ANDROID_PRIVATE_NATIVE_AHARDWARE_BUFFER_HELPERS_H 1889ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian#define ANDROID_PRIVATE_NATIVE_AHARDWARE_BUFFER_HELPERS_H 1989ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian 2089ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian/* 21a5a719e97cbec30c8968dddf542d86788e1051a4Craig Donner * This file contains utility functions related to AHardwareBuffer, mostly to 22a5a719e97cbec30c8968dddf542d86788e1051a4Craig Donner * convert to/from HAL formats. 2389ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian * 24a5a719e97cbec30c8968dddf542d86788e1051a4Craig Donner * These are PRIVATE methods, so this file can NEVER appear in a public NDK 25a5a719e97cbec30c8968dddf542d86788e1051a4Craig Donner * header. They are used by higher level libraries such as core/jni. 2689ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian */ 2789ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian 2889ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian#include <stdint.h> 2989ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian 3089ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopianstruct AHardwareBuffer; 31619634070f2fd5fa6ca0e035323fb2bb2aeea785Mathias Agopianstruct ANativeWindowBuffer; 3289ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian 3389ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopiannamespace android { 3489ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian 353a11413a2584cf9a51e4315bef27546f602578fbMathias Agopian// whether this AHardwareBuffer format is valid 363a11413a2584cf9a51e4315bef27546f602578fbMathias Agopianbool AHardwareBuffer_isValidPixelFormat(uint32_t ahardwarebuffer_format); 373a11413a2584cf9a51e4315bef27546f602578fbMathias Agopian 383a11413a2584cf9a51e4315bef27546f602578fbMathias Agopian// convert AHardwareBuffer format to HAL format (note: this is a no-op) 3989ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopianuint32_t AHardwareBuffer_convertFromPixelFormat(uint32_t format); 403a11413a2584cf9a51e4315bef27546f602578fbMathias Agopian 413a11413a2584cf9a51e4315bef27546f602578fbMathias Agopian// convert HAL format to AHardwareBuffer format (note: this is a no-op) 4289ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopianuint32_t AHardwareBuffer_convertToPixelFormat(uint32_t format); 433a11413a2584cf9a51e4315bef27546f602578fbMathias Agopian 443a11413a2584cf9a51e4315bef27546f602578fbMathias Agopian// convert AHardwareBuffer usage bits to HAL usage bits (note: this is a no-op) 452c38b56d19f464142e32030b99ac56afd47ab7cdMathias Agopianuint64_t AHardwareBuffer_convertFromGrallocUsageBits(uint64_t usage); 4689ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian 473a11413a2584cf9a51e4315bef27546f602578fbMathias Agopian// convert HAL usage bits to AHardwareBuffer usage bits (note: this is a no-op) 483a11413a2584cf9a51e4315bef27546f602578fbMathias Agopianuint64_t AHardwareBuffer_convertToGrallocUsageBits(uint64_t usage); 493a11413a2584cf9a51e4315bef27546f602578fbMathias Agopian 5089ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopianclass GraphicBuffer; 5189ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopianconst GraphicBuffer* AHardwareBuffer_to_GraphicBuffer(const AHardwareBuffer* buffer); 5289ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias AgopianGraphicBuffer* AHardwareBuffer_to_GraphicBuffer(AHardwareBuffer* buffer); 5389ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian 54619634070f2fd5fa6ca0e035323fb2bb2aeea785Mathias Agopianconst ANativeWindowBuffer* AHardwareBuffer_to_ANativeWindowBuffer(const AHardwareBuffer* buffer); 55619634070f2fd5fa6ca0e035323fb2bb2aeea785Mathias AgopianANativeWindowBuffer* AHardwareBuffer_to_ANativeWindowBuffer(AHardwareBuffer* buffer); 56619634070f2fd5fa6ca0e035323fb2bb2aeea785Mathias Agopian 57619634070f2fd5fa6ca0e035323fb2bb2aeea785Mathias AgopianAHardwareBuffer* AHardwareBuffer_from_GraphicBuffer(GraphicBuffer* buffer); 5889ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian} // namespace android 5989ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian 6089ed4c8cfd8ad64269dfcff9742e16bdd705b926Mathias Agopian#endif // ANDROID_PRIVATE_NATIVE_AHARDWARE_BUFFER_HELPERS_H 61