mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 14:05:58 +01:00
parent
776f944619
commit
b9937484f4
4 changed files with 64 additions and 26 deletions
|
@ -424,26 +424,54 @@ void CScreencopyProtocolManager::sendFrameDamage(SScreencopyFrame* frame) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScreencopyProtocolManager::copyFrameShm(SScreencopyFrame* frame, timespec* now) {
|
bool CScreencopyProtocolManager::copyFrameShm(SScreencopyFrame* frame, timespec* now) {
|
||||||
// void* data;
|
wlr_texture* sourceTex = wlr_texture_from_buffer(g_pCompositor->m_sWLRRenderer, m_pLastMonitorBackBuffer);
|
||||||
// uint32_t format;
|
if (!sourceTex)
|
||||||
// size_t stride;
|
return false;
|
||||||
// if (!wlr_buffer_begin_data_ptr_access(frame->buffer, WLR_BUFFER_DATA_PTR_ACCESS_WRITE, &data, &format, &stride))
|
|
||||||
// return false;
|
|
||||||
|
|
||||||
// if (!wlr_renderer_begin_with_buffer(g_pCompositor->m_sWLRRenderer, m_pLastMonitorBackBuffer)) {
|
void* data;
|
||||||
// Debug::log(ERR, "[sc] shm: Client requested a copy to a buffer that failed to pass wlr_renderer_begin_with_buffer");
|
uint32_t format;
|
||||||
// wlr_buffer_end_data_ptr_access(frame->buffer);
|
size_t stride;
|
||||||
// return false;
|
if (!wlr_buffer_begin_data_ptr_access(frame->buffer, WLR_BUFFER_DATA_PTR_ACCESS_WRITE, &data, &format, &stride)) {
|
||||||
// }
|
wlr_texture_destroy(sourceTex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// bool success = wlr_renderer_read_pixels(g_pCompositor->m_sWLRRenderer, format, stride, frame->box.width, frame->box.height, frame->box.x, frame->box.y, 0, 0, data);
|
CRegion fakeDamage = {0, 0, INT16_MAX, INT16_MAX};
|
||||||
// wlr_renderer_end(g_pCompositor->m_sWLRRenderer);
|
|
||||||
// wlr_buffer_end_data_ptr_access(frame->buffer);
|
|
||||||
|
|
||||||
// return success;
|
g_pHyprRenderer->makeEGLCurrent();
|
||||||
|
|
||||||
return false; // TODO: maybe fix this with the new rendering pipeline?
|
CFramebuffer fb;
|
||||||
// though who tf isnt using dmabuf?
|
fb.alloc(frame->box.w, frame->box.h); // 8bit only
|
||||||
|
|
||||||
|
if (!g_pHyprRenderer->beginRender(frame->pMonitor, fakeDamage, RENDER_MODE_FULL_FAKE, nullptr, &fb)) {
|
||||||
|
wlr_texture_destroy(sourceTex);
|
||||||
|
wlr_buffer_end_data_ptr_access(frame->buffer);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CBox monbox = CBox{0, 0, frame->pMonitor->vecPixelSize.x, frame->pMonitor->vecPixelSize.y}.translate({-frame->box.x, -frame->box.y});
|
||||||
|
g_pHyprOpenGL->setMonitorTransformEnabled(false);
|
||||||
|
g_pHyprOpenGL->renderTexture(sourceTex, &monbox, 1);
|
||||||
|
g_pHyprOpenGL->setMonitorTransformEnabled(true);
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, fb.m_iFb);
|
||||||
|
|
||||||
|
const auto PFORMAT = gles2FromDRM(format);
|
||||||
|
if (!PFORMAT) {
|
||||||
|
Debug::log(ERR, "[sc] Cannot read pixels, unsupported format {:x}", (uintptr_t)PFORMAT);
|
||||||
|
wlr_texture_destroy(sourceTex);
|
||||||
|
wlr_buffer_end_data_ptr_access(frame->buffer);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
glReadPixels(0, 0, frame->box.w, frame->box.h, PFORMAT->gl_format, PFORMAT->gl_type, data);
|
||||||
|
|
||||||
|
g_pHyprRenderer->endRender();
|
||||||
|
|
||||||
|
wlr_buffer_end_data_ptr_access(frame->buffer);
|
||||||
|
wlr_texture_destroy(sourceTex);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScreencopyProtocolManager::copyFrameDmabuf(SScreencopyFrame* frame) {
|
bool CScreencopyProtocolManager::copyFrameDmabuf(SScreencopyFrame* frame) {
|
||||||
|
|
|
@ -363,7 +363,12 @@ bool CToplevelExportProtocolManager::copyFrameShm(SScreencopyFrame* frame, times
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(frame->pWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(frame->pWindow->m_iMonitorID);
|
||||||
CRegion fakeDamage{0, 0, PMONITOR->vecPixelSize.x * 10, PMONITOR->vecPixelSize.y * 10};
|
CRegion fakeDamage{0, 0, PMONITOR->vecPixelSize.x * 10, PMONITOR->vecPixelSize.y * 10};
|
||||||
|
|
||||||
if (!g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_FULL_FAKE)) {
|
g_pHyprRenderer->makeEGLCurrent();
|
||||||
|
|
||||||
|
CFramebuffer outFB;
|
||||||
|
outFB.alloc(PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y);
|
||||||
|
|
||||||
|
if (!g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_FULL_FAKE, nullptr, &outFB)) {
|
||||||
wlr_buffer_end_data_ptr_access(frame->buffer);
|
wlr_buffer_end_data_ptr_access(frame->buffer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2312,7 +2312,7 @@ bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode
|
||||||
if (!m_pCurrentWlrBuffer)
|
if (!m_pCurrentWlrBuffer)
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
m_pCurrentWlrBuffer = buffer;
|
m_pCurrentWlrBuffer = wlr_buffer_lock(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -2331,13 +2331,17 @@ bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode
|
||||||
void CHyprRenderer::endRender() {
|
void CHyprRenderer::endRender() {
|
||||||
const auto PMONITOR = g_pHyprOpenGL->m_RenderData.pMonitor;
|
const auto PMONITOR = g_pHyprOpenGL->m_RenderData.pMonitor;
|
||||||
|
|
||||||
|
if (m_eRenderMode != RENDER_MODE_TO_BUFFER_READ_ONLY)
|
||||||
g_pHyprOpenGL->end();
|
g_pHyprOpenGL->end();
|
||||||
|
else {
|
||||||
if (m_eRenderMode == RENDER_MODE_FULL_FAKE) {
|
g_pHyprOpenGL->m_RenderData.pMonitor = nullptr;
|
||||||
wlr_output_rollback(PMONITOR->output);
|
g_pHyprOpenGL->m_RenderData.mouseZoomFactor = 1.f;
|
||||||
return;
|
g_pHyprOpenGL->m_RenderData.mouseZoomUseMouse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_eRenderMode == RENDER_MODE_FULL_FAKE)
|
||||||
|
return;
|
||||||
|
|
||||||
if (isNvidia())
|
if (isNvidia())
|
||||||
glFinish();
|
glFinish();
|
||||||
else
|
else
|
||||||
|
|
|
@ -32,7 +32,8 @@ enum eRenderMode
|
||||||
{
|
{
|
||||||
RENDER_MODE_NORMAL = 0,
|
RENDER_MODE_NORMAL = 0,
|
||||||
RENDER_MODE_FULL_FAKE = 1,
|
RENDER_MODE_FULL_FAKE = 1,
|
||||||
RENDER_MODE_TO_BUFFER = 2
|
RENDER_MODE_TO_BUFFER = 2,
|
||||||
|
RENDER_MODE_TO_BUFFER_READ_ONLY = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
class CToplevelExportProtocolManager;
|
class CToplevelExportProtocolManager;
|
||||||
|
|
Loading…
Reference in a new issue