• 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_data_store_weather.h"
17 
18 #include <core/intf_engine.h>
19 #include <core/log.h>
20 #include <render/intf_render_context.h>
21 
22 using namespace BASE_NS;
23 using namespace CORE_NS;
24 using namespace RENDER_NS;
25 
CORE3D_BEGIN_NAMESPACE()26 CORE3D_BEGIN_NAMESPACE()
27 RenderDataStoreWeather::RenderDataStoreWeather(const IRenderContext& renderContext, const BASE_NS::string_view name)
28     : name_(name), renderContex_(renderContext)
29 {}
30 
PostRender()31 void RenderDataStoreWeather::PostRender()
32 {
33     Clear();
34 }
35 
Clear()36 void RenderDataStoreWeather::Clear()
37 {
38     // clear every frame
39     waterEffectData_.clear();
40 
41     // NOTE: weather settings are not cleared at the moment
42 }
43 
SetWeatherSettings(uint64_t id,const WeatherSettings & settings)44 void RenderDataStoreWeather::SetWeatherSettings(uint64_t id, const WeatherSettings& settings)
45 {
46     settings_ = settings;
47 }
48 
GetWeatherSettings() const49 RenderDataStoreWeather::WeatherSettings RenderDataStoreWeather::GetWeatherSettings() const
50 {
51     return settings_;
52 }
53 
SetWaterEffect(uint64_t id,Math::Vec2 offset)54 void RenderDataStoreWeather::SetWaterEffect(uint64_t id, Math::Vec2 offset)
55 {
56     waterEffectData_.push_back({ id, offset });
57 }
58 
GetWaterEffectData() const59 array_view<const RenderDataStoreWeather::WaterEffectData> RenderDataStoreWeather::GetWaterEffectData() const
60 {
61     return { waterEffectData_.data(), waterEffectData_.size() };
62 }
63 
Ref()64 void RenderDataStoreWeather::Ref()
65 {
66     refcnt_.fetch_add(1, std::memory_order_relaxed);
67 }
68 
Unref()69 void RenderDataStoreWeather::Unref()
70 {
71     if (std::atomic_fetch_sub_explicit(&refcnt_, 1, std::memory_order_release) == 1) {
72         std::atomic_thread_fence(std::memory_order_acquire);
73         delete this;
74     }
75 }
76 
GetRefCount()77 int32_t RenderDataStoreWeather::GetRefCount()
78 {
79     return refcnt_;
80 }
81 
Create(IRenderContext & renderContext,const char * name)82 BASE_NS::refcnt_ptr<IRenderDataStore> RenderDataStoreWeather::Create(IRenderContext& renderContext, const char* name)
83 {
84     return refcnt_ptr<IRenderDataStore>(new RenderDataStoreWeather(renderContext, name));
85 }
86 CORE3D_END_NAMESPACE()