File indexing completed on 2024-11-10 04:56:40

0001 /*
0002     SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "core/rendertarget.h"
0008 #include "opengl/glutils.h"
0009 
0010 namespace KWin
0011 {
0012 
0013 RenderTarget::RenderTarget(GLFramebuffer *fbo, const ColorDescription &colorDescription)
0014     : m_framebuffer(fbo)
0015     , m_transform(fbo->colorAttachment() ? fbo->colorAttachment()->contentTransform() : OutputTransform())
0016     , m_colorDescription(colorDescription)
0017 {
0018 }
0019 
0020 RenderTarget::RenderTarget(QImage *image, const ColorDescription &colorDescription)
0021     : m_image(image)
0022     , m_colorDescription(colorDescription)
0023 {
0024 }
0025 
0026 QSize RenderTarget::size() const
0027 {
0028     if (m_framebuffer) {
0029         return m_framebuffer->size();
0030     } else if (m_image) {
0031         return m_image->size();
0032     } else {
0033         Q_UNREACHABLE();
0034     }
0035 }
0036 
0037 OutputTransform RenderTarget::transform() const
0038 {
0039     return m_transform;
0040 }
0041 
0042 GLFramebuffer *RenderTarget::framebuffer() const
0043 {
0044     return m_framebuffer;
0045 }
0046 
0047 GLTexture *RenderTarget::texture() const
0048 {
0049     return m_framebuffer->colorAttachment();
0050 }
0051 
0052 QImage *RenderTarget::image() const
0053 {
0054     return m_image;
0055 }
0056 
0057 const ColorDescription &RenderTarget::colorDescription() const
0058 {
0059     return m_colorDescription;
0060 }
0061 
0062 } // namespace KWin