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 RS_RENDER_SURFACE_OHOS_H 17 #define RS_RENDER_SURFACE_OHOS_H 18 19 #include <memory> 20 21 #include "include/core/SkCanvas.h" 22 #include "include/core/SkSurface.h" 23 24 #include "common/rs_rect.h" 25 26 #include "rs_render_surface.h" 27 #include "rs_render_surface_frame.h" 28 29 namespace OHOS { 30 namespace Rosen { 31 class RSRenderSurfaceOhos : public RSRenderSurface { 32 public: 33 explicit RSRenderSurfaceOhos(const sptr<Surface>& surface, const std::shared_ptr<DrawingContext>& drawingContext); 34 ~RSRenderSurfaceOhos(); 35 bool IsValid() const override; 36 sptr<Surface> GetSurfaceOhos() const; 37 uint32_t GetQueueSize() const override; 38 std::shared_ptr<RSRenderSurfaceFrame> RequestFrame( 39 int32_t width, int32_t height, uint64_t uiTimestamp = 0, bool useAFBC = true) override; 40 bool FlushFrame(uint64_t uiTimestamp = 0) override; 41 void SetUiTimeStamp(uint64_t uiTimestamp = 0) override; 42 void SetDamageRegion(const std::vector<RectI> &rects) override; 43 int32_t GetBufferAge() override; 44 void ClearBuffer() override; 45 SkCanvas* GetCanvas() override; 46 sk_sp<SkSurface> GetSurface() override; 47 GraphicColorGamut GetColorSpace() override; 48 void SetColorSpace(GraphicColorGamut colorSpace) override; 49 void SetSurfaceBufferUsage(uint64_t usage); 50 void SetSurfacePixelFormat(uint64_t pixelFormat); GetCurrentBuffer()51 sptr<SurfaceBuffer> GetCurrentBuffer() 52 { 53 return nullptr; 54 } 55 private: 56 void RenderFrame(); 57 void SetReleaseFence(const int32_t& fence); 58 int32_t GetReleaseFence() const; 59 }; 60 } 61 } // namespace Rosen 62 #endif