• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DRAWING_RS_SURFACE_H
17 #define RENDER_SERVICE_BASE_DRAWING_RS_SURFACE_H
18 
19 #include <memory>
20 
21 #include "rs_surface_frame.h"
22 #ifndef ROSEN_CROSS_PLATFORM
23 #include "surface_type.h"
24 #endif
25 
26 namespace OHOS {
27 namespace Rosen {
28 class RenderContext;
29 class RSSurface {
30 public:
31     RSSurface() = default;
32 
33     virtual ~RSSurface() = default;
34 
35     virtual bool IsValid() const = 0;
36 
37     virtual void SetUiTimeStamp(const std::unique_ptr<RSSurfaceFrame>& frame, uint64_t uiTimestamp = 0) = 0;
38 
39     virtual std::unique_ptr<RSSurfaceFrame> RequestFrame(
40         int32_t width, int32_t height, uint64_t uiTimestamp = 0, bool useAFBC = true) = 0;
41 
42     virtual bool FlushFrame(std::unique_ptr<RSSurfaceFrame>& frame, uint64_t uiTimestamp = 0) = 0;
43 
44     virtual RenderContext* GetRenderContext() = 0;
45     virtual void SetRenderContext(RenderContext* context) = 0;
46 #ifndef ROSEN_CROSS_PLATFORM
47     virtual GraphicColorGamut GetColorSpace() const = 0;
48     virtual void SetColorSpace(GraphicColorGamut colorSpace) = 0;
49 #endif
50     virtual uint32_t GetQueueSize() const = 0;
51     virtual void ClearBuffer() = 0; // clear cache only for producer
52 
53     // clear buffer for both producer and consumer and will receive OnGoBackground callback
54     virtual void ClearAllBuffer() = 0;
55     virtual void ResetBufferAge() = 0;
56 protected:
57 private:
58 };
59 
60 } // namespace Rosen
61 } // namespace OHOS
62 
63 #endif // RENDER_SERVICE_BASE_DRAWING_RS_SURFACE_H
64