HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
PipelineImage_Image.hpp
1// Copyright 2019 Pokitec
2// All rights reserved.
3
4#pragma once
5
6#include "TTauri/Foundation/vspan.hpp"
7#include "TTauri/Foundation/ivec.hpp"
8#include "TTauri/Foundation/iaarect.hpp"
9#include "TTauri/Foundation/vec.hpp"
10#include "TTauri/Foundation/aarect.hpp"
11#include "TTauri/Foundation/mat.hpp"
12#include "TTauri/GUI/PipelineImage_Page.hpp"
13#include <nonstd/span>
14#include <atomic>
15#include <string>
16
17namespace tt {
18
19template<typename T> struct PixelMap;
20class R16G16B16A16SFloat;
21};
22
23namespace tt::PipelineImage {
24
25struct Vertex;
26struct ImageLocation;
27struct DeviceShared;
28
31struct Image {
32 enum class State { Uninitialized, Drawing, Uploaded };
33
34 mutable std::atomic<State> state = State::Uninitialized;
35
36 DeviceShared *parent;
37
41
46
48
49 Image() noexcept :
50 parent(nullptr), extent(), pageExtent(), pages() {}
51
52 Image(DeviceShared *parent, ivec extent, ivec pageExtent, std::vector<Page> &&pages) noexcept :
53 parent(parent),
56 pages(std::move(pages)) {}
57
58 Image(Image &&other) noexcept;
59 Image &operator=(Image &&other) noexcept;
60 ~Image();
61
62 Image(Image const &other) = delete;
63 Image &operator=(Image const &other) = delete;
64
70 iaarect indexToRect(int const pageIndex) const noexcept;
71
76 void placeVertices(vspan<Vertex> &vertices, mat transform, aarect clippingRectangle);
77
80 void upload(PixelMap<R16G16B16A16SFloat> const &image) noexcept;
81
82private:
85
86 void calculateVertexPositions(mat transform, aarect clippingRectangle);
87
88 void placePageVertices(vspan<Vertex> &vertices, int const index, aarect clippingRectangle) const;
89
90};
91
92}
An image, in different formats.
Definition Image.hpp:18
Class which represents an axis-aligned rectangle.
Definition aarect.hpp:13
Class which represents an axis-aligned rectangle.
Definition iaarect.hpp:12
A 4D vector.
Definition ivec.hpp:37
A 4x4 matrix.
Definition mat.hpp:18
A 2D canvas of pixels.
Definition PixelMap.hpp:83
Definition vspan.hpp:72
Definition PipelineImage_DeviceShared.hpp:23
This is a image that is uploaded into the texture atlas.
Definition PipelineImage_Image.hpp:31
void placeVertices(vspan< Vertex > &vertices, mat transform, aarect clippingRectangle)
iaarect indexToRect(int const pageIndex) const noexcept
Find the image coordinates of a page in the image.
void upload(PixelMap< R16G16B16A16SFloat > const &image) noexcept
Upload image to atlas.
ivec pageExtent
This size of the image in pages.
Definition PipelineImage_Image.hpp:45
ivec extent
The size of the image in pixels.
Definition PipelineImage_Image.hpp:40
T move(T... args)