1.10
canvas.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_CANVAS_H
7#define EGT_CANVAS_H
8
14#include <egt/detail/meta.h>
15#include <egt/geometry.h>
16#include <egt/types.h>
17
18namespace egt
19{
20inline namespace v1
21{
22
40class EGT_API Canvas
41{
42public:
43
52 explicit Canvas(const Size& size,
53 PixelFormat format = PixelFormat::argb8888) noexcept;
54
63 explicit Canvas(const SizeF& size,
64 PixelFormat format = PixelFormat::argb8888) noexcept;
65
73 explicit Canvas(const shared_cairo_surface_t& surface) noexcept;
74
84 Canvas(const shared_cairo_surface_t& surface, PixelFormat format) noexcept;
85
89 EGT_NODISCARD shared_cairo_t context() const { return m_cr; }
90
94 EGT_NODISCARD shared_cairo_surface_t surface() const { return m_surface; }
95
99 EGT_NODISCARD Size size() const;
100
107 void reallocate(const Size& size, PixelFormat format = PixelFormat::argb8888);
108
115 void reallocate(const SizeF& size, PixelFormat format = PixelFormat::argb8888);
116
123 void zero();
124
128 EGT_NODISCARD PixelFormat format() const;
129
133 void copy(const shared_cairo_surface_t& surface);
134
135 void copy(const shared_cairo_surface_t& surface, const RectF& rect);
136
137protected:
138
143
148};
149
150}
151}
152
153#endif
Manages a unique drawing surface and context.
Definition canvas.h:41
void zero()
Fill the surface with zero (including for transparency channel if applicable).
void reallocate(const SizeF &size, PixelFormat format=PixelFormat::argb8888)
Reallocate the canvas to a different size.
void copy(const shared_cairo_surface_t &surface, const RectF &rect)
void reallocate(const Size &size, PixelFormat format=PixelFormat::argb8888)
Reallocate the canvas to a different size.
Canvas(const shared_cairo_surface_t &surface, PixelFormat format) noexcept
Construct a canvas with an already existing surface, and specify the format of the surface the canvas...
shared_cairo_t m_cr
The context of the canvas.
Definition canvas.h:147
void copy(const shared_cairo_surface_t &surface)
Create a copy of a surface.
Canvas(const SizeF &size, PixelFormat format=PixelFormat::argb8888) noexcept
Construct a canvas with the specified format and size.
EGT_NODISCARD Size size() const
Get the size of the surface.
EGT_NODISCARD PixelFormat format() const
Get the format of the surface.
EGT_NODISCARD shared_cairo_surface_t surface() const
Get the surface for the Canvas.
Definition canvas.h:94
EGT_NODISCARD shared_cairo_t context() const
Get the context for the Canvas.
Definition canvas.h:89
Canvas(const Size &size, PixelFormat format=PixelFormat::argb8888) noexcept
Construct a canvas with the specified format and size.
Canvas(const shared_cairo_surface_t &surface) noexcept
Construct a canvas with an already existing surface.
shared_cairo_surface_t m_surface
The surface of the canvas.
Definition canvas.h:142
A rectangle with a point and a size.
Definition geometry.h:595
std::shared_ptr< cairo_surface_t > shared_cairo_surface_t
Shared pointer for a cairo surface.
Definition types.h:29
std::shared_ptr< cairo_t > shared_cairo_t
Shared pointer for a cairo context.
Definition types.h:35
PixelFormat
Supported pixel formats.
Definition types.h:94
EGT framework namespace.
Definition animation.h:24