1 /* 2 * Copyright (c) 2024 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_GRAPHIC_TEST_DIRECTOR_H 17 #define RS_GRAPHIC_TEST_DIRECTOR_H 18 19 #include "common/rs_rect.h" 20 #include "pixel_map.h" 21 #include "rs_graphic_rootnode.h" 22 #include "ui/rs_display_node.h" 23 #include "ui/rs_ui_director.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 class VSyncWaiter; 28 class RSGraphicTestDirector { 29 public: 30 ~RSGraphicTestDirector(); 31 32 void Run(); 33 void FlushMessage(); 34 std::shared_ptr<Media::PixelMap> TakeScreenCaptureAndWait(int ms); 35 void WaitForVSync(size_t count = 1); 36 void ResetImagePath(); 37 38 std::shared_ptr<RSGraphicRootNode> GetRootNode() const; 39 Vector2f GetScreenSize() const; 40 void SetSurfaceBounds(const Vector4f& bounds); 41 void SetSurfaceColor(const RSColor& color); 42 43 static RSGraphicTestDirector& Instance(); 44 45 private: 46 ScreenId screenId_ = 0; 47 RectF screenBounds_; 48 std::shared_ptr<RSGraphicRootNode> rootNode_; 49 std::shared_ptr<RSUIDirector> rsUiDirector_; 50 51 std::shared_ptr<OHOS::AppExecFwk::EventRunner> runner_; 52 std::shared_ptr<OHOS::AppExecFwk::EventHandler> handler_; 53 std::shared_ptr<VSyncWaiter> vsyncWaiter_; 54 55 friend class RSGraphicTest; 56 }; 57 58 } // namespace Rosen 59 } // namespace OHOS 60 61 #endif // RS_GRAPHIC_TEST_DIRECTOR_H 62