• 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_dof.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(DofConfiguration);
29 
30 DATA_TYPE_METADATA(RenderPostProcessDofNode::EffectProperties, MEMBER_PROPERTY(enabled, "Enabled", 0),
31     MEMBER_PROPERTY(dofConfiguration, "DOF Configuration", 0))
32 CORE_END_NAMESPACE()
33 
34 RENDER_BEGIN_NAMESPACE()
35 namespace {
36 constexpr size_t PROPERTY_BYTE_SIZE { sizeof(RenderPostProcessDofNode::EffectProperties) };
37 }
38 
RenderPostProcessDof()39 RenderPostProcessDof::RenderPostProcessDof()
40     : properties_(
41           &propertiesData, array_view(PropertyType::DataType<RenderPostProcessDofNode::EffectProperties>::properties))
42 {}
43 
GetProperties()44 CORE_NS::IPropertyHandle* RenderPostProcessDof::GetProperties()
45 {
46     return properties_.GetData();
47 }
48 
SetData(BASE_NS::array_view<const uint8_t> data)49 void RenderPostProcessDof::SetData(BASE_NS::array_view<const uint8_t> data)
50 {
51     if (data.size_bytes() == PROPERTY_BYTE_SIZE) {
52         BASE_NS::CloneData(&propertiesData, PROPERTY_BYTE_SIZE, data.data(), data.size_bytes());
53     }
54 #if (RENDER_VALIDATION_ENABLED == 1)
55     if (data.size_bytes() != PROPERTY_BYTE_SIZE) {
56         PLUGIN_LOG_ONCE_E("RenderPostProcessDof_Size_Mismatch",
57             "RENDER_VALIDATION_ENABLED: RenderPostProcessDof::SetData(), size missmatch (ignored)");
58     }
59 #endif
60 }
61 
GetData() const62 BASE_NS::array_view<const uint8_t> RenderPostProcessDof::GetData() const
63 {
64     return { reinterpret_cast<const uint8_t*>(&propertiesData), PROPERTY_BYTE_SIZE };
65 }
66 RENDER_END_NAMESPACE()
67