mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-14 18:58:29 +12:00
rework the present system
This commit is contained in:
parent
6bb191212b
commit
d4a1074425
5 changed files with 120 additions and 47 deletions
45
src/Cafe/HW/Latte/Renderer/Metal/MetalLayerHandle.cpp
Normal file
45
src/Cafe/HW/Latte/Renderer/Metal/MetalLayerHandle.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include "Cafe/HW/Latte/Renderer/Metal/MetalLayerHandle.h"
|
||||
#include "Cafe/HW/Latte/Renderer/Metal/MetalLayer.h"
|
||||
|
||||
#include "gui/guiWrapper.h"
|
||||
|
||||
MetalLayerHandle::MetalLayerHandle(MTL::Device* device, const Vector2i& size)
|
||||
{
|
||||
const auto& windowInfo = gui_getWindowInfo().window_main;
|
||||
|
||||
m_layer = (CA::MetalLayer*)CreateMetalLayer(windowInfo.handle, m_layerScaleX, m_layerScaleY);
|
||||
m_layer->setDevice(device);
|
||||
m_layer->setDrawableSize(CGSize{(float)size.x * m_layerScaleX, (float)size.y * m_layerScaleY});
|
||||
}
|
||||
|
||||
MetalLayerHandle::~MetalLayerHandle()
|
||||
{
|
||||
if (m_layer)
|
||||
m_layer->release();
|
||||
}
|
||||
|
||||
void MetalLayerHandle::Resize(const Vector2i& size)
|
||||
{
|
||||
m_layer->setDrawableSize(CGSize{(float)size.x * m_layerScaleX, (float)size.y * m_layerScaleY});
|
||||
}
|
||||
|
||||
bool MetalLayerHandle::AcquireDrawable()
|
||||
{
|
||||
if (m_drawable)
|
||||
return true;
|
||||
|
||||
m_drawable = m_layer->nextDrawable();
|
||||
if (!m_drawable)
|
||||
{
|
||||
debug_printf("failed to acquire next drawable\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MetalLayerHandle::PresentDrawable(MTL::CommandBuffer* commandBuffer)
|
||||
{
|
||||
commandBuffer->presentDrawable(m_drawable);
|
||||
m_drawable = nullptr;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue