Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_lod_capable_layer_offset.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef __KIS_LOD_CAPABLE_LAYER_OFFSET_H
8#define __KIS_LOD_CAPABLE_LAYER_OFFSET_H
9
10#include "kritaimage_export.h"
12
13
15{
20template <typename T>
21inline T syncLodNValue(const T &value, int lod) {
22 return value.syncLodNValue(lod);
23}
24
28KRITAIMAGE_EXPORT
29QPoint syncLodNValue(const QPoint &value, int lod);
30
31} // namespace KisLodSwitchingWrapperDetail
32
33template <typename T>
35{
36public:
39 m_data(std::forward<T>(initialValue)),
40 m_lodNData(KisLodSwitchingWrapperDetail::syncLodNValue(m_data, defaultBounds->currentLevelOfDetail()))
41 {
42 }
43
48
55
57 {
58 if (this != &rhs) {
60 m_data = rhs.m_data;
62 }
63
64 return *this;
65 }
66
67
71
75
76 const T *operator->() const noexcept
77 {
79 }
80
81 T *operator->() noexcept
82 {
84 }
85
86 const T& operator*() const noexcept
87 {
89 }
90
91 T& operator*() noexcept
92 {
94 }
95
101
102 using LodState = std::pair<int, T>;
103
104 void setLodState(const LodState &state) {
105 (state.first > 0 ? m_lodNData : m_data) = state.second;
106 }
107
109 return std::make_pair(m_defaultBounds->currentLevelOfDetail(), *(*this));
110 }
111
112 operator LodState() const {
113 return lodState();
114 }
115
117 {
118 setLodState(rhs);
119 return *this;
120 }
121
122
123private:
127};
128
130
131#endif /* __KIS_LOD_CAPABLE_LAYER_OFFSET_H */
float value(const T *src, size_t ch)
virtual int currentLevelOfDetail() const =0
KisLodSwitchingWrapper(T &&initialValue, KisDefaultBoundsBaseSP defaultBounds)
void setLodState(const LodState &state)
KisLodSwitchingWrapper(const KisLodSwitchingWrapper &rhs)
const T & operator*() const noexcept
const T * operator->() const noexcept
KisLodSwitchingWrapper(KisDefaultBoundsBaseSP defaultBounds)
KisDefaultBoundsBaseSP m_defaultBounds
KisLodSwitchingWrapper & operator=(const LodState &rhs)
KisLodSwitchingWrapper & operator=(const KisLodSwitchingWrapper &rhs)
void setDefaultBounds(KisDefaultBoundsBaseSP defaultBounds)
KisDefaultBoundsBaseSP defaultBounds() const
QPoint syncLodNValue(const QPoint &value, int lod)