• 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_TEST_TREE_H
17 #define RENDER_SERVICE_TEST_TREE_H
18 
19 #include <memory>
20 
21 #include "common/rs_color.h"
22 #include "common/rs_common_def.h"
23 #include "pipeline/rs_context.h"
24 #include "pipeline/rs_render_node.h"
25 
26 namespace OHOS::Rosen {
27 class TestTreeBuilder {
28 public:
29     TestTreeBuilder();
30     std::vector<std::shared_ptr<RSRenderNode>> Build(RSContext& context, NodeId topId, bool withDisplay,
31         bool withScreenNode = false, bool withPatchedGlobalRoot = false);
32 
33 private:
34     inline static const int startX = 200;
35     inline static const int startY = 1200;
36     inline static const int width = 900;
37     inline static const int height = 900;
38     inline static const int width13 = width / 3;
39     inline static const int width23 = 2 * width / 3;
40     inline static const int height13 = height / 3;
41     inline static const int height23 = 2 * height / 3;
42     inline static const int zero = 0;
43     inline static const int one = 1;
44     inline static const int two = 2;
45     inline static const int three = 3;
46     inline static const int four = 4;
47     inline static const int five = 5;
48     inline static const int visibleZPosition = 5000;
49     const Color almostWhite_ = Color(240, 240, 240, 255);
50     std::mt19937 mt_;
51     std::uniform_int_distribution<uint8_t> distribution_;
52     Drawing::Image GenerateRandomImage(int width, int height);
53     NodeId insideId_;
54     bool withDisplay_;
55     bool withScreenNode_;
56     bool withPatchedGlobalRoot_;
57     void CreateNode00(RSContext& context, std::vector<std::shared_ptr<RSRenderNode>>& tree);
58     void CreateNode01(RSContext& context, std::vector<std::shared_ptr<RSRenderNode>>& tree);
59     void CreateNode02(RSContext& context, std::vector<std::shared_ptr<RSRenderNode>>& tree);
60     void CreateNode03(RSContext& context, std::vector<std::shared_ptr<RSRenderNode>>& tree);
61     void CreateNode04(RSContext& context, std::vector<std::shared_ptr<RSRenderNode>>& tree);
62     void CreateNode05(RSContext& context, std::vector<std::shared_ptr<RSRenderNode>>& tree);
63     void CreateNode06(RSContext& context, std::vector<std::shared_ptr<RSRenderNode>>& tree);
64     void CreateNode07(RSContext& context, std::vector<std::shared_ptr<RSRenderNode>>& tree);
65     void CreateNode08(RSContext& context, std::vector<std::shared_ptr<RSRenderNode>>& tree);
66 };
67 } // namespace OHOS::Rosen
68 
69 #endif // RENDER_SERVICE_TEST_TREE_H