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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_VIEW_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_VIEW_H 18 19 #include <memory> 20 #include <mutex> 21 22 #include "custom/custom_render_descriptor.h" 23 #include "custom/shader_input_buffer.h" 24 #include "data_type/constants.h" 25 #include "data_type/geometry/geometry.h" 26 #include "data_type/gltf_animation.h" 27 #include "data_type/light.h" 28 #include "data_type/position.h" 29 30 #include "base/geometry/animatable_float.h" 31 #include "base/geometry/quaternion.h" 32 #include "base/geometry/vec3.h" 33 #include "base/memory/referenced.h" 34 #include "base/utils/utils.h" 35 36 #if defined(KIT_3D_ENABLE) 37 #include "scene_adapter/intf_scene_adapter.h" 38 #endif 39 40 namespace OHOS::Ace { 41 42 struct ModelViewContext { 43 std::string bundleName_; 44 std::string moduleName_; 45 Render3D::SurfaceType surfaceType_; 46 #if defined(KIT_3D_ENABLE) 47 std::shared_ptr<Render3D::ISceneAdapter> sceneAdapter_ = nullptr; 48 #endif 49 }; 50 51 class ModelView { 52 public: 53 static ModelView* GetInstance(); 54 virtual ~ModelView() = default; 55 virtual void Create(const ModelViewContext& context) = 0; 56 virtual void SetBackground(const std::string& src) = 0; 57 virtual void SetModelSource(const std::string& src) = 0; 58 virtual void SetHandleCameraMove(bool value) = 0; 59 virtual void AddCustomRender(const std::shared_ptr<Render3D::CustomRenderDescriptor>& customRender) = 0; 60 virtual void SetRenderWidth(Dimension& width) = 0; 61 virtual void SetRenderHeight(Dimension& height) = 0; 62 virtual void SetRenderFrameRate(float rate) = 0; 63 virtual void SetShader(const std::string& path) = 0; 64 virtual void AddShaderImageTexture(const std::string& path) = 0; 65 virtual void AddShaderInputBuffer(const std::shared_ptr<Render3D::ShaderInputBuffer>& buffer) = 0; 66 virtual std::optional<std::shared_ptr<Render3D::ShaderInputBuffer>> GetShaderInputBuffer() = 0; 67 68 private: 69 static std::unique_ptr<ModelView> instance_; 70 static std::mutex mutex_; 71 }; 72 73 } // namespace OHOS::Ace 74 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_VIEW_H 75