18bf80f4bSopenharmony_ci/* 28bf80f4bSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 38bf80f4bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48bf80f4bSopenharmony_ci * you may not use this file except in compliance with the License. 58bf80f4bSopenharmony_ci * You may obtain a copy of the License at 68bf80f4bSopenharmony_ci * 78bf80f4bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88bf80f4bSopenharmony_ci * 98bf80f4bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108bf80f4bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118bf80f4bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128bf80f4bSopenharmony_ci * See the License for the specific language governing permissions and 138bf80f4bSopenharmony_ci * limitations under the License. 148bf80f4bSopenharmony_ci */ 158bf80f4bSopenharmony_ci 168bf80f4bSopenharmony_ci#ifndef OHOS_RENDER_3D_WIDGET_ADAPTER_H 178bf80f4bSopenharmony_ci#define OHOS_RENDER_3D_WIDGET_ADAPTER_H 188bf80f4bSopenharmony_ci 198bf80f4bSopenharmony_ci#include <memory> 208bf80f4bSopenharmony_ci#include <EGL/egl.h> 218bf80f4bSopenharmony_ci#include <GLES/gl.h> 228bf80f4bSopenharmony_ci 238bf80f4bSopenharmony_ci#include "i_engine.h" 248bf80f4bSopenharmony_ci#include "data_type/constants.h" 258bf80f4bSopenharmony_ci#include "data_type/geometry/geometry.h" 268bf80f4bSopenharmony_ci#include "data_type/geometry/cube.h" 278bf80f4bSopenharmony_ci#include "data_type/geometry/sphere.h" 288bf80f4bSopenharmony_ci#include "data_type/geometry/cone.h" 298bf80f4bSopenharmony_ci#include "data_type/gltf_animation.h" 308bf80f4bSopenharmony_ci#include "data_type/pointer_event.h" 318bf80f4bSopenharmony_ci 328bf80f4bSopenharmony_cinamespace OHOS::Render3D { 338bf80f4bSopenharmony_ci 348bf80f4bSopenharmony_ciclass __attribute__((visibility("default"))) WidgetAdapter { 358bf80f4bSopenharmony_cipublic: 368bf80f4bSopenharmony_ci explicit WidgetAdapter(uint32_t key); 378bf80f4bSopenharmony_ci virtual ~WidgetAdapter(); 388bf80f4bSopenharmony_ci void DeInitEngine(); 398bf80f4bSopenharmony_ci WidgetAdapter(const WidgetAdapter&) = delete; 408bf80f4bSopenharmony_ci WidgetAdapter& operator=(const WidgetAdapter&) = delete; 418bf80f4bSopenharmony_ci 428bf80f4bSopenharmony_ci bool Initialize(std::unique_ptr<IEngine> engine); 438bf80f4bSopenharmony_ci bool OnWindowChange(const TextureInfo& textureInfo); 448bf80f4bSopenharmony_ci 458bf80f4bSopenharmony_ci bool SetupCameraTransform(const OHOS::Render3D::Position& position, const OHOS::Render3D::Vec3& lookAt, 468bf80f4bSopenharmony_ci const OHOS::Render3D::Vec3& up, const OHOS::Render3D::Quaternion& rotation); 478bf80f4bSopenharmony_ci bool SetupCameraViewProjection(float zNear, float zFar, float fovDegrees); 488bf80f4bSopenharmony_ci bool SetupCameraViewport(uint32_t width, uint32_t height); 498bf80f4bSopenharmony_ci 508bf80f4bSopenharmony_ci bool OnTouchEvent(const PointerEvent& event); 518bf80f4bSopenharmony_ci bool NeedsRepaint(); 528bf80f4bSopenharmony_ci 538bf80f4bSopenharmony_ci bool DrawFrame(); 548bf80f4bSopenharmony_ci bool UpdateGeometries(const std::vector<std::shared_ptr<Geometry>>& shapes); 558bf80f4bSopenharmony_ci bool UpdateGLTFAnimations(const std::vector<std::shared_ptr<GLTFAnimation>>& animations); 568bf80f4bSopenharmony_ci 578bf80f4bSopenharmony_ci bool UpdateLights(const std::vector<std::shared_ptr<OHOS::Render3D::Light>>& lights); 588bf80f4bSopenharmony_ci bool UpdateCustomRender(const std::shared_ptr<CustomRenderDescriptor>& customRender); 598bf80f4bSopenharmony_ci bool UpdateShaderPath(const std::string& shaderPath); 608bf80f4bSopenharmony_ci bool UpdateImageTexturePaths(const std::vector<std::string>& imageTextures); 618bf80f4bSopenharmony_ci bool UpdateShaderInputBuffer(const std::shared_ptr<OHOS::Render3D::ShaderInputBuffer>& shaderInputBuffer); 628bf80f4bSopenharmony_ci 638bf80f4bSopenharmony_ci bool LoadSceneModel(const std::string& scene); 648bf80f4bSopenharmony_ci bool LoadEnvModel(const std::string& enviroment, BackgroundType type); 658bf80f4bSopenharmony_ci bool UnloadSceneModel(); 668bf80f4bSopenharmony_ci bool UnloadEnvModel(); 678bf80f4bSopenharmony_ci 688bf80f4bSopenharmony_ciprivate: 698bf80f4bSopenharmony_ci std::unique_ptr<IEngine> engine_ = nullptr; 708bf80f4bSopenharmony_ci uint32_t key_; 718bf80f4bSopenharmony_ci}; 728bf80f4bSopenharmony_ci} // namespace OHOS::Render3D 738bf80f4bSopenharmony_ci#endif // OHOS_RENDER_3D_WIDGET_ADAPTER_H 74