1 // 2 // Copyright 2021 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 #ifndef LIBANGLE_RENDERER_VULKAN_ANDROID_AHBFUNCTIONS_H_ 8 #define LIBANGLE_RENDERER_VULKAN_ANDROID_AHBFUNCTIONS_H_ 9 10 #include <android/hardware_buffer.h> 11 12 namespace rx 13 { 14 15 class AHBFunctions 16 { 17 public: 18 AHBFunctions(); 19 ~AHBFunctions(); 20 acquire(AHardwareBuffer * buffer)21 void acquire(AHardwareBuffer *buffer) const { mAcquireFn(buffer); } describe(const AHardwareBuffer * buffer,AHardwareBuffer_Desc * outDesc)22 void describe(const AHardwareBuffer *buffer, AHardwareBuffer_Desc *outDesc) const 23 { 24 mDescribeFn(buffer, outDesc); 25 } release(AHardwareBuffer * buffer)26 void release(AHardwareBuffer *buffer) const { mReleaseFn(buffer); } 27 valid()28 bool valid() const { return mAcquireFn && mDescribeFn && mReleaseFn; } 29 30 private: 31 using PFN_AHARDWAREBUFFER_acquire = void (*)(AHardwareBuffer *buffer); 32 using PFN_AHARDWAREBUFFER_describe = void (*)(const AHardwareBuffer *buffer, 33 AHardwareBuffer_Desc *outDesc); 34 using PFN_AHARDWAREBUFFER_release = void (*)(AHardwareBuffer *buffer); 35 36 PFN_AHARDWAREBUFFER_acquire mAcquireFn = nullptr; 37 PFN_AHARDWAREBUFFER_describe mDescribeFn = nullptr; 38 PFN_AHARDWAREBUFFER_release mReleaseFn = nullptr; 39 }; 40 41 } // namespace rx 42 43 #endif // LIBANGLE_RENDERER_VULKAN_ANDROID_AHBFUNCTIONS_H_ 44