This commit is contained in:
2026-01-17 08:46:11 +01:00
parent 0aea07026d
commit e7a514a713
10 changed files with 1371 additions and 126 deletions

View File

@@ -0,0 +1,51 @@
#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;
};