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 <span>
11#include <atomic>
12#include <string>
13
14namespace tt {
15
16template<typename T> class pixel_map;
17class sfloat_rgba16;
18};
19
20namespace tt::pipeline_image {
21
22struct vertex;
23struct ImageLocation;
24struct device_shared;
25
28struct Image {
29 enum class State { Uninitialized, Drawing, Uploaded };
30
31 mutable std::atomic<State> state = State::Uninitialized;
32
33 device_shared *parent;
34
38
42
46
50
52
53 Image() noexcept :
54 parent(nullptr), width_in_px(0), height_in_px(0), width_in_pages(0), height_in_pages(0), pages() {}
55
56 Image(
57 device_shared *parent,
58 size_t width_in_px,
59 size_t height_in_px,
60 size_t width_in_pages,
61 size_t height_in_pages,
62 std::vector<Page> &&pages) noexcept :
63 parent(parent),
68 pages(std::move(pages)) {}
69
70 Image(Image &&other) noexcept;
71 Image &operator=(Image &&other) noexcept;
72 ~Image();
73
74 Image(Image const &other) = delete;
75 Image &operator=(Image const &other) = delete;
76
82 aarectangle index_to_rect(size_t page_index) const noexcept;
83
88 void place_vertices(vspan<vertex> &vertices, aarectangle clipping_rectangle, matrix3 transform);
89
92 void upload(pixel_map<sfloat_rgba16> const &image) noexcept;
93
94private:
97
98 void calculateVertexPositions(matrix3 transform, aarectangle clippingRectangle);
99
100 void placePageVertices(vspan<vertex> &vertices, size_t index, aarectangle clippingRectangle) const;
101
102};
103
104}
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:18
A 2D canvas of pixels.
Definition pixel_map.hpp:100
Definition pipeline_image_device_shared.hpp:24
This is a image that is uploaded into the texture atlas.
Definition pipeline_image_image.hpp:28
size_t width_in_pages
The width of the image in pages.
Definition pipeline_image_image.hpp:45
void place_vertices(vspan< vertex > &vertices, aarectangle clipping_rectangle, matrix3 transform)
aarectangle index_to_rect(size_t page_index) const noexcept
Find the image coordinates of a page in the image.
size_t height_in_pages
The height of the image in pages.
Definition pipeline_image_image.hpp:49
size_t width_in_px
The width of the image in pixels.
Definition pipeline_image_image.hpp:37
size_t height_in_px
The height of the image in pixels.
Definition pipeline_image_image.hpp:41
void upload(pixel_map< sfloat_rgba16 > const &image) noexcept
Upload image to atlas.
Definition vspan.hpp:73
T move(T... args)