mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:37:47 +00:00
LibAccelGfx+WebContent: Introduce Canvas that represents framebuffer
This commit is contained in:
parent
c03b69e664
commit
d5630fedf1
4 changed files with 84 additions and 26 deletions
46
Userland/Libraries/LibAccelGfx/Canvas.h
Normal file
46
Userland/Libraries/LibAccelGfx/Canvas.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <LibAccelGfx/GL.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
||||
namespace AccelGfx {
|
||||
|
||||
class Canvas : public RefCounted<Canvas> {
|
||||
public:
|
||||
static NonnullRefPtr<Canvas> create(Gfx::IntSize const& size)
|
||||
{
|
||||
return adopt_ref(*new Canvas(size));
|
||||
}
|
||||
|
||||
Gfx::IntSize const& size() const { return m_size; }
|
||||
GL::Framebuffer const& framebuffer() const { return m_framebuffer; }
|
||||
|
||||
void bind()
|
||||
{
|
||||
GL::bind_framebuffer(m_framebuffer);
|
||||
}
|
||||
|
||||
virtual ~Canvas()
|
||||
{
|
||||
GL::delete_framebuffer(m_framebuffer);
|
||||
}
|
||||
|
||||
private:
|
||||
Canvas(Gfx::IntSize const& size)
|
||||
: m_size(size)
|
||||
, m_framebuffer(GL::create_framebuffer(size))
|
||||
{
|
||||
}
|
||||
|
||||
Gfx::IntSize m_size;
|
||||
GL::Framebuffer m_framebuffer;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue