• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_CLIENT_CORE_TRANSACTION_RS_INTERFACES_H
17 #define RENDER_SERVICE_CLIENT_CORE_TRANSACTION_RS_INTERFACES_H
18 
19 #include <memory>
20 
21 #include "transaction/rs_render_service_client.h"
22 #include "ui/rs_display_node.h"
23 #include "ui/rs_surface_node.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 class RS_EXPORT RSInterfaces {
28 public:
29     static RSInterfaces &GetInstance();
30     RSInterfaces(const RSInterfaces &) = delete;
31     void operator=(const RSInterfaces &) = delete;
32 
33     ScreenId GetDefaultScreenId();
34 
35     // mirrorId: decide which screen id to mirror, INVALID_SCREEN_ID means do not mirror any screen.
36     ScreenId CreateVirtualScreen(
37         const std::string &name,
38         uint32_t width,
39         uint32_t height,
40         sptr<Surface> surface,
41         ScreenId mirrorId = 0,
42         int flags = 0);
43 
44     int32_t SetVirtualScreenSurface(ScreenId id, sptr<Surface> surface);
45 
46     void RemoveVirtualScreen(ScreenId id);
47 
48     int32_t SetScreenChangeCallback(const ScreenChangeCallback &callback);
49 
50     bool TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node,
51         std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX = 1.0f, float scaleY = 1.0f);
52 
53     bool TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node,
54         std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX = 1.0f, float scaleY = 1.0f);
55 
56     void SetScreenActiveMode(ScreenId id, uint32_t modeId);
57 
58     void SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status);
59 
60     RSScreenModeInfo GetScreenActiveMode(ScreenId id);
61 
62     std::vector<RSScreenModeInfo> GetScreenSupportedModes(ScreenId id);
63 
64     RSScreenCapability GetScreenCapability(ScreenId id);
65 
66     ScreenPowerStatus GetScreenPowerStatus(ScreenId id);
67 
68     RSScreenData GetScreenData(ScreenId id);
69 
70     int32_t GetScreenBacklight(ScreenId id);
71 
72     void SetScreenBacklight(ScreenId id, uint32_t level);
73 
74     int32_t GetScreenSupportedColorGamuts(ScreenId id, std::vector<ScreenColorGamut>& mode);
75 
76     int32_t GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode);
77 
78     int32_t SetScreenColorGamut(ScreenId id, int32_t modeIdx);
79 
80     int32_t SetScreenGamutMap(ScreenId id, ScreenGamutMap mode);
81 
82     int32_t GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode);
83 
84     bool RequestRotation(ScreenId id, ScreenRotation rotation);
85 
86     ScreenRotation GetRotation(ScreenId id);
87 
88     std::shared_ptr<VSyncReceiver> CreateVSyncReceiver(
89         const std::string& name,
90         const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper = nullptr);
91 
92 private:
93     RSInterfaces();
94     ~RSInterfaces() noexcept;
95 
96     std::unique_ptr<RSRenderServiceClient> renderServiceClient_;
97 };
98 } // namespace Rosen
99 } // namespace OHOS
100 
101 #endif // RENDER_SERVICE_CLIENT_CORE_TRANSACTION_RS_INTERFACES_H
102