1 /* 2 * Copyright (c) 2023-2025 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_RENDER_ADAPTER_RENDER_SURFACE_IMPL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_RENDER_SURFACE_IMPL_H 18 19 #include <cstdint> 20 21 #include "base/memory/referenced.h" 22 #include "base/utils/noncopyable.h" 23 #include "core/components/video/resource/ext_surface.h" 24 #include "core/components_ng/render/ext_surface_callback_interface.h" 25 #include "core/components_ng/render/render_surface.h" 26 27 namespace OHOS::Ace::NG { 28 29 class RenderSurfaceImpl : public RenderSurface { 30 DECLARE_ACE_TYPE(RenderSurfaceImpl, NG::RenderSurface); 31 public: 32 RenderSurfaceImpl() = default; 33 ~RenderSurfaceImpl() override; 34 35 void InitSurface() override; 36 37 void UpdateSurfaceConfig() override; 38 39 void* GetNativeWindow() override; 40 41 void SetRenderContext(const RefPtr<RenderContext>& renderContext) override; 42 43 void ConfigSurface(uint32_t surfaceWidth, uint32_t surfaceHeight) override; 44 45 bool IsSurfaceValid() const override; 46 47 void CreateNativeWindow() override; 48 49 void AdjustNativeWindowSize(uint32_t width, uint32_t height) override; 50 51 std::string GetUniqueId() const override; 52 SetSurfaceId(int64_t id)53 void SetSurfaceId(int64_t id) 54 { 55 surfaceId_ = id; 56 } 57 GetSurfaceId()58 int64_t GetSurfaceId() const 59 { 60 return surfaceId_; 61 } 62 63 void SetExtSurfaceBounds(int32_t left, int32_t top, int32_t width, int32_t height) override; 64 65 bool SetExtSurfaceBoundsSync(int32_t left, int32_t top, int32_t width, int32_t height) override; 66 67 void SetExtSurfaceCallback(const RefPtr<ExtSurfaceCallbackInterface>& extSurfaceCallback) override; 68 69 void SetIsFullScreen(bool isFullScreen) override; 70 #ifdef RENDER_EXTRACT_SUPPORTED 71 void SetSurfaceRotation(bool isLock); 72 73 void SetSurfaceRect(float positionX, float positionY, float width, float height); 74 #endif 75 private: 76 WeakPtr<NG::RenderContext> renderContext_; 77 RefPtr<ExtSurface> extSurface_; 78 RefPtr<ExtSurfaceCallbackInterface> extSurfaceCallback_; 79 int64_t surfaceId_ = -1; 80 void* nativeWindow_ = nullptr; 81 bool isSetConfigSurface_ = false; 82 Rect lastRect_; 83 84 ACE_DISALLOW_COPY_AND_MOVE(RenderSurfaceImpl); 85 }; 86 87 } // namespace OHOS::Ace::NG 88 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_RENDER_SURFACE_IMPL_H 89