• 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_fxaa.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(FxaaConfiguration);
29 DECLARE_PROPERTY_TYPE(FxaaConfiguration::Sharpness);
30 DECLARE_PROPERTY_TYPE(FxaaConfiguration::Quality);
31 ENUM_TYPE_METADATA(FxaaConfiguration::Sharpness, ENUM_VALUE(SOFT, "Soft Sharpness"),
32     ENUM_VALUE(MEDIUM, "Medium Sharpness"), ENUM_VALUE(SHARP, "Sharp Sharpness"))
33 
34 ENUM_TYPE_METADATA(FxaaConfiguration::Quality, ENUM_VALUE(LOW, "Low Quality"), ENUM_VALUE(MEDIUM, "Medium Quality"),
35     ENUM_VALUE(HIGH, "High Quality"))
36 
37 DATA_TYPE_METADATA(RenderPostProcessFxaaNode::EffectProperties, MEMBER_PROPERTY(enabled, "Enabled", 0),
38     MEMBER_PROPERTY(fxaaConfiguration, "FXAA Configuration", 0), MEMBER_PROPERTY(targetSize, "Target Size", 0))
39 CORE_END_NAMESPACE()
40 
41 RENDER_BEGIN_NAMESPACE()
42 namespace {
43 constexpr size_t PROPERTY_BYTE_SIZE { sizeof(RenderPostProcessFxaaNode::EffectProperties) };
44 }
45 
RenderPostProcessFxaa()46 RenderPostProcessFxaa::RenderPostProcessFxaa()
47     : properties_(
48           &propertiesData, array_view(PropertyType::DataType<RenderPostProcessFxaaNode::EffectProperties>::properties))
49 {}
50 
GetProperties()51 CORE_NS::IPropertyHandle* RenderPostProcessFxaa::GetProperties()
52 {
53     return properties_.GetData();
54 }
55 
SetData(BASE_NS::array_view<const uint8_t> data)56 void RenderPostProcessFxaa::SetData(BASE_NS::array_view<const uint8_t> data)
57 {
58     if (data.size_bytes() == PROPERTY_BYTE_SIZE) {
59         BASE_NS::CloneData(&propertiesData, PROPERTY_BYTE_SIZE, data.data(), data.size_bytes());
60     }
61 #if (RENDER_VALIDATION_ENABLED == 1)
62     if (data.size_bytes() != PROPERTY_BYTE_SIZE) {
63         PLUGIN_LOG_ONCE_E("RenderPostProcessFxaa_Size_Mismatch",
64             "RENDER_VALIDATION_ENABLED: RenderPostProcessFxaa::SetData(), size missmatch (ignored)");
65     }
66 #endif
67 }
68 
GetData() const69 BASE_NS::array_view<const uint8_t> RenderPostProcessFxaa::GetData() const
70 {
71     return { reinterpret_cast<const uint8_t*>(&propertiesData), PROPERTY_BYTE_SIZE };
72 }
73 RENDER_END_NAMESPACE()
74