• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_RENDER_SURFACE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_RENDER_SURFACE_H
18 
19 #include <cstdint>
20 #include <stdint.h>
21 
22 #include "base/geometry/axis.h"
23 #include "base/memory/ace_type.h"
24 #include "base/utils/noncopyable.h"
25 #include "core/components_ng/render/ext_surface_callback_interface.h"
26 #include "core/components_ng/render/render_context.h"
27 
28 namespace OHOS::Ace::NG {
29 // RenderSurface is used for SurfaceNode
30 class ACE_FORCE_EXPORT RenderSurface : public virtual AceType {
31     DECLARE_ACE_TYPE(NG::RenderSurface, AceType)
32 
33 public:
34     RenderSurface() = default;
35     ~RenderSurface() override = default;
36 
37 // under the condition of supporting cross platform and texture rendering,
38 // it is necessary to dynamically set the rendering type of the surface node.
39 // the defalut type is RenderSurfaceType::TEXTURE.
40 #ifdef RENDER_EXTRACT_SUPPORTED
41     enum class RenderSurfaceType {
42         UNKNOWN = -1,
43         SURFACE = 0,
44         TEXTURE
45     };
46     static RefPtr<RenderSurface> Create(const RenderSurfaceType& type = RenderSurfaceType::TEXTURE);
47 #else
48 // under the condition of supporting ohos platform
49     static RefPtr<RenderSurface> Create();
50 #endif
51 
InitSurface()52     virtual void InitSurface() {}
53 
UpdateSurfaceConfig()54     virtual void UpdateSurfaceConfig() {}
55 
GetNativeWindow()56     virtual void* GetNativeWindow()
57     {
58         return nullptr;
59     }
60 
SetRenderContext(const RefPtr<RenderContext> & renderContext)61     virtual void SetRenderContext(const RefPtr<RenderContext>& renderContext) {};
62 
ConfigSurface(uint32_t surfaceWidth,uint32_t surfaceHeight)63     virtual void ConfigSurface(uint32_t surfaceWidth, uint32_t surfaceHeight) {};
64 
IsSurfaceValid()65     virtual bool IsSurfaceValid() const
66     {
67         return false;
68     }
69 
CreateNativeWindow()70     virtual void CreateNativeWindow() {};
71 
AdjustNativeWindowSize(uint32_t width,uint32_t height)72     virtual void AdjustNativeWindowSize(uint32_t width, uint32_t height) {}
73 
GetUniqueId()74     virtual std::string GetUniqueId() const
75     {
76         return "";
77     }
78 
UpdateSurfaceSizeInUserData(uint32_t width,uint32_t height)79     virtual void UpdateSurfaceSizeInUserData(uint32_t width, uint32_t height) {}
80 
SetExtSurfaceBounds(int32_t left,int32_t top,int32_t width,int32_t height)81     virtual void SetExtSurfaceBounds(int32_t left, int32_t top, int32_t width, int32_t height) {}
82 
SetExtSurfaceBoundsSync(int32_t left,int32_t top,int32_t width,int32_t height)83     virtual bool SetExtSurfaceBoundsSync(int32_t left, int32_t top, int32_t width, int32_t height)
84     {
85         return true;
86     }
87 
SetExtSurfaceCallback(const RefPtr<ExtSurfaceCallbackInterface> & extSurfaceCallback)88     virtual void SetExtSurfaceCallback(const RefPtr<ExtSurfaceCallbackInterface>& extSurfaceCallback) {}
89 
SetTransformHint(uint32_t rotation)90     virtual void SetTransformHint(uint32_t rotation) {}
91 
DumpInfo()92     virtual void DumpInfo() {}
93 
DumpInfo(std::unique_ptr<JsonValue> & json)94     virtual void DumpInfo(std::unique_ptr<JsonValue>& json) {}
95 
SetIsTexture(bool isTexture)96     virtual void SetIsTexture(bool isTexture) {}
97 
SetIsFullScreen(bool isFullScreen)98     virtual void SetIsFullScreen(bool isFullScreen) {}
99 
SetInstanceId(int32_t instanceId)100     virtual void SetInstanceId(int32_t instanceId) {}
101 
SetSurfaceDefaultSize(int32_t width,int32_t height)102     virtual void SetSurfaceDefaultSize(int32_t width, int32_t height) {}
103 
IsTexture()104     virtual bool IsTexture()
105     {
106         return false;
107     }
108 
AttachToGLContext(int64_t textureId,bool isAttach)109     virtual void AttachToGLContext(int64_t textureId, bool isAttach) {}
110 
UpdateTextureImage(std::vector<float> & matrix)111     virtual void UpdateTextureImage(std::vector<float>& matrix) {}
112 
SetWebMessage(OffsetF offset)113     virtual void SetWebMessage(OffsetF offset) {}
114 
SetWebSlideAxis(Axis axis)115     virtual void SetWebSlideAxis(Axis axis) {}
116 
SetWebOffset(float webOffset)117     virtual void SetWebOffset(float webOffset) {}
118 
SetPatternType(const std::string & type)119     virtual void SetPatternType(const std::string& type) {}
120 
SetBufferUsage(const std::string & usage)121     virtual void SetBufferUsage(const std::string& usage) {}
122 
SetSurfaceQueueSize(int32_t queueSize)123     virtual void SetSurfaceQueueSize(int32_t queueSize) {}
124 
DrawBufferForXComponent(RSCanvas & canvas,float width,float height,float offsetX,float offsetY)125     virtual void DrawBufferForXComponent(RSCanvas& canvas, float width, float height, float offsetX, float offsetY) {};
126 
ReleaseSurfaceBuffers()127     virtual void ReleaseSurfaceBuffers() {}
128 
RegisterSurface()129     virtual void RegisterSurface() const {};
130 
UnregisterSurface()131     virtual void UnregisterSurface() const {};
132 
Connect()133     virtual void Connect() const {};
134 
Disconnect()135     virtual void Disconnect() const {};
136 
RegisterBufferCallback()137     virtual void RegisterBufferCallback() {}
138 
OnWindowStateChange(bool isShow)139     virtual void OnWindowStateChange(bool isShow) {}
140 
SetIsNeedSyncGeometryProperties(bool isNeedSyncGeometryProperties)141     virtual void SetIsNeedSyncGeometryProperties(bool isNeedSyncGeometryProperties) {}
142 
SetKeyBoardAvoidRect(RectF keyBoardAvoidRect)143     virtual void SetKeyBoardAvoidRect(RectF keyBoardAvoidRect) {}
144 
145 protected:
146     ACE_DISALLOW_COPY_AND_MOVE(RenderSurface);
147 };
148 } // namespace OHOS::Ace::NG
149 
150 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_RENDER_SURFACE_H
151