• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ROSEN_RENDER_SERVICE_BASE_BENCHMARKS_RS_RECORDING_THREAD_H
17 #define ROSEN_RENDER_SERVICE_BASE_BENCHMARKS_RS_RECORDING_THREAD_H
18 
19 
20 #ifndef USE_ROSEN_DRAWING
21 #include "pipeline/rs_draw_cmd_list.h"
22 #else
23 #include "common/rs_common_def.h"
24 #include "common/rs_macros.h"
25 #include "recording/draw_cmd_list.h"
26 #endif
27 
28 #include <sys/stat.h>
29 
30 #include "event_handler.h"
31 
32 namespace OHOS::Rosen {
33 class RSB_EXPORT RSRecordingThread {
34 public:
35     const static size_t RECORDING_PARCEL_MAX_CAPCITY = 234 * 1000 * 1024;
36 
37     static RSRecordingThread& Instance();
38     void Start();
39     void PostTask(const std::function<void()> & task);
40     bool CheckAndRecording();
41     void FinishRecordingOneFrame();
42 #ifndef USE_ROSEN_DRAWING
43     void RecordingToFile(const std::shared_ptr<DrawCmdList> & drawCmdList);
44 #else
45     void RecordingToFile(const std::shared_ptr<Drawing::DrawCmdList> & drawCmdList);
46 #endif
GetCurDumpFrame()47     [[nodiscard]] int GetCurDumpFrame() const
48     {
49         return curDumpFrame_;
50     }
51 
52 private:
53     RSRecordingThread() = default;
54     ~RSRecordingThread() = default;
55 
56     std::shared_ptr<AppExecFwk::EventRunner> runner_ = nullptr;
57     std::shared_ptr<AppExecFwk::EventHandler> handler_ = nullptr;
58     std::string fileDir_ = "/data/";
59     bool isRecordingEnabled_ = false;
60     int dumpFrameNum_ = 0;
61     int curDumpFrame_ = 0;
62 };
63 } // namespace OHOS::Rosen
64 
65 #endif // ROSEN_RENDER_SERVICE_BASE_BENCHMARKS_RS_RECORDING_THREAD_H