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_combined.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 CORE_BEGIN_NAMESPACE()
27 DATA_TYPE_METADATA(RenderPostProcessCombinedNode::EffectProperties, MEMBER_PROPERTY(enabled, "Enabled", 0))
28 CORE_END_NAMESPACE()
29 RENDER_BEGIN_NAMESPACE()
30
31 namespace {
32 constexpr size_t PROPERTY_BYTE_SIZE { sizeof(RenderPostProcessCombinedNode::EffectProperties) };
33 }
34
RenderPostProcessCombined()35 RenderPostProcessCombined::RenderPostProcessCombined() {}
36
GetProperties()37 CORE_NS::IPropertyHandle* RenderPostProcessCombined::GetProperties()
38 {
39 return properties_.GetData();
40 }
41
SetData(BASE_NS::array_view<const uint8_t> data)42 void RenderPostProcessCombined::SetData(BASE_NS::array_view<const uint8_t> data)
43 {
44 if (data.size_bytes() == PROPERTY_BYTE_SIZE) {
45 BASE_NS::CloneData(&propertiesData, PROPERTY_BYTE_SIZE, data.data(), data.size_bytes());
46 }
47 #if (RENDER_VALIDATION_ENABLED == 1)
48 if (data.size_bytes() != PROPERTY_BYTE_SIZE) {
49 PLUGIN_LOG_ONCE_E("RenderPostProcessCombined_Size_Mismatch",
50 "RENDER_VALIDATION_ENABLED: RenderPostProcessCombined::SetData(), size missmatch (ignored)");
51 }
52 #endif
53 }
54
GetData() const55 BASE_NS::array_view<const uint8_t> RenderPostProcessCombined::GetData() const
56 {
57 return { reinterpret_cast<const uint8_t*>(&propertiesData), PROPERTY_BYTE_SIZE };
58 }
59 RENDER_END_NAMESPACE()
60