1 // 2 // Copyright 2018 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // android_util.h: Utilities for the using the Android platform 8 9 #ifndef COMMON_ANDROIDUTIL_H_ 10 #define COMMON_ANDROIDUTIL_H_ 11 12 #include <EGL/egl.h> 13 #include <EGL/eglext.h> 14 15 #include <stdint.h> 16 #include <array> 17 18 #include "angle_gl.h" 19 20 struct ANativeWindowBuffer; 21 struct AHardwareBuffer; 22 23 namespace angle 24 { 25 26 namespace android 27 { 28 29 constexpr std::array<GLenum, 3> kSupportedSizedInternalFormats = {GL_RGBA8, GL_RGB8, GL_RGB565}; 30 31 ANativeWindowBuffer *ClientBufferToANativeWindowBuffer(EGLClientBuffer clientBuffer); 32 EGLClientBuffer AHardwareBufferToClientBuffer(const AHardwareBuffer *hardwareBuffer); 33 AHardwareBuffer *ClientBufferToAHardwareBuffer(EGLClientBuffer clientBuffer); 34 35 EGLClientBuffer CreateEGLClientBufferFromAHardwareBuffer(int width, 36 int height, 37 int depth, 38 int androidFormat, 39 int usage); 40 41 void GetANativeWindowBufferProperties(const ANativeWindowBuffer *buffer, 42 int *width, 43 int *height, 44 int *depth, 45 int *pixelFormat); 46 GLenum NativePixelFormatToGLInternalFormat(int pixelFormat); 47 int GLInternalFormatToNativePixelFormat(GLenum internalFormat); 48 49 bool NativePixelFormatIsYUV(int pixelFormat); 50 51 AHardwareBuffer *ANativeWindowBufferToAHardwareBuffer(ANativeWindowBuffer *windowBuffer); 52 53 uint64_t GetAHBUsage(int eglNativeBufferUsage); 54 55 } // namespace android 56 } // namespace angle 57 58 #endif // COMMON_ANDROIDUTIL_H_ 59