• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_GFX_FIRST_FRAME_NOTIFIER_RS_FIRST_FRAME_NOTIFIER_H
17 #define RENDER_SERVICE_BASE_GFX_FIRST_FRAME_NOTIFIER_RS_FIRST_FRAME_NOTIFIER_H
18 
19 #include <array>
20 #include <mutex>
21 #include <shared_mutex>
22 #include <string>
23 
24 #include "common/rs_common_def.h"
25 #include "ipc_callbacks/rs_ifirst_frame_commit_callback.h"
26 #include "screen_manager/screen_types.h"
27 
28 namespace OHOS::Rosen {
29 class RSB_EXPORT RSFirstFrameNotifier {
30 public:
31     static RSFirstFrameNotifier &GetInstance();
32     void RegisterFirstFrameCommitCallback(pid_t pid, const sptr<RSIFirstFrameCommitCallback>& callback);
33     void OnFirstFrameCommitCallback(ScreenId screenId);
34     void ExecIfFirstFrameCommit(ScreenId screenId);
35     void AddFirstFrameCommitScreen(ScreenId screenId);
36 private:
37     RSFirstFrameNotifier() = default;
38     ~RSFirstFrameNotifier() = default;
39     RSFirstFrameNotifier(const RSFirstFrameNotifier&) = delete;
40     RSFirstFrameNotifier(const RSFirstFrameNotifier&&) = delete;
41     RSFirstFrameNotifier& operator=(const RSFirstFrameNotifier&) = delete;
42     RSFirstFrameNotifier& operator=(const RSFirstFrameNotifier&&) = delete;
43 
44     std::mutex screensMutex_;
45     std::unordered_set<ScreenId> firstFrameCommitScreens_;
46 
47     std::shared_mutex callbacksMutex_;
48     std::unordered_map<pid_t, sptr<RSIFirstFrameCommitCallback>> firstFrameCommitCallbacks_;
49 };
50 }
51 #endif