1 /* 2 * Copyright (c) 2023 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 RENDER_SERVICE_BASE_COMMON_RS_SURFACE_EXT_H 17 #define RENDER_SERVICE_BASE_COMMON_RS_SURFACE_EXT_H 18 #include <functional> 19 #include <limits> 20 #include <memory> 21 #include <string> 22 #include <unistd.h> 23 24 #ifndef USE_ROSEN_DRAWING 25 #include "include/core/SkImage.h" 26 #else 27 #include "image/image.h" 28 #endif 29 30 namespace OHOS { 31 namespace Rosen { 32 class RSPaintFilterCanvas; 33 class RSSurfaceExt : public std::enable_shared_from_this<RSSurfaceExt> { 34 public: 35 static inline constexpr RSSurfaceExtType Type = RSSurfaceExtType::NONE; GetType()36 RSSurfaceExtType GetType() const 37 { 38 return Type; 39 } 40 RSSurfaceExt() = default; 41 virtual ~RSSurfaceExt() = default; 42 43 RSSurfaceExt(const RSSurfaceExt&) = delete; 44 RSSurfaceExt(const RSSurfaceExt&&) = delete; 45 RSSurfaceExt& operator=(const RSSurfaceExt&) = delete; 46 RSSurfaceExt& operator=(const RSSurfaceExt&&) = delete; 47 48 #ifdef USE_SURFACE_TEXTURE 49 #ifndef USE_ROSEN_DRAWING 50 virtual void DrawTextureImage(RSPaintFilterCanvas& canvas, bool freeze, const SkRect& clipRect) = 0; 51 #else 52 virtual void DrawTextureImage(RSPaintFilterCanvas& canvas, bool freeze, const Drawing::Rect& clipRect) = 0; 53 #endif 54 virtual void UpdateSurfaceDefaultSize(float width, float height) = 0; 55 virtual void SetAttachCallback(const RSSurfaceTextureAttachCallBack& attachCallback) = 0; 56 virtual void SetUpdateCallback(const RSSurfaceTextureUpdateCallBack& updateCallback) = 0; 57 virtual void MarkUiFrameAvailable(bool available) = 0; 58 virtual bool IsUiFrameAvailable() const = 0; 59 #endif 60 }; 61 62 #ifdef USE_SURFACE_TEXTURE 63 using RSSurfaceTexture = RSSurfaceExt; 64 #endif 65 } 66 } 67 #endif // #define RENDER_SERVICE_BASE_COMMON_RS_SURFACE_EXT_H 68 69