|
| 1 | +/* |
| 2 | + * Copyright 2026 Diligent Graphics LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * In no event and under no legal theory, whether in tort (including negligence), |
| 17 | + * contract, or otherwise, unless required by applicable law (such as deliberate |
| 18 | + * and grossly negligent acts) or agreed to in writing, shall any Contributor be |
| 19 | + * liable for any damages, including any direct, indirect, special, incidental, |
| 20 | + * or consequential damages of any character arising as a result of this License or |
| 21 | + * out of the use or inability to use the software (including but not limited to damages |
| 22 | + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and |
| 23 | + * all other commercial damages or losses), even if such Contributor has been advised |
| 24 | + * of the possibility of such damages. |
| 25 | + */ |
| 26 | + |
| 27 | +#pragma once |
| 28 | + |
| 29 | +#include "ObjectBase.hpp" |
| 30 | +#include "SuperResolution.h" |
| 31 | + |
| 32 | +#include <vector> |
| 33 | +#include <string> |
| 34 | + |
| 35 | +namespace Diligent |
| 36 | +{ |
| 37 | + |
| 38 | +class SuperResolutionBase : public ObjectBase<ISuperResolution> |
| 39 | +{ |
| 40 | +public: |
| 41 | + using TBase = ObjectBase<ISuperResolution>; |
| 42 | + |
| 43 | + SuperResolutionBase(IReferenceCounters* pRefCounters, |
| 44 | + const SuperResolutionDesc& Desc) : |
| 45 | + TBase{pRefCounters}, |
| 46 | + m_Desc{Desc} |
| 47 | + { |
| 48 | + if (Desc.Name != nullptr) |
| 49 | + { |
| 50 | + m_Name = Desc.Name; |
| 51 | + m_Desc.Name = m_Name.c_str(); |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_SuperResolution, TBase) |
| 56 | + |
| 57 | + virtual const SuperResolutionDesc& DILIGENT_CALL_TYPE GetDesc() const override final |
| 58 | + { |
| 59 | + return m_Desc; |
| 60 | + } |
| 61 | + |
| 62 | + virtual void DILIGENT_CALL_TYPE GetJitterOffset(Uint32 Index, float* pJitterX, float* pJitterY) const override final |
| 63 | + { |
| 64 | + DEV_CHECK_ERR(pJitterX != nullptr && pJitterY != nullptr, "pJitterX and pJitterY must not be null"); |
| 65 | + |
| 66 | + if (!m_JitterPattern.empty()) |
| 67 | + { |
| 68 | + const Uint32 WrappedIndex = Index % static_cast<Uint32>(m_JitterPattern.size()); |
| 69 | + *pJitterX = m_JitterPattern[WrappedIndex].X; |
| 70 | + *pJitterY = m_JitterPattern[WrappedIndex].Y; |
| 71 | + } |
| 72 | + else |
| 73 | + { |
| 74 | + *pJitterX = 0.0f; |
| 75 | + *pJitterY = 0.0f; |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | +protected: |
| 80 | + struct JitterOffset |
| 81 | + { |
| 82 | + float X = 0.0f; |
| 83 | + float Y = 0.0f; |
| 84 | + }; |
| 85 | + |
| 86 | + SuperResolutionDesc m_Desc; |
| 87 | + std::string m_Name; |
| 88 | + std::vector<JitterOffset> m_JitterPattern; |
| 89 | +}; |
| 90 | + |
| 91 | +} // namespace Diligent |
0 commit comments