• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "render_post_process_taa.h"
17 
18 #include <core/property/property_types.h>
19 #include <core/property_tools/property_api_impl.inl>
20 
21 #include "util/log.h"
22 
23 using namespace BASE_NS;
24 using namespace CORE_NS;
25 using namespace RENDER_NS;
26 
27 CORE_BEGIN_NAMESPACE()
28 DECLARE_PROPERTY_TYPE(TaaConfiguration);
29 DECLARE_PROPERTY_TYPE(TaaConfiguration::Sharpness);
30 DECLARE_PROPERTY_TYPE(TaaConfiguration::Quality);
31 ENUM_TYPE_METADATA(TaaConfiguration::Sharpness, ENUM_VALUE(SOFT, "Soft Sharpness"),
32     ENUM_VALUE(MEDIUM, "Medium Sharpness"), ENUM_VALUE(SHARP, "Sharp Sharpness"))
33 
34 ENUM_TYPE_METADATA(TaaConfiguration::Quality, ENUM_VALUE(LOW, "Low Quality"), ENUM_VALUE(MEDIUM, "Medium Quality"),
35     ENUM_VALUE(HIGH, "High Quality"))
36 
37 DATA_TYPE_METADATA(TaaConfiguration, MEMBER_PROPERTY(sharpness, "Sharpness", 0), MEMBER_PROPERTY(quality, "Quality", 0),
38     MEMBER_PROPERTY(useBicubic, "Use Bicubic", 0), MEMBER_PROPERTY(useVarianceClipping, "Use Variance Clipping", 0),
39     MEMBER_PROPERTY(useyCoCG, "Use yCoCG", 0), MEMBER_PROPERTY(ignoreBicubicEdges, "Ignore Bicubic Edges", 0))
40 
41 DATA_TYPE_METADATA(RenderPostProcessTaaNode::EffectProperties, MEMBER_PROPERTY(enabled, "Enabled", 0),
42     MEMBER_PROPERTY(taaConfiguration, "TAA Configuration", 0))
43 CORE_END_NAMESPACE()
44 
45 RENDER_BEGIN_NAMESPACE()
46 namespace {
47 constexpr size_t PROPERTY_BYTE_SIZE { sizeof(RenderPostProcessTaaNode::EffectProperties) };
48 }
49 
RenderPostProcessTaa()50 RenderPostProcessTaa::RenderPostProcessTaa()
51     : properties_(
52           &propertiesData, array_view(PropertyType::DataType<RenderPostProcessTaaNode::EffectProperties>::properties))
53 {}
54 
GetProperties()55 CORE_NS::IPropertyHandle* RenderPostProcessTaa::GetProperties()
56 {
57     return properties_.GetData();
58 }
59 
SetData(BASE_NS::array_view<const uint8_t> data)60 void RenderPostProcessTaa::SetData(BASE_NS::array_view<const uint8_t> data)
61 {
62     if (data.size_bytes() == PROPERTY_BYTE_SIZE) {
63         BASE_NS::CloneData(&propertiesData, PROPERTY_BYTE_SIZE, data.data(), data.size_bytes());
64     }
65 #if (RENDER_VALIDATION_ENABLED == 1)
66     if (data.size_bytes() != PROPERTY_BYTE_SIZE) {
67         PLUGIN_LOG_ONCE_E("RenderPostProcessTaa_Size_Mismatch",
68             "RENDER_VALIDATION_ENABLED: RenderPostProcessTaa::SetData(), size missmatch (ignored)");
69     }
70 #endif
71 }
72 
GetData() const73 BASE_NS::array_view<const uint8_t> RenderPostProcessTaa::GetData() const
74 {
75     return { reinterpret_cast<const uint8_t*>(&propertiesData), PROPERTY_BYTE_SIZE };
76 }
77 RENDER_END_NAMESPACE()
78