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_SURFACE_FRAME_OHOS_VULKAN_H
17 #define RS_SURFACE_FRAME_OHOS_VULKAN_H
18 
19 #include <surface.h>
20 
21 #include "include/gpu/GrDirectContext.h"
22 
23 #include "platform/ohos/rs_surface_frame_ohos.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 
28 class RSSurfaceFrameOhosVulkan : public RSSurfaceFrameOhos {
29 public:
30     RSSurfaceFrameOhosVulkan(std::shared_ptr<Drawing::Surface> surface, int32_t width,
31         int32_t height, int32_t bufferAge);
32     ~RSSurfaceFrameOhosVulkan() override = default;
33 
34     Drawing::Canvas* GetCanvas() override;
35     std::shared_ptr<Drawing::Surface> GetSurface() override;
36     void SetDamageRegion(int32_t left, int32_t top, int32_t width, int32_t height) override;
37     void SetDamageRegion(const std::vector<RectI>& rects) override;
38     int32_t GetReleaseFence() const;
39     void SetReleaseFence(const int32_t& fence);
40     int32_t GetBufferAge() const override;
41 
42 private:
43     int32_t releaseFence_ = 0;
44     std::shared_ptr<Drawing::Surface> surface_;
45     int width_ = 0;
46     int height_ = 0;
47     int32_t bufferAge_ = -1;
48     void CreateCanvas();
49 };
50 } // namespace Rosen
51 } // namespace OHOS
52 
53 #endif // RENDER_SERVICE_BASE_PLATFORM_RS_SURFACE_FRAME_OHOS_H
54