Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
texture.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#ifndef INKSCAPE_UI_WIDGET_CANVAS_TEXTURE_H
4#define INKSCAPE_UI_WIDGET_CANVAS_TEXTURE_H
5
6#include <2geom/point.h>
7#include <epoxy/gl.h>
8
9namespace Inkscape::UI::Widget {
10
12{
13public:
14 // Create null texture owning no resources.
15 Texture() = default;
16
17 // Allocate a blank texture of a given size. The texture is bound to GL_TEXTURE_2D.
19
20 // Wrap an existing texture.
21 Texture(GLuint id, Geom::IntPoint const &size) : _id(id), _size(size) {}
22
23 // Boilerplate constructors/operators
24 Texture(Texture &&other) noexcept { _movefrom(other); }
25 Texture &operator=(Texture &&other) noexcept { _reset(); _movefrom(other); return *this; }
27
28 // Observers
29 GLuint id() const { return _id; }
30 Geom::IntPoint const &size() const { return _size; }
31 explicit operator bool() const { return _id; }
32
33 // Methods
34 void clear() { _reset(); _id = 0; }
35 void invalidate();
36
37private:
38 GLuint _id = 0;
40
41 void _reset() noexcept { if (_id) glDeleteTextures(1, &_id); }
42 void _movefrom(Texture &other) noexcept { _id = other._id; _size = other._size; other._id = 0; }
43};
44
45} // namespace Inkscape::UI::Widget
46
47#endif // INKSCAPE_UI_WIDGET_CANVAS_TEXTURE_H
48
49/*
50 Local Variables:
51 mode:c++
52 c-file-style:"stroustrup"
53 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
54 indent-tabs-mode:nil
55 fill-column:99
56 End:
57*/
58// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
Cartesian point / 2D vector and related operations.
Two-dimensional point with integer coordinates.
Definition int-point.h:57
Texture & operator=(Texture &&other) noexcept
Definition texture.h:25
void _movefrom(Texture &other) noexcept
Definition texture.h:42
void _reset() noexcept
Definition texture.h:41
Texture(GLuint id, Geom::IntPoint const &size)
Definition texture.h:21
Geom::IntPoint const & size() const
Definition texture.h:30
Texture(Texture &&other) noexcept
Definition texture.h:24
Custom widgets.
Definition desktop.h:126