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 "../aarect.hpp"
10#include "../numeric_array.hpp"
11#include "../aarect.hpp"
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
45
47
48 Image() noexcept :
49 parent(nullptr), extent(), pageExtent(), pages() {}
50
51 Image(device_shared *parent, i32x4 extent, i32x4 pageExtent, std::vector<Page> &&pages) noexcept :
52 parent(parent),
55 pages(std::move(pages)) {}
56
57 Image(Image &&other) noexcept;
58 Image &operator=(Image &&other) noexcept;
59 ~Image();
60
61 Image(Image const &other) = delete;
62 Image &operator=(Image const &other) = delete;
63
69 iaarect indexToRect(int const pageIndex) const noexcept;
70
75 void placeVertices(vspan<vertex> &vertices, matrix3 transform, aarect clippingRectangle);
76
79 void upload(pixel_map<sfloat_rgba16> const &image) noexcept;
80
81private:
84
85 void calculateVertexPositions(matrix3 transform, aarect clippingRectangle);
86
87 void placePageVertices(vspan<vertex> &vertices, int const index, aarect clippingRectangle) const;
88
89};
90
91}
A 2D canvas of pixels.
Definition pixel_map.hpp:99
Definition pipeline_image_device_shared.hpp:24
This is a image that is uploaded into the texture atlas.
Definition pipeline_image_image.hpp:30
i32x4 extent
The size of the image in pixels.
Definition pipeline_image_image.hpp:39
i32x4 pageExtent
This size of the image in pages.
Definition pipeline_image_image.hpp:44
iaarect indexToRect(int const pageIndex) 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.
void placeVertices(vspan< vertex > &vertices, matrix3 transform, aarect clippingRectangle)
A 4D vector.
Definition ivec.hpp:38
Definition vspan.hpp:73
T move(T... args)