Rename GLRenderTarget to GLFramebuffer
GLRenderTarget doesn't provide a generic abstraction for framebuffer objects, so let's call GLRenderTarget what it is - a framebuffer. Renaming the GLRenderTarget class allows us to use the term "render target" which abstracts fbos or shm images without creating confusion.
This commit is contained in:
parent
7358daa92c
commit
992753c24a
45 changed files with 206 additions and 205 deletions
|
@ -111,11 +111,11 @@ QRegion EglGbmLayer::beginFrame()
|
|||
}
|
||||
}
|
||||
|
||||
GLRenderTarget::pushRenderTarget(m_gbmSurface->renderTarget());
|
||||
GLFramebuffer::pushFramebuffer(m_gbmSurface->fbo());
|
||||
if (m_shadowBuffer) {
|
||||
// the blit after rendering will completely overwrite the back buffer anyways
|
||||
repaintRegion = QRegion();
|
||||
GLRenderTarget::pushRenderTarget(m_shadowBuffer->renderTarget());
|
||||
GLFramebuffer::pushFramebuffer(m_shadowBuffer->fbo());
|
||||
}
|
||||
|
||||
return repaintRegion;
|
||||
|
@ -136,11 +136,11 @@ void EglGbmLayer::endFrame(const QRegion &renderedRegion, const QRegion &damaged
|
|||
{
|
||||
Q_UNUSED(renderedRegion)
|
||||
if (m_shadowBuffer) {
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
// TODO handle m_pipeline->pending.bufferTransformation != Rotate0
|
||||
m_shadowBuffer->render(m_pipeline->pending.sourceTransformation);
|
||||
}
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
QSharedPointer<DrmBuffer> buffer;
|
||||
if (m_pipeline->gpu() == m_eglBackend->gpu()) {
|
||||
buffer = m_gbmSurface->swapBuffersForDrm(damagedRegion);
|
||||
|
|
|
@ -27,7 +27,7 @@ GbmSurface::GbmSurface(DrmGpu *gpu, const QSize &size, uint32_t format, uint32_t
|
|||
, m_eglBackend(static_cast<EglGbmBackend *>(gpu->platform()->renderBackend()))
|
||||
, m_size(size)
|
||||
, m_format(format)
|
||||
, m_renderTarget(new GLRenderTarget(0, size))
|
||||
, m_fbo(new GLFramebuffer(0, size))
|
||||
{
|
||||
if (!m_surface) {
|
||||
qCCritical(KWIN_DRM) << "Could not create gbm surface!" << strerror(errno);
|
||||
|
@ -45,7 +45,7 @@ GbmSurface::GbmSurface(DrmGpu *gpu, const QSize &size, uint32_t format, QVector<
|
|||
, m_size(size)
|
||||
, m_format(format)
|
||||
, m_modifiers(modifiers)
|
||||
, m_renderTarget(new GLRenderTarget(0, size))
|
||||
, m_fbo(new GLFramebuffer(0, size))
|
||||
{
|
||||
if (!m_surface) {
|
||||
qCCritical(KWIN_DRM) << "Could not create gbm surface!" << strerror(errno);
|
||||
|
@ -144,9 +144,9 @@ QSharedPointer<DrmGbmBuffer> GbmSurface::currentDrmBuffer() const
|
|||
return m_currentDrmBuffer;
|
||||
}
|
||||
|
||||
GLRenderTarget *GbmSurface::renderTarget() const
|
||||
GLFramebuffer *GbmSurface::fbo() const
|
||||
{
|
||||
return m_renderTarget.data();
|
||||
return m_fbo.data();
|
||||
}
|
||||
|
||||
EGLSurface GbmSurface::eglSurface() const
|
||||
|
|
|
@ -23,7 +23,7 @@ struct gbm_surface;
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
class GLRenderTarget;
|
||||
class GLFramebuffer;
|
||||
class EglGbmBackend;
|
||||
|
||||
class GbmSurface
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
QSharedPointer<GbmBuffer> currentBuffer() const;
|
||||
QSharedPointer<DrmGbmBuffer> currentDrmBuffer() const;
|
||||
GLRenderTarget *renderTarget() const;
|
||||
GLFramebuffer *fbo() const;
|
||||
|
||||
EGLSurface eglSurface() const;
|
||||
QSize size() const;
|
||||
|
@ -64,7 +64,7 @@ private:
|
|||
QSharedPointer<GbmBuffer> m_currentBuffer;
|
||||
QSharedPointer<DrmGbmBuffer> m_currentDrmBuffer;
|
||||
QVector<GbmBuffer *> m_lockedBuffers;
|
||||
QScopedPointer<GLRenderTarget> m_renderTarget;
|
||||
QScopedPointer<GLFramebuffer> m_fbo;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ ShadowBuffer::ShadowBuffer(const QSize &size, const GbmFormat &format)
|
|||
m_texture->setFilter(GL_NEAREST);
|
||||
m_texture->setYInverted(true);
|
||||
|
||||
m_renderTarget.reset(new GLRenderTarget(m_texture.data()));
|
||||
if (!m_renderTarget->valid()) {
|
||||
m_fbo.reset(new GLFramebuffer(m_texture.data()));
|
||||
if (!m_fbo->valid()) {
|
||||
qCCritical(KWIN_DRM) << "Error: framebuffer not complete!";
|
||||
return;
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ void ShadowBuffer::render(DrmPlane::Transformations transform)
|
|||
ShaderManager::instance()->popShader();
|
||||
}
|
||||
|
||||
GLRenderTarget *ShadowBuffer::renderTarget() const
|
||||
GLFramebuffer *ShadowBuffer::fbo() const
|
||||
{
|
||||
return m_renderTarget.data();
|
||||
return m_fbo.data();
|
||||
}
|
||||
|
||||
QSharedPointer<GLTexture> ShadowBuffer::texture() const
|
||||
|
@ -98,7 +98,7 @@ QSharedPointer<GLTexture> ShadowBuffer::texture() const
|
|||
|
||||
bool ShadowBuffer::isComplete() const
|
||||
{
|
||||
return m_renderTarget->valid() && m_vbo;
|
||||
return m_fbo->valid() && m_vbo;
|
||||
}
|
||||
|
||||
uint32_t ShadowBuffer::drmFormat() const
|
||||
|
|
|
@ -26,14 +26,14 @@ public:
|
|||
bool isComplete() const;
|
||||
void render(DrmPlane::Transformations transform);
|
||||
|
||||
GLRenderTarget *renderTarget() const;
|
||||
GLFramebuffer *fbo() const;
|
||||
QSharedPointer<GLTexture> texture() const;
|
||||
uint32_t drmFormat() const;
|
||||
|
||||
private:
|
||||
GLint internalFormat(const GbmFormat &format) const;
|
||||
QSharedPointer<GLTexture> m_texture;
|
||||
QScopedPointer<GLRenderTarget> m_renderTarget;
|
||||
QScopedPointer<GLFramebuffer> m_fbo;
|
||||
QScopedPointer<GLVertexBuffer> m_vbo;
|
||||
const QSize m_size;
|
||||
const uint32_t m_drmFormat;
|
||||
|
|
|
@ -78,13 +78,13 @@ QRegion VirtualEglGbmLayer::beginFrame()
|
|||
if (!m_gbmSurface->makeContextCurrent()) {
|
||||
return QRegion();
|
||||
}
|
||||
GLRenderTarget::pushRenderTarget(m_gbmSurface->renderTarget());
|
||||
GLFramebuffer::pushFramebuffer(m_gbmSurface->fbo());
|
||||
return m_gbmSurface->repaintRegion();
|
||||
}
|
||||
|
||||
void VirtualEglGbmLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion)
|
||||
{
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
const auto buffer = m_gbmSurface->swapBuffers(damagedRegion.intersected(m_output->geometry()));
|
||||
if (buffer) {
|
||||
m_currentBuffer = buffer;
|
||||
|
|
|
@ -57,8 +57,8 @@ EglGbmBackend::EglGbmBackend(VirtualBackend *b)
|
|||
|
||||
EglGbmBackend::~EglGbmBackend()
|
||||
{
|
||||
while (GLRenderTarget::currentRenderTarget()) {
|
||||
GLRenderTarget::popRenderTarget();
|
||||
while (GLFramebuffer::currentFramebuffer()) {
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
delete m_fbo;
|
||||
delete m_backBuffer;
|
||||
|
@ -102,13 +102,13 @@ void EglGbmBackend::init()
|
|||
initKWinGL();
|
||||
|
||||
m_backBuffer = new GLTexture(GL_RGB8, screens()->size().width(), screens()->size().height());
|
||||
m_fbo = new GLRenderTarget(m_backBuffer);
|
||||
m_fbo = new GLFramebuffer(m_backBuffer);
|
||||
if (!m_fbo->valid()) {
|
||||
setFailed("Could not create framebuffer object");
|
||||
return;
|
||||
}
|
||||
GLRenderTarget::pushRenderTarget(m_fbo);
|
||||
if (!GLRenderTarget::currentRenderTarget()) {
|
||||
GLFramebuffer::pushFramebuffer(m_fbo);
|
||||
if (!GLFramebuffer::currentFramebuffer()) {
|
||||
setFailed("Failed to bind framebuffer object");
|
||||
return;
|
||||
}
|
||||
|
@ -177,8 +177,8 @@ SurfaceTexture *EglGbmBackend::createSurfaceTextureWayland(SurfacePixmapWayland
|
|||
|
||||
QRegion EglGbmBackend::beginFrame()
|
||||
{
|
||||
if (!GLRenderTarget::currentRenderTarget()) {
|
||||
GLRenderTarget::pushRenderTarget(m_fbo);
|
||||
if (!GLFramebuffer::currentFramebuffer()) {
|
||||
GLFramebuffer::pushFramebuffer(m_fbo);
|
||||
}
|
||||
return infiniteRegion();
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ void EglGbmBackend::present(AbstractOutput *output)
|
|||
convertFromGLImage(img, m_backBuffer->width(), m_backBuffer->height());
|
||||
img.save(QStringLiteral("%1/%2.png").arg(m_backend->saveFrames()).arg(QString::number(m_frameCounter++)));
|
||||
}
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
|
||||
eglSwapBuffers(eglDisplay(), surface());
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
namespace KWin
|
||||
{
|
||||
class VirtualBackend;
|
||||
class GLFramebuffer;
|
||||
class GLTexture;
|
||||
class GLRenderTarget;
|
||||
class EglGbmBackend;
|
||||
|
||||
class VirtualOutputLayer : public OutputLayer
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
bool initRenderingContext();
|
||||
VirtualBackend *m_backend;
|
||||
GLTexture *m_backBuffer = nullptr;
|
||||
GLRenderTarget *m_fbo = nullptr;
|
||||
GLFramebuffer *m_fbo = nullptr;
|
||||
int m_frameCounter = 0;
|
||||
QScopedPointer<VirtualOutputLayer> m_layer;
|
||||
};
|
||||
|
|
|
@ -80,7 +80,7 @@ bool EglWaylandOutput::init()
|
|||
return false;
|
||||
}
|
||||
m_overlay = overlay;
|
||||
m_renderTarget.reset(new GLRenderTarget(0, nativeSize));
|
||||
m_fbo.reset(new GLFramebuffer(0, nativeSize));
|
||||
|
||||
EGLSurface eglSurface = EGL_NO_SURFACE;
|
||||
if (m_backend->havePlatformBase()) {
|
||||
|
@ -106,15 +106,15 @@ EglWaylandOutput::~EglWaylandOutput()
|
|||
wl_egl_window_destroy(m_overlay);
|
||||
}
|
||||
|
||||
GLRenderTarget *EglWaylandOutput::renderTarget() const
|
||||
GLFramebuffer *EglWaylandOutput::fbo() const
|
||||
{
|
||||
return m_renderTarget.data();
|
||||
return m_fbo.data();
|
||||
}
|
||||
|
||||
void EglWaylandOutput::updateSize()
|
||||
{
|
||||
const QSize nativeSize = m_waylandOutput->geometry().size() * m_waylandOutput->scale();
|
||||
m_renderTarget.reset(new GLRenderTarget(0, nativeSize));
|
||||
m_fbo.reset(new GLFramebuffer(0, nativeSize));
|
||||
|
||||
wl_egl_window_resize(m_overlay, nativeSize.width(), nativeSize.height(), 0, 0);
|
||||
resetBufferAge();
|
||||
|
@ -146,7 +146,7 @@ QRegion EglWaylandOutput::beginFrame()
|
|||
{
|
||||
eglWaitNative(EGL_CORE_NATIVE_ENGINE);
|
||||
makeContextCurrent();
|
||||
GLRenderTarget::pushRenderTarget(m_renderTarget.get());
|
||||
GLFramebuffer::pushFramebuffer(m_fbo.get());
|
||||
if (m_backend->supportsBufferAge()) {
|
||||
return m_damageJournal.accumulate(m_bufferAge, infiniteRegion());
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ void EglWaylandOutput::endFrame(const QRegion &renderedRegion, const QRegion &da
|
|||
{
|
||||
Q_UNUSED(renderedRegion)
|
||||
m_damageJournal.add(damagedRegion);
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
|
||||
void EglWaylandOutput::aboutToStartPainting(const QRegion &damage)
|
||||
|
@ -358,10 +358,10 @@ bool EglWaylandBackend::initBufferConfigs()
|
|||
QSharedPointer<KWin::GLTexture> EglWaylandBackend::textureForOutput(KWin::AbstractOutput *output) const
|
||||
{
|
||||
QSharedPointer<GLTexture> texture(new GLTexture(GL_RGBA8, output->pixelSize()));
|
||||
GLRenderTarget::pushRenderTarget(m_outputs[output]->renderTarget());
|
||||
GLRenderTarget renderTarget(texture.data());
|
||||
GLFramebuffer::pushFramebuffer(m_outputs[output]->fbo());
|
||||
GLFramebuffer renderTarget(texture.data());
|
||||
renderTarget.blitFromFramebuffer(QRect(0, texture->height(), texture->width(), -texture->height()));
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
return texture;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ struct wl_shm;
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
class GLRenderTarget;
|
||||
class GLFramebuffer;
|
||||
|
||||
namespace Wayland
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
bool init();
|
||||
void updateSize();
|
||||
|
||||
GLRenderTarget *renderTarget() const;
|
||||
GLFramebuffer *fbo() const;
|
||||
bool makeContextCurrent() const;
|
||||
void present();
|
||||
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
EGLSurface m_eglSurface = EGL_NO_SURFACE;
|
||||
int m_bufferAge = 0;
|
||||
DamageJournal m_damageJournal;
|
||||
QScopedPointer<GLRenderTarget> m_renderTarget;
|
||||
QScopedPointer<GLFramebuffer> m_fbo;
|
||||
EglWaylandBackend *const m_backend;
|
||||
|
||||
friend class EglWaylandBackend;
|
||||
|
|
|
@ -105,7 +105,7 @@ void EglBackend::init()
|
|||
return;
|
||||
}
|
||||
|
||||
m_renderTarget.reset(new GLRenderTarget(0, screens()->size()));
|
||||
m_fbo.reset(new GLFramebuffer(0, screens()->size()));
|
||||
|
||||
kwinApp()->platform()->setSceneEglDisplay(shareDisplay);
|
||||
kwinApp()->platform()->setSceneEglGlobalShareContext(shareContext);
|
||||
|
@ -118,7 +118,7 @@ void EglBackend::screenGeometryChanged()
|
|||
|
||||
// The back buffer contents are now undefined
|
||||
m_bufferAge = 0;
|
||||
m_renderTarget.reset(new GLRenderTarget(0, screens()->size()));
|
||||
m_fbo.reset(new GLFramebuffer(0, screens()->size()));
|
||||
}
|
||||
|
||||
QRegion EglBackend::beginFrame()
|
||||
|
@ -133,7 +133,7 @@ QRegion EglBackend::beginFrame()
|
|||
eglWaitNative(EGL_CORE_NATIVE_ENGINE);
|
||||
|
||||
// Push the default framebuffer to the render target stack.
|
||||
GLRenderTarget::pushRenderTarget(m_renderTarget.data());
|
||||
GLFramebuffer::pushFramebuffer(m_fbo.data());
|
||||
return repaint;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ void EglBackend::present(AbstractOutput *output)
|
|||
}
|
||||
|
||||
// Pop the default render target from the render target stack.
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
|
||||
presentSurface(surface(), effectiveRenderedRegion, screens()->geometry());
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ private:
|
|||
X11StandalonePlatform *m_backend;
|
||||
SoftwareVsyncMonitor *m_vsyncMonitor;
|
||||
DamageJournal m_damageJournal;
|
||||
QScopedPointer<GLRenderTarget> m_renderTarget;
|
||||
QScopedPointer<GLFramebuffer> m_fbo;
|
||||
int m_bufferAge = 0;
|
||||
QRegion m_lastRenderedRegion;
|
||||
QScopedPointer<EglLayer> m_layer;
|
||||
|
|
|
@ -230,7 +230,7 @@ void GlxBackend::init()
|
|||
glPlatform->printResults();
|
||||
initGL(&getProcAddress);
|
||||
|
||||
m_renderTarget.reset(new GLRenderTarget(0, screens()->size()));
|
||||
m_fbo.reset(new GLFramebuffer(0, screens()->size()));
|
||||
|
||||
bool supportsSwapEvent = false;
|
||||
|
||||
|
@ -771,7 +771,7 @@ void GlxBackend::screenGeometryChanged()
|
|||
|
||||
// The back buffer contents are now undefined
|
||||
m_bufferAge = 0;
|
||||
m_renderTarget.reset(new GLRenderTarget(0, size));
|
||||
m_fbo.reset(new GLFramebuffer(0, size));
|
||||
}
|
||||
|
||||
SurfaceTexture *GlxBackend::createSurfaceTextureX11(SurfacePixmapX11 *pixmap)
|
||||
|
@ -784,7 +784,7 @@ QRegion GlxBackend::beginFrame()
|
|||
QRegion repaint;
|
||||
makeCurrent();
|
||||
|
||||
GLRenderTarget::pushRenderTarget(m_renderTarget.data());
|
||||
GLFramebuffer::pushFramebuffer(m_fbo.data());
|
||||
if (supportsBufferAge()) {
|
||||
repaint = m_damageJournal.accumulate(m_bufferAge, infiniteRegion());
|
||||
}
|
||||
|
@ -823,7 +823,7 @@ void GlxBackend::present(AbstractOutput *output)
|
|||
effectiveRenderedRegion = displayRegion;
|
||||
}
|
||||
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
|
||||
present(effectiveRenderedRegion);
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ private:
|
|||
QHash<xcb_visualid_t, FBConfigInfo *> m_fbconfigHash;
|
||||
QHash<xcb_visualid_t, int> m_visualDepthHash;
|
||||
std::unique_ptr<SwapEventFilter> m_swapEventFilter;
|
||||
QScopedPointer<GLRenderTarget> m_renderTarget;
|
||||
QScopedPointer<GLFramebuffer> m_fbo;
|
||||
DamageJournal m_damageJournal;
|
||||
QRegion m_lastRenderedRegion;
|
||||
int m_bufferAge;
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace KWin
|
|||
|
||||
EglX11Output::EglX11Output(EglX11Backend *backend, AbstractOutput *output, EGLSurface surface)
|
||||
: m_eglSurface(surface)
|
||||
, m_renderTarget(new GLRenderTarget(0, output->pixelSize()))
|
||||
, m_fbo(new GLFramebuffer(0, output->pixelSize()))
|
||||
, m_output(output)
|
||||
, m_backend(backend)
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ EglX11Output::~EglX11Output()
|
|||
QRegion EglX11Output::beginFrame()
|
||||
{
|
||||
eglMakeCurrent(m_backend->eglDisplay(), m_eglSurface, m_eglSurface, m_backend->context());
|
||||
GLRenderTarget::pushRenderTarget(m_renderTarget.data());
|
||||
GLFramebuffer::pushFramebuffer(m_fbo.data());
|
||||
return m_output->rect();
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ void EglX11Output::endFrame(const QRegion &renderedRegion, const QRegion &damage
|
|||
{
|
||||
Q_UNUSED(renderedRegion)
|
||||
m_lastDamage = damagedRegion;
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
|
||||
EGLSurface EglX11Output::surface() const
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
private:
|
||||
EGLSurface m_eglSurface;
|
||||
QScopedPointer<GLRenderTarget> m_renderTarget;
|
||||
QScopedPointer<GLFramebuffer> m_fbo;
|
||||
QRegion m_lastDamage;
|
||||
|
||||
AbstractOutput *const m_output;
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace KWin
|
|||
|
||||
DmaBufTexture::DmaBufTexture(KWin::GLTexture *texture)
|
||||
: m_texture(texture)
|
||||
, m_framebuffer(new KWin::GLRenderTarget(texture))
|
||||
, m_framebuffer(new KWin::GLFramebuffer(texture))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ KWin::GLTexture *DmaBufTexture::texture() const
|
|||
return m_texture.data();
|
||||
}
|
||||
|
||||
KWin::GLRenderTarget *DmaBufTexture::framebuffer() const
|
||||
KWin::GLFramebuffer *DmaBufTexture::framebuffer() const
|
||||
{
|
||||
return m_framebuffer.data();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
class GLRenderTarget;
|
||||
class GLFramebuffer;
|
||||
class GLTexture;
|
||||
|
||||
class KWIN_EXPORT DmaBufTexture
|
||||
|
@ -22,11 +22,11 @@ public:
|
|||
virtual quint32 stride() const = 0;
|
||||
virtual int fd() const = 0;
|
||||
KWin::GLTexture *texture() const;
|
||||
KWin::GLRenderTarget *framebuffer() const;
|
||||
KWin::GLFramebuffer *framebuffer() const;
|
||||
|
||||
protected:
|
||||
QScopedPointer<KWin::GLTexture> m_texture;
|
||||
QScopedPointer<KWin::GLRenderTarget> m_framebuffer;
|
||||
QScopedPointer<KWin::GLFramebuffer> m_framebuffer;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ bool ContrastEffect::enabledByDefault()
|
|||
|
||||
bool ContrastEffect::supported()
|
||||
{
|
||||
bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported();
|
||||
bool supported = effects->isOpenGLCompositing() && GLFramebuffer::supported();
|
||||
|
||||
if (supported) {
|
||||
int maxTexSize;
|
||||
|
|
|
@ -108,7 +108,7 @@ void BlurEffect::slotScreenGeometryChanged()
|
|||
|
||||
bool BlurEffect::renderTargetsValid() const
|
||||
{
|
||||
return !m_renderTargets.isEmpty() && std::find_if(m_renderTargets.cbegin(), m_renderTargets.cend(), [](const GLRenderTarget *target) {
|
||||
return !m_renderTargets.isEmpty() && std::find_if(m_renderTargets.cbegin(), m_renderTargets.cend(), [](const GLFramebuffer *target) {
|
||||
return !target->valid();
|
||||
})
|
||||
== m_renderTargets.cend();
|
||||
|
@ -165,7 +165,7 @@ void BlurEffect::updateTexture()
|
|||
m_renderTextures.constLast()->setFilter(GL_LINEAR);
|
||||
m_renderTextures.constLast()->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||
|
||||
m_renderTargets.append(new GLRenderTarget(m_renderTextures.constLast()));
|
||||
m_renderTargets.append(new GLFramebuffer(m_renderTextures.constLast()));
|
||||
}
|
||||
|
||||
// This last set is used as a temporary helper texture
|
||||
|
@ -173,7 +173,7 @@ void BlurEffect::updateTexture()
|
|||
m_renderTextures.constLast()->setFilter(GL_LINEAR);
|
||||
m_renderTextures.constLast()->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||
|
||||
m_renderTargets.append(new GLRenderTarget(m_renderTextures.constLast()));
|
||||
m_renderTargets.append(new GLFramebuffer(m_renderTextures.constLast()));
|
||||
|
||||
m_renderTargetsValid = renderTargetsValid();
|
||||
|
||||
|
@ -402,7 +402,7 @@ bool BlurEffect::enabledByDefault()
|
|||
|
||||
bool BlurEffect::supported()
|
||||
{
|
||||
bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported() && GLRenderTarget::blitSupported();
|
||||
bool supported = effects->isOpenGLCompositing() && GLFramebuffer::supported() && GLFramebuffer::blitSupported();
|
||||
|
||||
if (supported) {
|
||||
int maxTexSize;
|
||||
|
@ -722,7 +722,7 @@ void BlurEffect::doBlur(const QRegion &shape, const QRect &screen, const float o
|
|||
*/
|
||||
if (isDock) {
|
||||
m_renderTargets.last()->blitFromFramebuffer(effects->mapToRenderTarget(sourceRect), destRect);
|
||||
GLRenderTarget::pushRenderTargets(m_renderTargetStack);
|
||||
GLFramebuffer::pushFramebuffers(m_renderTargetStack);
|
||||
|
||||
if (useSRGB) {
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
|
@ -734,14 +734,14 @@ void BlurEffect::doBlur(const QRegion &shape, const QRect &screen, const float o
|
|||
copyScreenSampleTexture(vbo, blurRectCount, shape.translated(xTranslate, yTranslate), mvp);
|
||||
} else {
|
||||
m_renderTargets.first()->blitFromFramebuffer(effects->mapToRenderTarget(sourceRect), destRect);
|
||||
GLRenderTarget::pushRenderTargets(m_renderTargetStack);
|
||||
GLFramebuffer::pushFramebuffers(m_renderTargetStack);
|
||||
|
||||
if (useSRGB) {
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
|
||||
// Remove the m_renderTargets[0] from the top of the stack that we will not use
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
|
||||
downSampleTexture(vbo, blurRectCount);
|
||||
|
@ -844,7 +844,7 @@ void BlurEffect::downSampleTexture(GLVertexBuffer *vbo, int blurRectCount)
|
|||
m_renderTextures[i - 1]->bind();
|
||||
|
||||
vbo->draw(GL_TRIANGLES, blurRectCount * i, blurRectCount);
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
|
||||
m_shader->unbind();
|
||||
|
@ -868,7 +868,7 @@ void BlurEffect::upSampleTexture(GLVertexBuffer *vbo, int blurRectCount)
|
|||
m_renderTextures[i + 1]->bind();
|
||||
|
||||
vbo->draw(GL_TRIANGLES, blurRectCount * i, blurRectCount);
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
|
||||
m_shader->unbind();
|
||||
|
@ -889,7 +889,7 @@ void BlurEffect::copyScreenSampleTexture(GLVertexBuffer *vbo, int blurRectCount,
|
|||
m_renderTextures.last()->bind();
|
||||
|
||||
vbo->draw(GL_TRIANGLES, 0, blurRectCount);
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
|
||||
m_shader->unbind();
|
||||
}
|
||||
|
|
|
@ -86,9 +86,9 @@ private:
|
|||
|
||||
private:
|
||||
BlurShader *m_shader;
|
||||
QVector<GLRenderTarget *> m_renderTargets;
|
||||
QVector<GLFramebuffer *> m_renderTargets;
|
||||
QVector<GLTexture *> m_renderTextures;
|
||||
QStack<GLRenderTarget *> m_renderTargetStack;
|
||||
QStack<GLFramebuffer *> m_renderTargetStack;
|
||||
|
||||
QScopedPointer<GLTexture> m_noiseTexture;
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ bool LookingGlassEffect::loadData()
|
|||
m_texture->setFilter(GL_LINEAR_MIPMAP_LINEAR);
|
||||
m_texture->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||
|
||||
m_fbo = new GLRenderTarget(m_texture);
|
||||
m_fbo = new GLFramebuffer(m_texture);
|
||||
if (!m_fbo->valid()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ void LookingGlassEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::m
|
|||
if (m_valid && m_enabled) {
|
||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||
// Start rendering to texture
|
||||
GLRenderTarget::pushRenderTarget(m_fbo);
|
||||
GLFramebuffer::pushFramebuffer(m_fbo);
|
||||
}
|
||||
|
||||
effects->prePaintScreen(data, presentTime);
|
||||
|
@ -251,7 +251,7 @@ void LookingGlassEffect::paintScreen(int mask, const QRegion ®ion, ScreenPain
|
|||
effects->paintScreen(mask, region, data);
|
||||
if (m_valid && m_enabled) {
|
||||
// Disable render texture
|
||||
GLRenderTarget *target = GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer *target = GLFramebuffer::popFramebuffer();
|
||||
Q_ASSERT(target == m_fbo);
|
||||
Q_UNUSED(target);
|
||||
m_texture->bind();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
class GLRenderTarget;
|
||||
class GLFramebuffer;
|
||||
class GLShader;
|
||||
class GLTexture;
|
||||
class GLVertexBuffer;
|
||||
|
@ -64,7 +64,7 @@ private:
|
|||
int radius;
|
||||
int initialradius;
|
||||
GLTexture *m_texture;
|
||||
GLRenderTarget *m_fbo;
|
||||
GLFramebuffer *m_fbo;
|
||||
GLVertexBuffer *m_vbo;
|
||||
GLShader *m_shader;
|
||||
std::chrono::milliseconds m_lastPresentTime;
|
||||
|
|
|
@ -67,7 +67,7 @@ MagnifierEffect::~MagnifierEffect()
|
|||
|
||||
bool MagnifierEffect::supported()
|
||||
{
|
||||
return effects->isOpenGLCompositing() && GLRenderTarget::blitSupported();
|
||||
return effects->isOpenGLCompositing() && GLFramebuffer::blitSupported();
|
||||
}
|
||||
|
||||
void MagnifierEffect::reconfigure(ReconfigureFlags)
|
||||
|
@ -208,7 +208,7 @@ void MagnifierEffect::zoomIn()
|
|||
effects->makeOpenGLContextCurrent();
|
||||
m_texture = new GLTexture(GL_RGBA8, magnifier_size.width(), magnifier_size.height());
|
||||
m_texture->setYInverted(false);
|
||||
m_fbo = new GLRenderTarget(m_texture);
|
||||
m_fbo = new GLFramebuffer(m_texture);
|
||||
}
|
||||
effects->addRepaint(magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH));
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ void MagnifierEffect::toggle()
|
|||
effects->makeOpenGLContextCurrent();
|
||||
m_texture = new GLTexture(GL_RGBA8, magnifier_size.width(), magnifier_size.height());
|
||||
m_texture->setYInverted(false);
|
||||
m_fbo = new GLRenderTarget(m_texture);
|
||||
m_fbo = new GLFramebuffer(m_texture);
|
||||
}
|
||||
} else {
|
||||
target_zoom = 1;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
class GLRenderTarget;
|
||||
class GLFramebuffer;
|
||||
class GLTexture;
|
||||
|
||||
class MagnifierEffect
|
||||
|
@ -61,7 +61,7 @@ private:
|
|||
std::chrono::milliseconds m_lastPresentTime;
|
||||
QSize magnifier_size;
|
||||
GLTexture *m_texture;
|
||||
GLRenderTarget *m_fbo;
|
||||
GLFramebuffer *m_fbo;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -75,7 +75,7 @@ static void convertFromGLImage(QImage &img, int w, int h)
|
|||
|
||||
bool ScreenShotEffect::supported()
|
||||
{
|
||||
return effects->isOpenGLCompositing() && GLRenderTarget::supported();
|
||||
return effects->isOpenGLCompositing() && GLFramebuffer::supported();
|
||||
}
|
||||
|
||||
ScreenShotEffect::ScreenShotEffect()
|
||||
|
@ -235,12 +235,12 @@ void ScreenShotEffect::takeScreenShot(ScreenShotWindowData *screenshot)
|
|||
}
|
||||
bool validTarget = true;
|
||||
QScopedPointer<GLTexture> offscreenTexture;
|
||||
QScopedPointer<GLRenderTarget> target;
|
||||
QScopedPointer<GLFramebuffer> target;
|
||||
if (effects->isOpenGLCompositing()) {
|
||||
offscreenTexture.reset(new GLTexture(GL_RGBA8, geometry.size() * devicePixelRatio));
|
||||
offscreenTexture->setFilter(GL_LINEAR);
|
||||
offscreenTexture->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||
target.reset(new GLRenderTarget(offscreenTexture.data()));
|
||||
target.reset(new GLFramebuffer(offscreenTexture.data()));
|
||||
validTarget = target->valid();
|
||||
}
|
||||
if (validTarget) {
|
||||
|
@ -251,7 +251,7 @@ void ScreenShotEffect::takeScreenShot(ScreenShotWindowData *screenshot)
|
|||
int mask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT;
|
||||
QImage img;
|
||||
if (effects->isOpenGLCompositing()) {
|
||||
GLRenderTarget::pushRenderTarget(target.data());
|
||||
GLFramebuffer::pushFramebuffer(target.data());
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
|
@ -267,7 +267,7 @@ void ScreenShotEffect::takeScreenShot(ScreenShotWindowData *screenshot)
|
|||
img.setDevicePixelRatio(devicePixelRatio);
|
||||
glReadnPixels(0, 0, img.width(), img.height(), GL_RGBA, GL_UNSIGNED_BYTE, img.sizeInBytes(),
|
||||
static_cast<GLvoid *>(img.bits()));
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
convertFromGLImage(img, img.width(), img.height());
|
||||
}
|
||||
|
||||
|
@ -354,10 +354,10 @@ QImage ScreenShotEffect::blitScreenshot(const QRect &geometry, qreal devicePixel
|
|||
if (effects->isOpenGLCompositing()) {
|
||||
const QSize nativeSize = geometry.size() * devicePixelRatio;
|
||||
|
||||
if (GLRenderTarget::blitSupported() && !GLPlatform::instance()->isGLES()) {
|
||||
if (GLFramebuffer::blitSupported() && !GLPlatform::instance()->isGLES()) {
|
||||
image = QImage(nativeSize.width(), nativeSize.height(), QImage::Format_ARGB32);
|
||||
GLTexture texture(GL_RGBA8, nativeSize.width(), nativeSize.height());
|
||||
GLRenderTarget target(&texture);
|
||||
GLFramebuffer target(&texture);
|
||||
target.blitFromFramebuffer(effects->mapToRenderTarget(geometry));
|
||||
// copy content from framebuffer into image
|
||||
texture.bind();
|
||||
|
|
|
@ -66,12 +66,12 @@ void ScreenTransformEffect::addScreen(EffectScreen *screen)
|
|||
// Rendering the current scene into a texture
|
||||
const bool c = state.m_texture->create();
|
||||
Q_ASSERT(c);
|
||||
GLRenderTarget renderTarget(state.m_texture.data());
|
||||
GLRenderTarget::pushRenderTarget(&renderTarget);
|
||||
GLFramebuffer fbo(state.m_texture.data());
|
||||
GLFramebuffer::pushFramebuffer(&fbo);
|
||||
|
||||
effects->renderScreen(screen);
|
||||
state.m_captured = true;
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
class GLRenderTarget;
|
||||
class GLFramebuffer;
|
||||
class GLTexture;
|
||||
|
||||
class ScreenTransformEffect : public Effect
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace KWin
|
|||
struct DeformOffscreenData
|
||||
{
|
||||
QScopedPointer<GLTexture> texture;
|
||||
QScopedPointer<GLRenderTarget> renderTarget;
|
||||
QScopedPointer<GLFramebuffer> fbo;
|
||||
bool isDirty = true;
|
||||
};
|
||||
|
||||
|
@ -101,12 +101,12 @@ GLTexture *DeformEffectPrivate::maybeRender(EffectWindow *window, DeformOffscree
|
|||
offscreenData->texture.reset(new GLTexture(GL_RGBA8, textureSize));
|
||||
offscreenData->texture->setFilter(GL_LINEAR);
|
||||
offscreenData->texture->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||
offscreenData->renderTarget.reset(new GLRenderTarget(offscreenData->texture.data()));
|
||||
offscreenData->fbo.reset(new GLFramebuffer(offscreenData->texture.data()));
|
||||
offscreenData->isDirty = true;
|
||||
}
|
||||
|
||||
if (offscreenData->isDirty) {
|
||||
GLRenderTarget::pushRenderTarget(offscreenData->renderTarget.data());
|
||||
GLFramebuffer::pushFramebuffer(offscreenData->fbo.data());
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
@ -122,7 +122,7 @@ GLTexture *DeformEffectPrivate::maybeRender(EffectWindow *window, DeformOffscree
|
|||
const int mask = Effect::PAINT_WINDOW_TRANSFORMED | Effect::PAINT_WINDOW_TRANSLUCENT;
|
||||
effects->drawWindow(window, mask, infiniteRegion(), data);
|
||||
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
offscreenData->isDirty = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -576,7 +576,7 @@ void GLTexture::clear()
|
|||
{
|
||||
Q_D(GLTexture);
|
||||
Q_ASSERT(!d->m_foreign);
|
||||
if (!GLTexturePrivate::s_fbo && GLRenderTarget::supported() && GLPlatform::instance()->driver() != Driver_Catalyst) { // fail. -> bug #323065
|
||||
if (!GLTexturePrivate::s_fbo && GLFramebuffer::supported() && GLPlatform::instance()->driver() != Driver_Catalyst) { // fail. -> bug #323065
|
||||
glGenFramebuffers(1, &GLTexturePrivate::s_fbo);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <cmath>
|
||||
#include <deque>
|
||||
|
||||
#define DEBUG_GLRENDERTARGET 0
|
||||
#define DEBUG_GLFRAMEBUFFER 0
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
|
@ -152,7 +152,7 @@ void initGL(const std::function<resolveFuncPtr(const char *)> &resolveFunction)
|
|||
initDebugOutput();
|
||||
|
||||
GLTexturePrivate::initStatic();
|
||||
GLRenderTarget::initStatic();
|
||||
GLFramebuffer::initStatic();
|
||||
GLVertexBuffer::initStatic();
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ void cleanupGL()
|
|||
{
|
||||
ShaderManager::cleanup();
|
||||
GLTexturePrivate::cleanup();
|
||||
GLRenderTarget::cleanup();
|
||||
GLFramebuffer::cleanup();
|
||||
GLVertexBuffer::cleanup();
|
||||
GLPlatform::cleanup();
|
||||
|
||||
|
@ -940,12 +940,12 @@ GLShader *ShaderManager::loadShaderFromCode(const QByteArray &vertexSource, cons
|
|||
return shader;
|
||||
}
|
||||
|
||||
/*** GLRenderTarget ***/
|
||||
bool GLRenderTarget::sSupported = false;
|
||||
bool GLRenderTarget::s_blitSupported = false;
|
||||
QStack<GLRenderTarget *> GLRenderTarget::s_renderTargets = QStack<GLRenderTarget *>();
|
||||
/*** GLFramebuffer ***/
|
||||
bool GLFramebuffer::sSupported = false;
|
||||
bool GLFramebuffer::s_blitSupported = false;
|
||||
QStack<GLFramebuffer *> GLFramebuffer::s_fbos = QStack<GLFramebuffer *>();
|
||||
|
||||
void GLRenderTarget::initStatic()
|
||||
void GLFramebuffer::initStatic()
|
||||
{
|
||||
if (GLPlatform::instance()->isGLES()) {
|
||||
sSupported = true;
|
||||
|
@ -957,61 +957,61 @@ void GLRenderTarget::initStatic()
|
|||
}
|
||||
}
|
||||
|
||||
void GLRenderTarget::cleanup()
|
||||
void GLFramebuffer::cleanup()
|
||||
{
|
||||
Q_ASSERT(s_renderTargets.isEmpty());
|
||||
Q_ASSERT(s_fbos.isEmpty());
|
||||
sSupported = false;
|
||||
s_blitSupported = false;
|
||||
}
|
||||
|
||||
bool GLRenderTarget::blitSupported()
|
||||
bool GLFramebuffer::blitSupported()
|
||||
{
|
||||
return s_blitSupported;
|
||||
}
|
||||
|
||||
GLRenderTarget *GLRenderTarget::currentRenderTarget()
|
||||
GLFramebuffer *GLFramebuffer::currentFramebuffer()
|
||||
{
|
||||
return s_renderTargets.isEmpty() ? nullptr : s_renderTargets.top();
|
||||
return s_fbos.isEmpty() ? nullptr : s_fbos.top();
|
||||
}
|
||||
|
||||
void GLRenderTarget::pushRenderTarget(GLRenderTarget *target)
|
||||
void GLFramebuffer::pushFramebuffer(GLFramebuffer *fbo)
|
||||
{
|
||||
target->bind();
|
||||
s_renderTargets.push(target);
|
||||
fbo->bind();
|
||||
s_fbos.push(fbo);
|
||||
}
|
||||
|
||||
void GLRenderTarget::pushRenderTargets(QStack<GLRenderTarget *> targets)
|
||||
void GLFramebuffer::pushFramebuffers(QStack<GLFramebuffer *> fbos)
|
||||
{
|
||||
targets.top()->bind();
|
||||
s_renderTargets.append(targets);
|
||||
fbos.top()->bind();
|
||||
s_fbos.append(fbos);
|
||||
}
|
||||
|
||||
GLRenderTarget *GLRenderTarget::popRenderTarget()
|
||||
GLFramebuffer *GLFramebuffer::popFramebuffer()
|
||||
{
|
||||
GLRenderTarget *ret = s_renderTargets.pop();
|
||||
if (!s_renderTargets.isEmpty()) {
|
||||
s_renderTargets.top()->bind();
|
||||
GLFramebuffer *ret = s_fbos.pop();
|
||||
if (!s_fbos.isEmpty()) {
|
||||
s_fbos.top()->bind();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
GLRenderTarget::GLRenderTarget()
|
||||
GLFramebuffer::GLFramebuffer()
|
||||
{
|
||||
}
|
||||
|
||||
GLRenderTarget::GLRenderTarget(GLTexture *colorAttachment)
|
||||
GLFramebuffer::GLFramebuffer(GLTexture *colorAttachment)
|
||||
: mSize(colorAttachment->size())
|
||||
{
|
||||
// Make sure FBO is supported
|
||||
if (sSupported && !colorAttachment->isNull()) {
|
||||
initFBO(colorAttachment);
|
||||
} else {
|
||||
qCCritical(LIBKWINGLUTILS) << "Render targets aren't supported!";
|
||||
qCCritical(LIBKWINGLUTILS) << "Framebuffer objects aren't supported!";
|
||||
}
|
||||
}
|
||||
|
||||
GLRenderTarget::GLRenderTarget(GLuint handle, const QSize &size)
|
||||
GLFramebuffer::GLFramebuffer(GLuint handle, const QSize &size)
|
||||
: mFramebuffer(handle)
|
||||
, mSize(size)
|
||||
, mValid(true)
|
||||
|
@ -1019,17 +1019,17 @@ GLRenderTarget::GLRenderTarget(GLuint handle, const QSize &size)
|
|||
{
|
||||
}
|
||||
|
||||
GLRenderTarget::~GLRenderTarget()
|
||||
GLFramebuffer::~GLFramebuffer()
|
||||
{
|
||||
if (!mForeign && mValid) {
|
||||
glDeleteFramebuffers(1, &mFramebuffer);
|
||||
}
|
||||
}
|
||||
|
||||
bool GLRenderTarget::bind()
|
||||
bool GLFramebuffer::bind()
|
||||
{
|
||||
if (!valid()) {
|
||||
qCCritical(LIBKWINGLUTILS) << "Can't enable invalid render target!";
|
||||
qCCritical(LIBKWINGLUTILS) << "Can't enable invalid framebuffer object!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1071,22 +1071,22 @@ static QString formatFramebufferStatus(GLenum status)
|
|||
}
|
||||
}
|
||||
|
||||
void GLRenderTarget::initFBO(GLTexture *colorAttachment)
|
||||
void GLFramebuffer::initFBO(GLTexture *colorAttachment)
|
||||
{
|
||||
#if DEBUG_GLRENDERTARGET
|
||||
#if DEBUG_GLFRAMEBUFFER
|
||||
GLenum err = glGetError();
|
||||
if (err != GL_NO_ERROR)
|
||||
qCCritical(LIBKWINGLUTILS) << "Error status when entering GLRenderTarget::initFBO: " << formatGLError(err);
|
||||
qCCritical(LIBKWINGLUTILS) << "Error status when entering GLFramebuffer::initFBO: " << formatGLError(err);
|
||||
#endif
|
||||
|
||||
GLuint prevFbo = 0;
|
||||
if (const GLRenderTarget *current = currentRenderTarget()) {
|
||||
if (const GLFramebuffer *current = currentFramebuffer()) {
|
||||
prevFbo = current->handle();
|
||||
}
|
||||
|
||||
glGenFramebuffers(1, &mFramebuffer);
|
||||
|
||||
#if DEBUG_GLRENDERTARGET
|
||||
#if DEBUG_GLFRAMEBUFFER
|
||||
if ((err = glGetError()) != GL_NO_ERROR) {
|
||||
qCCritical(LIBKWINGLUTILS) << "glGenFramebuffers failed: " << formatGLError(err);
|
||||
return;
|
||||
|
@ -1095,7 +1095,7 @@ void GLRenderTarget::initFBO(GLTexture *colorAttachment)
|
|||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
|
||||
|
||||
#if DEBUG_GLRENDERTARGET
|
||||
#if DEBUG_GLFRAMEBUFFER
|
||||
if ((err = glGetError()) != GL_NO_ERROR) {
|
||||
qCCritical(LIBKWINGLUTILS) << "glBindFramebuffer failed: " << formatGLError(err);
|
||||
glDeleteFramebuffers(1, &mFramebuffer);
|
||||
|
@ -1106,7 +1106,7 @@ void GLRenderTarget::initFBO(GLTexture *colorAttachment)
|
|||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||
colorAttachment->target(), colorAttachment->texture(), 0);
|
||||
|
||||
#if DEBUG_GLRENDERTARGET
|
||||
#if DEBUG_GLFRAMEBUFFER
|
||||
if ((err = glGetError()) != GL_NO_ERROR) {
|
||||
qCCritical(LIBKWINGLUTILS) << "glFramebufferTexture2D failed: " << formatGLError(err);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, prevFbo);
|
||||
|
@ -1133,14 +1133,14 @@ void GLRenderTarget::initFBO(GLTexture *colorAttachment)
|
|||
mValid = true;
|
||||
}
|
||||
|
||||
void GLRenderTarget::blitFromFramebuffer(const QRect &source, const QRect &destination, GLenum filter)
|
||||
void GLFramebuffer::blitFromFramebuffer(const QRect &source, const QRect &destination, GLenum filter)
|
||||
{
|
||||
if (!valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const GLRenderTarget *top = currentRenderTarget();
|
||||
GLRenderTarget::pushRenderTarget(this);
|
||||
const GLFramebuffer *top = currentFramebuffer();
|
||||
GLFramebuffer::pushFramebuffer(this);
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, handle());
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, top->handle());
|
||||
|
@ -1160,7 +1160,7 @@ void GLRenderTarget::blitFromFramebuffer(const QRect &source, const QRect &desti
|
|||
|
||||
glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, GL_COLOR_BUFFER_BIT, filter);
|
||||
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
@ -2032,9 +2032,9 @@ void GLVertexBuffer::draw(const QRegion ®ion, GLenum primitiveMode, int first
|
|||
glDrawElementsBaseVertex(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, nullptr, first);
|
||||
} else {
|
||||
// Clip using scissoring
|
||||
const GLRenderTarget *renderTarget = GLRenderTarget::currentRenderTarget();
|
||||
const GLFramebuffer *current = GLFramebuffer::currentFramebuffer();
|
||||
for (const QRect &r : region) {
|
||||
glScissor(r.x(), renderTarget->size().height() - (r.y() + r.height()), r.width(), r.height());
|
||||
glScissor(r.x(), current->size().height() - (r.y() + r.height()), r.width(), r.height());
|
||||
glDrawElementsBaseVertex(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, nullptr, first);
|
||||
}
|
||||
}
|
||||
|
@ -2045,9 +2045,9 @@ void GLVertexBuffer::draw(const QRegion ®ion, GLenum primitiveMode, int first
|
|||
glDrawArrays(primitiveMode, first, count);
|
||||
} else {
|
||||
// Clip using scissoring
|
||||
const GLRenderTarget *renderTarget = GLRenderTarget::currentRenderTarget();
|
||||
const GLFramebuffer *current = GLFramebuffer::currentFramebuffer();
|
||||
for (const QRect &r : region) {
|
||||
glScissor(r.x(), renderTarget->size().height() - (r.y() + r.height()), r.width(), r.height());
|
||||
glScissor(r.x(), current->size().height() - (r.y() + r.height()), r.width(), r.height());
|
||||
glDrawArrays(primitiveMode, first, count);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,46 +374,46 @@ inline GLShader *ShaderBinder::shader()
|
|||
}
|
||||
|
||||
/**
|
||||
* @short Render target object
|
||||
* @short OpenGL framebuffer object
|
||||
*
|
||||
* Render target object enables you to render onto a texture. This texture can
|
||||
* later be used to e.g. do post-processing of the scene.
|
||||
* Framebuffer object enables you to render onto a texture. This texture can
|
||||
* later be used to e.g. do post-processing of the scene.
|
||||
*
|
||||
* @author Rivo Laks <rivolaks@hot.ee>
|
||||
*/
|
||||
class KWINGLUTILS_EXPORT GLRenderTarget
|
||||
class KWINGLUTILS_EXPORT GLFramebuffer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructs a GLRenderTarget
|
||||
* Constructs a GLFramebuffer
|
||||
* @since 5.13
|
||||
*/
|
||||
explicit GLRenderTarget();
|
||||
explicit GLFramebuffer();
|
||||
|
||||
/**
|
||||
* Constructs a GLRenderTarget. Note that ensuring the color attachment outlives
|
||||
* the render target is the responsibility of the caller.
|
||||
* Constructs a GLFramebuffer. Note that ensuring the color attachment outlives
|
||||
* the framebuffer is the responsibility of the caller.
|
||||
*
|
||||
* @param colorAttachment texture where the scene will be rendered onto
|
||||
*/
|
||||
explicit GLRenderTarget(GLTexture *colorAttachment);
|
||||
explicit GLFramebuffer(GLTexture *colorAttachment);
|
||||
|
||||
/**
|
||||
* Constructs a wrapper for an already created render target object. The GLRenderTarget
|
||||
* Constructs a wrapper for an already created framebuffer object. The GLFramebuffer
|
||||
* does not take the ownership of the framebuffer object handle.
|
||||
*/
|
||||
GLRenderTarget(GLuint handle, const QSize &size);
|
||||
~GLRenderTarget();
|
||||
GLFramebuffer(GLuint handle, const QSize &size);
|
||||
~GLFramebuffer();
|
||||
|
||||
/**
|
||||
* Returns the framebuffer object handle to this render target object.
|
||||
* Returns the framebuffer object handle to this framebuffer object.
|
||||
*/
|
||||
GLuint handle() const
|
||||
{
|
||||
return mFramebuffer;
|
||||
}
|
||||
/**
|
||||
* Returns the size of the color attachment to this render target object.
|
||||
* Returns the size of the color attachment to this framebuffer object.
|
||||
*/
|
||||
QSize size() const
|
||||
{
|
||||
|
@ -431,19 +431,19 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the last bound render target, or @c null if no render target is current.
|
||||
* Returns the last bound framebuffer, or @c null if no framebuffer is current.
|
||||
*/
|
||||
static GLRenderTarget *currentRenderTarget();
|
||||
static GLFramebuffer *currentFramebuffer();
|
||||
|
||||
/**
|
||||
* Pushes the render target stack of the input parameter in reverse order.
|
||||
* @param targets The stack of GLRenderTargets
|
||||
* Pushes the framebuffer stack of the input parameter in reverse order.
|
||||
* @param fbos The stack of GLFramebuffers
|
||||
* @since 5.13
|
||||
*/
|
||||
static void pushRenderTargets(QStack<GLRenderTarget *> targets);
|
||||
static void pushFramebuffers(QStack<GLFramebuffer *> fbos);
|
||||
|
||||
static void pushRenderTarget(GLRenderTarget *target);
|
||||
static GLRenderTarget *popRenderTarget();
|
||||
static void pushFramebuffer(GLFramebuffer *fbo);
|
||||
static GLFramebuffer *popFramebuffer();
|
||||
/**
|
||||
* Whether the GL_EXT_framebuffer_blit extension is supported.
|
||||
* This functionality is not available in OpenGL ES 2.0.
|
||||
|
@ -454,8 +454,8 @@ public:
|
|||
static bool blitSupported();
|
||||
|
||||
/**
|
||||
* Blits from @a source rectangle in the current render target to the @a destination rectangle in
|
||||
* this render target.
|
||||
* Blits from @a source rectangle in the current framebuffer to the @a destination rectangle in
|
||||
* this framebuffer.
|
||||
*
|
||||
* Be aware that framebuffer blitting may not be supported on all hardware. Use blitSupported()
|
||||
* to check whether it is supported.
|
||||
|
@ -478,7 +478,7 @@ private:
|
|||
static void cleanup();
|
||||
static bool sSupported;
|
||||
static bool s_blitSupported;
|
||||
static QStack<GLRenderTarget *> s_renderTargets;
|
||||
static QStack<GLFramebuffer *> s_fbos;
|
||||
|
||||
GLuint mFramebuffer = 0;
|
||||
QSize mSize;
|
||||
|
|
|
@ -371,7 +371,7 @@ void AbstractEglBackend::setSurface(const EGLSurface &surface)
|
|||
QSharedPointer<GLTexture> AbstractEglBackend::textureForOutput(AbstractOutput *requestedOutput) const
|
||||
{
|
||||
QSharedPointer<GLTexture> texture(new GLTexture(GL_RGBA8, requestedOutput->pixelSize()));
|
||||
GLRenderTarget renderTarget(texture.data());
|
||||
GLFramebuffer renderTarget(texture.data());
|
||||
renderTarget.blitFromFramebuffer(QRect(0, texture->height(), texture->width(), -texture->height()));
|
||||
return texture;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ void OutputScreenCastSource::render(QImage *image)
|
|||
}
|
||||
}
|
||||
|
||||
void OutputScreenCastSource::render(GLRenderTarget *target)
|
||||
void OutputScreenCastSource::render(GLFramebuffer *target)
|
||||
{
|
||||
const QSharedPointer<GLTexture> outputTexture = Compositor::self()->scene()->textureForOutput(m_output);
|
||||
if (!outputTexture) {
|
||||
|
@ -56,11 +56,11 @@ void OutputScreenCastSource::render(GLRenderTarget *target)
|
|||
projectionMatrix.ortho(geometry);
|
||||
shaderBinder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix);
|
||||
|
||||
GLRenderTarget::pushRenderTarget(target);
|
||||
GLFramebuffer::pushFramebuffer(target);
|
||||
outputTexture->bind();
|
||||
outputTexture->render(geometry);
|
||||
outputTexture->unbind();
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds OutputScreenCastSource::clock() const
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
bool hasAlphaChannel() const override;
|
||||
QSize textureSize() const override;
|
||||
|
||||
void render(GLRenderTarget *target) override;
|
||||
void render(GLFramebuffer *target) override;
|
||||
void render(QImage *image) override;
|
||||
std::chrono::nanoseconds clock() const override;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ void RegionScreenCastSource::updateOutput(AbstractWaylandOutput *output)
|
|||
return;
|
||||
}
|
||||
|
||||
GLRenderTarget::pushRenderTarget(m_target.data());
|
||||
GLFramebuffer::pushFramebuffer(m_target.data());
|
||||
const QRect geometry({0, 0}, m_target->size());
|
||||
|
||||
ShaderBinder shaderBinder(ShaderTrait::MapTexture);
|
||||
|
@ -64,7 +64,7 @@ void RegionScreenCastSource::updateOutput(AbstractWaylandOutput *output)
|
|||
outputTexture->bind();
|
||||
outputTexture->render(output->geometry());
|
||||
outputTexture->unbind();
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,11 +73,11 @@ std::chrono::nanoseconds RegionScreenCastSource::clock() const
|
|||
return m_last;
|
||||
}
|
||||
|
||||
void RegionScreenCastSource::render(GLRenderTarget *target)
|
||||
void RegionScreenCastSource::render(GLFramebuffer *target)
|
||||
{
|
||||
if (!m_renderedTexture) {
|
||||
m_renderedTexture.reset(new GLTexture(hasAlphaChannel() ? GL_RGBA8 : GL_RGB8, textureSize()));
|
||||
m_target.reset(new GLRenderTarget(m_renderedTexture.data()));
|
||||
m_target.reset(new GLFramebuffer(m_renderedTexture.data()));
|
||||
const auto allOutputs = kwinApp()->platform()->enabledOutputs();
|
||||
for (auto output : allOutputs) {
|
||||
AbstractWaylandOutput *streamOutput = qobject_cast<AbstractWaylandOutput *>(output);
|
||||
|
@ -87,7 +87,7 @@ void RegionScreenCastSource::render(GLRenderTarget *target)
|
|||
}
|
||||
}
|
||||
|
||||
GLRenderTarget::pushRenderTarget(target);
|
||||
GLFramebuffer::pushFramebuffer(target);
|
||||
QRect r(QPoint(), target->size());
|
||||
auto shader = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture);
|
||||
|
||||
|
@ -100,13 +100,13 @@ void RegionScreenCastSource::render(GLRenderTarget *target)
|
|||
m_renderedTexture->unbind();
|
||||
|
||||
ShaderManager::instance()->popShader();
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
|
||||
void RegionScreenCastSource::render(QImage *image)
|
||||
{
|
||||
GLTexture offscreenTexture(hasAlphaChannel() ? GL_RGBA8 : GL_RGB8, textureSize());
|
||||
GLRenderTarget offscreenTarget(&offscreenTexture);
|
||||
GLFramebuffer offscreenTarget(&offscreenTexture);
|
||||
|
||||
render(&offscreenTarget);
|
||||
grabTexture(&offscreenTexture, image);
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
bool hasAlphaChannel() const override;
|
||||
QSize textureSize() const override;
|
||||
|
||||
void render(GLRenderTarget *target) override;
|
||||
void render(GLFramebuffer *target) override;
|
||||
void render(QImage *image) override;
|
||||
std::chrono::nanoseconds clock() const override;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
private:
|
||||
const QRect m_region;
|
||||
const qreal m_scale;
|
||||
QScopedPointer<GLRenderTarget> m_target;
|
||||
QScopedPointer<GLFramebuffer> m_target;
|
||||
QScopedPointer<GLTexture> m_renderedTexture;
|
||||
std::chrono::nanoseconds m_last;
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
class GLRenderTarget;
|
||||
class GLFramebuffer;
|
||||
|
||||
class ScreenCastSource : public QObject
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
virtual bool hasAlphaChannel() const = 0;
|
||||
virtual QSize textureSize() const = 0;
|
||||
|
||||
virtual void render(GLRenderTarget *target) = 0;
|
||||
virtual void render(GLFramebuffer *target) = 0;
|
||||
virtual void render(QImage *image) = 0;
|
||||
virtual std::chrono::nanoseconds clock() const = 0;
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ void ScreenCastStream::recordFrame(const QRegion &damagedRegion)
|
|||
|
||||
auto cursor = Cursors::self()->currentCursor();
|
||||
if (m_cursor.mode == KWaylandServer::ScreencastV1Interface::Embedded && m_cursor.viewport.contains(cursor->pos())) {
|
||||
GLRenderTarget::pushRenderTarget(buf->framebuffer());
|
||||
GLFramebuffer::pushFramebuffer(buf->framebuffer());
|
||||
|
||||
QRect r(QPoint(), size);
|
||||
auto shader = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture);
|
||||
|
@ -433,7 +433,7 @@ void ScreenCastStream::recordFrame(const QRegion &damagedRegion)
|
|||
m_cursor.lastRect = cursorRect;
|
||||
|
||||
ShaderManager::instance()->popShader();
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,13 +40,13 @@ QSize WindowScreenCastSource::textureSize() const
|
|||
void WindowScreenCastSource::render(QImage *image)
|
||||
{
|
||||
GLTexture offscreenTexture(hasAlphaChannel() ? GL_RGBA8 : GL_RGB8, textureSize());
|
||||
GLRenderTarget offscreenTarget(&offscreenTexture);
|
||||
GLFramebuffer offscreenTarget(&offscreenTexture);
|
||||
|
||||
render(&offscreenTarget);
|
||||
grabTexture(&offscreenTexture, image);
|
||||
}
|
||||
|
||||
void WindowScreenCastSource::render(GLRenderTarget *target)
|
||||
void WindowScreenCastSource::render(GLFramebuffer *target)
|
||||
{
|
||||
const QRect geometry = m_window->clientGeometry();
|
||||
QMatrix4x4 projectionMatrix;
|
||||
|
@ -57,11 +57,11 @@ void WindowScreenCastSource::render(GLRenderTarget *target)
|
|||
WindowPaintData data(effectWindow);
|
||||
data.setProjectionMatrix(projectionMatrix);
|
||||
|
||||
GLRenderTarget::pushRenderTarget(target);
|
||||
GLFramebuffer::pushFramebuffer(target);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
effectWindow->sceneWindow()->performPaint(Scene::PAINT_WINDOW_TRANSFORMED, infiniteRegion(), data);
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds WindowScreenCastSource::clock() const
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
bool hasAlphaChannel() const override;
|
||||
QSize textureSize() const override;
|
||||
|
||||
void render(GLRenderTarget *target) override;
|
||||
void render(GLFramebuffer *target) override;
|
||||
void render(QImage *image) override;
|
||||
std::chrono::nanoseconds clock() const override;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void LanczosFilter::init()
|
|||
if (!force && options->glSmoothScale() != 2) {
|
||||
return; // disabled by config
|
||||
}
|
||||
if (!GLRenderTarget::supported()) {
|
||||
if (!GLFramebuffer::supported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ void LanczosFilter::updateOffscreenSurfaces()
|
|||
m_offscreenTex = new GLTexture(GL_RGBA8, w, h);
|
||||
m_offscreenTex->setFilter(GL_LINEAR);
|
||||
m_offscreenTex->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||
m_offscreenTarget = new GLRenderTarget(m_offscreenTex);
|
||||
m_offscreenTarget = new GLFramebuffer(m_offscreenTex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ void LanczosFilter::performPaint(EffectWindowImpl *w, int mask, QRegion region,
|
|||
|
||||
// Bind the offscreen FBO and draw the window on it unscaled
|
||||
updateOffscreenSurfaces();
|
||||
GLRenderTarget::pushRenderTarget(m_offscreenTarget);
|
||||
GLFramebuffer::pushFramebuffer(m_offscreenTarget);
|
||||
|
||||
QMatrix4x4 modelViewProjectionMatrix;
|
||||
modelViewProjectionMatrix.ortho(0, m_offscreenTex->width(), m_offscreenTex->height(), 0, 0, 65535);
|
||||
|
@ -341,7 +341,7 @@ void LanczosFilter::performPaint(EffectWindowImpl *w, int mask, QRegion region,
|
|||
cache->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||
cache->bind();
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, m_offscreenTex->height() - th, tw, th);
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
|
||||
if (hardwareClipping) {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
|
|
@ -25,7 +25,7 @@ class EffectWindow;
|
|||
class EffectWindowImpl;
|
||||
class WindowPaintData;
|
||||
class GLTexture;
|
||||
class GLRenderTarget;
|
||||
class GLFramebuffer;
|
||||
class GLShader;
|
||||
class Scene;
|
||||
|
||||
|
@ -51,7 +51,7 @@ private:
|
|||
void createKernel(float delta, int *kernelSize);
|
||||
void createOffsets(int count, float width, Qt::Orientation direction);
|
||||
GLTexture *m_offscreenTex;
|
||||
GLRenderTarget *m_offscreenTarget;
|
||||
GLFramebuffer *m_offscreenTarget;
|
||||
QBasicTimer m_timer;
|
||||
bool m_inited;
|
||||
QScopedPointer<GLShader> m_shader;
|
||||
|
|
|
@ -410,10 +410,10 @@ void WindowThumbnailItem::updateOffscreenTexture()
|
|||
m_offscreenTexture.reset(new GLTexture(GL_RGBA8, textureSize));
|
||||
m_offscreenTexture->setFilter(GL_LINEAR);
|
||||
m_offscreenTexture->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||
m_offscreenTarget.reset(new GLRenderTarget(m_offscreenTexture.data()));
|
||||
m_offscreenTarget.reset(new GLFramebuffer(m_offscreenTexture.data()));
|
||||
}
|
||||
|
||||
GLRenderTarget::pushRenderTarget(m_offscreenTarget.data());
|
||||
GLFramebuffer::pushFramebuffer(m_offscreenTarget.data());
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
@ -430,7 +430,7 @@ void WindowThumbnailItem::updateOffscreenTexture()
|
|||
// frame, which is not ideal, but it is acceptable for things such as thumbnails.
|
||||
const int mask = Scene::PAINT_WINDOW_TRANSFORMED;
|
||||
effectWindow->sceneWindow()->performPaint(mask, infiniteRegion(), data);
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
|
||||
// The fence is needed to avoid the case where qtquick renderer starts using
|
||||
// the texture while all rendering commands to it haven't completed yet.
|
||||
|
@ -499,10 +499,10 @@ void DesktopThumbnailItem::updateOffscreenTexture()
|
|||
m_offscreenTexture->setFilter(GL_LINEAR);
|
||||
m_offscreenTexture->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||
m_offscreenTexture->setYInverted(true);
|
||||
m_offscreenTarget.reset(new GLRenderTarget(m_offscreenTexture.data()));
|
||||
m_offscreenTarget.reset(new GLFramebuffer(m_offscreenTexture.data()));
|
||||
}
|
||||
|
||||
GLRenderTarget::pushRenderTarget(m_offscreenTarget.data());
|
||||
GLFramebuffer::pushFramebuffer(m_offscreenTarget.data());
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
@ -516,7 +516,7 @@ void DesktopThumbnailItem::updateOffscreenTexture()
|
|||
const int mask = Scene::PAINT_WINDOW_TRANSFORMED | Scene::PAINT_SCREEN_TRANSFORMED;
|
||||
Scene *scene = Compositor::self()->scene();
|
||||
scene->paintDesktop(m_desktop, mask, infiniteRegion(), data);
|
||||
GLRenderTarget::popRenderTarget();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
|
||||
// The fence is needed to avoid the case where qtquick renderer starts using
|
||||
// the texture while all rendering commands to it haven't completed yet.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace KWin
|
||||
{
|
||||
class AbstractClient;
|
||||
class GLRenderTarget;
|
||||
class GLFramebuffer;
|
||||
class GLTexture;
|
||||
class ThumbnailTextureProvider;
|
||||
|
||||
|
@ -85,7 +85,7 @@ protected:
|
|||
|
||||
mutable ThumbnailTextureProvider *m_provider = nullptr;
|
||||
QSharedPointer<GLTexture> m_offscreenTexture;
|
||||
QScopedPointer<GLRenderTarget> m_offscreenTarget;
|
||||
QScopedPointer<GLFramebuffer> m_offscreenTarget;
|
||||
GLsync m_acquireFence = 0;
|
||||
qreal m_devicePixelRatio = 1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue