HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
pipeline_image_image.hpp
1// Copyright Take Vos 2019-2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "pipeline_image_page.hpp"
8#include "../vspan.hpp"
9#include "../geometry/axis_aligned_rectangle.hpp"
10#include "../geometry/matrix.hpp"
11#include <cstdlib>
12#include <span>
13#include <atomic>
14#include <string>
15
16namespace tt {
17
18template<typename T> class pixel_map;
19class sfloat_rgba16;
20};
21
22namespace tt::pipeline_image {
23
24struct vertex;
25struct ImageLocation;
26struct device_shared;
27
30struct image {
31 enum class State { Uninitialized, Drawing, Uploaded };
32
33 mutable std::atomic<State> state = State::Uninitialized;
34
35 device_shared *parent;
36
40
44
48
52
54
55 image() noexcept :
56 parent(nullptr), width_in_px(0), height_in_px(0), width_in_pages(0), height_in_pages(0), pages() {}
57
58 image(
59 device_shared *parent,
60 size_t width_in_px,
61 size_t height_in_px,
62 size_t width_in_pages,
63 size_t height_in_pages,
64 std::vector<Page> &&pages) noexcept :
65 parent(parent),
70 pages(std::move(pages)) {}
71
72 image(image &&other) noexcept;
73 image &operator=(image &&other) noexcept;
74 ~image();
75
76 image(image const &other) = delete;
77 image &operator=(image const &other) = delete;
78
84 aarectangle index_to_rect(size_t page_index) const noexcept;
85
90 void place_vertices(vspan<vertex> &vertices, aarectangle clipping_rectangle, matrix3 transform);
91
94 void upload(pixel_map<sfloat_rgba16> const &image) noexcept;
95
96private:
99
100 void calculateVertexPositions(matrix3 transform, aarectangle clippingRectangle);
101
102 void placePageVertices(vspan<vertex> &vertices, size_t index, aarectangle clippingRectangle) const;
103
104};
105
106}
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
A 2D canvas of pixels.
Definition pixel_map.hpp:101
Definition pipeline_image_device_shared.hpp:24
This is a image that is uploaded into the texture atlas.
Definition pipeline_image_image.hpp:30
aarectangle index_to_rect(size_t page_index) const noexcept
Find the image coordinates of a page in the image.
void upload(pixel_map< sfloat_rgba16 > const &image) noexcept
Upload image to atlas.
size_t height_in_px
The height of the image in pixels.
Definition pipeline_image_image.hpp:43
void place_vertices(vspan< vertex > &vertices, aarectangle clipping_rectangle, matrix3 transform)
size_t height_in_pages
The height of the image in pages.
Definition pipeline_image_image.hpp:51
size_t width_in_pages
The width of the image in pages.
Definition pipeline_image_image.hpp:47
size_t width_in_px
The width of the image in pixels.
Definition pipeline_image_image.hpp:39
Definition vspan.hpp:73
T move(T... args)