1 /* 2 * Copyright (c) 2024 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_resource.h" 17 18 #include <scene/ext/util.h> 19 20 #include <render/device/intf_gpu_resource_manager.h> 21 SCENE_BEGIN_NAMESPACE()22SCENE_BEGIN_NAMESPACE() 23 24 bool RenderResource::Build(const META_NS::IMetadata::Ptr& d) 25 { 26 auto res = Super::Build(d); 27 if (res) { 28 auto context = GetInterfaceBuildArg<IRenderContext>(d, "RenderContext"); 29 if (!context) { 30 CORE_LOG_E("Invalid arguments to construct RenderResource"); 31 return false; 32 } 33 context_ = context; 34 } 35 return res; 36 } 37 GetRenderHandle() const38RENDER_NS::RenderHandleReference RenderResource::GetRenderHandle() const 39 { 40 std::shared_lock lock { mutex_ }; 41 return handle_; 42 } 43 44 SCENE_END_NAMESPACE() 45