1 /* 2 * Copyright (c) 2021-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_PLATFORM_RS_SURFACE_OHOS_H 17 #define RENDER_SERVICE_BASE_PLATFORM_RS_SURFACE_OHOS_H 18 19 #include <surface.h> 20 21 #include "platform/drawing/rs_surface.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 class RenderContext; 26 class RSSurfaceOhos : public RSSurface { 27 public: RSSurfaceOhos(const sptr<Surface> & producer)28 RSSurfaceOhos(const sptr<Surface>& producer) : producer_(producer) 29 { 30 } 31 GetSurface()32 sptr<Surface> GetSurface() const 33 { 34 return producer_; 35 } 36 37 virtual RenderContext* GetRenderContext() override; 38 virtual void SetRenderContext(RenderContext* context) override; 39 virtual void SetColorSpace(GraphicColorGamut colorSpace) override; 40 virtual GraphicColorGamut GetColorSpace() const override; 41 virtual uint32_t GetQueueSize() const override; 42 43 virtual void SetSurfaceBufferUsage(uint64_t usage) = 0; 44 virtual void SetSurfacePixelFormat(int32_t pixelFormat) = 0; 45 virtual sptr<SurfaceBuffer> GetCurrentBuffer() = 0; 46 void ClearAllBuffer() override; 47 virtual void SetTimeOut(int32_t timeOut); 48 protected: 49 sptr<Surface> producer_; 50 RenderContext* context_ = nullptr; 51 GraphicColorGamut colorSpace_ = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB; 52 int32_t pixelFormat_ = GRAPHIC_PIXEL_FMT_RGBA_8888; 53 uint64_t bufferUsage_ = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA; 54 int32_t timeOut_ = 3000; // ms 55 }; 56 57 } // namespace Rosen 58 } // namespace OHOS 59 60 #endif // RENDER_SERVICE_BASE_PLATFORM_RS_SURFACE_OHOS_H 61