52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <android/hardware_buffer.h>
|
|
#include <cstdint>
|
|
|
|
/**
|
|
* Abstract interface for texture backends.
|
|
* Allows swapping between OpenGL and Vulkan implementations at runtime.
|
|
*/
|
|
class ITextureBackend
|
|
{
|
|
public:
|
|
virtual ~ITextureBackend() = default;
|
|
|
|
/**
|
|
* Create texture resources from a hardware buffer.
|
|
* @param buffer The AHardwareBuffer from the Mosis service
|
|
* @return true if creation succeeded
|
|
*/
|
|
virtual bool Create(AHardwareBuffer* buffer) = 0;
|
|
|
|
/**
|
|
* Update the texture (blit from source to destination).
|
|
* Called each frame when a new frame is available.
|
|
*/
|
|
virtual void Update() = 0;
|
|
|
|
/**
|
|
* Destroy all texture resources.
|
|
*/
|
|
virtual void Destroy() = 0;
|
|
|
|
/**
|
|
* Get the native texture pointer for Unity.
|
|
* For OpenGL: GLuint cast to void*
|
|
* For Vulkan: VkImage cast to void*
|
|
*/
|
|
virtual void* GetNativeTexturePtr() = 0;
|
|
|
|
/**
|
|
* Get texture dimensions.
|
|
*/
|
|
virtual int GetWidth() const = 0;
|
|
virtual int GetHeight() const = 0;
|
|
|
|
/**
|
|
* Check if the backend is Vulkan-based.
|
|
* Unity needs this to know how to interpret the native pointer.
|
|
*/
|
|
virtual bool IsVulkan() const = 0;
|
|
};
|