From 1a7505deee3b3aedf86f0e9789b000ffdcd77636 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Sat, 17 Dec 2022 11:53:18 -0800 Subject: [PATCH] [Impeller] Move GetSecondsElapsed to Playground (flutter/engine#38375) --- .../flutter/impeller/playground/compute_playground_test.cc | 4 ---- .../flutter/impeller/playground/compute_playground_test.h | 4 ---- engine/src/flutter/impeller/playground/playground.cc | 7 +++++++ engine/src/flutter/impeller/playground/playground.h | 7 +++++++ engine/src/flutter/impeller/playground/playground_test.cc | 6 ------ engine/src/flutter/impeller/playground/playground_test.h | 7 ------- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/engine/src/flutter/impeller/playground/compute_playground_test.cc b/engine/src/flutter/impeller/playground/compute_playground_test.cc index fce9088ddd..165a6f9ca8 100644 --- a/engine/src/flutter/impeller/playground/compute_playground_test.cc +++ b/engine/src/flutter/impeller/playground/compute_playground_test.cc @@ -62,8 +62,4 @@ std::string ComputePlaygroundTest::GetWindowTitle() const { return FormatWindowTitle(flutter::testing::GetCurrentTestName()); } -Scalar ComputePlaygroundTest::GetSecondsElapsed() const { - return (fml::TimePoint::Now().ToEpochDelta() - start_time_).ToSecondsF(); -} - } // namespace impeller diff --git a/engine/src/flutter/impeller/playground/compute_playground_test.h b/engine/src/flutter/impeller/playground/compute_playground_test.h index 93cff4ce2f..06c480b5be 100644 --- a/engine/src/flutter/impeller/playground/compute_playground_test.h +++ b/engine/src/flutter/impeller/playground/compute_playground_test.h @@ -36,10 +36,6 @@ class ComputePlaygroundTest // |Playground| std::string GetWindowTitle() const override; - /// @brief Get the amount of time elapsed from the start of the playground - /// test's execution. - Scalar GetSecondsElapsed() const; - private: fml::TimeDelta start_time_; diff --git a/engine/src/flutter/impeller/playground/playground.cc b/engine/src/flutter/impeller/playground/playground.cc index e402568592..f33d4697a1 100644 --- a/engine/src/flutter/impeller/playground/playground.cc +++ b/engine/src/flutter/impeller/playground/playground.cc @@ -7,6 +7,7 @@ #include #include +#include "fml/time/time_point.h" #include "impeller/image/decompressed_image.h" #include "impeller/renderer/command_buffer.h" #include "impeller/runtime_stage/runtime_stage.h" @@ -126,6 +127,8 @@ void Playground::SetupWindow() { return; } renderer_ = std::move(renderer); + + start_time_ = fml::TimePoint::Now().ToEpochDelta(); } void Playground::TeardownWindow() { @@ -165,6 +168,10 @@ Point Playground::GetContentScale() const { return impl_->GetContentScale(); } +Scalar Playground::GetSecondsElapsed() const { + return (fml::TimePoint::Now().ToEpochDelta() - start_time_).ToSecondsF(); +} + void Playground::SetCursorPosition(Point pos) { cursor_position_ = pos; } diff --git a/engine/src/flutter/impeller/playground/playground.h b/engine/src/flutter/impeller/playground/playground.h index 842c988394..1bc94570d0 100644 --- a/engine/src/flutter/impeller/playground/playground.h +++ b/engine/src/flutter/impeller/playground/playground.h @@ -8,6 +8,7 @@ #include "flutter/fml/closure.h" #include "flutter/fml/macros.h" +#include "flutter/fml/time/time_delta.h" #include "impeller/geometry/point.h" #include "impeller/renderer/renderer.h" @@ -50,6 +51,10 @@ class Playground { Point GetContentScale() const; + /// @brief Get the amount of time elapsed from the start of the playground's + /// execution. + Scalar GetSecondsElapsed() const; + std::shared_ptr GetContext() const; bool OpenPlaygroundHere(const Renderer::RenderCallback& render_callback); @@ -80,6 +85,8 @@ class Playground { static const bool is_enabled_ = false; #endif // IMPELLER_ENABLE_PLAYGROUND + fml::TimeDelta start_time_; + struct GLFWInitializer; std::unique_ptr glfw_initializer_; std::unique_ptr impl_; diff --git a/engine/src/flutter/impeller/playground/playground_test.cc b/engine/src/flutter/impeller/playground/playground_test.cc index 6773e22a08..9db2c3a2ee 100644 --- a/engine/src/flutter/impeller/playground/playground_test.cc +++ b/engine/src/flutter/impeller/playground/playground_test.cc @@ -25,8 +25,6 @@ void PlaygroundTest::SetUp() { SetupContext(GetParam()); SetupWindow(); - - start_time_ = fml::TimePoint::Now().ToEpochDelta(); } void PlaygroundTest::TearDown() { @@ -63,8 +61,4 @@ std::string PlaygroundTest::GetWindowTitle() const { return FormatWindowTitle(flutter::testing::GetCurrentTestName()); } -Scalar PlaygroundTest::GetSecondsElapsed() const { - return (fml::TimePoint::Now().ToEpochDelta() - start_time_).ToSecondsF(); -} - } // namespace impeller diff --git a/engine/src/flutter/impeller/playground/playground_test.h b/engine/src/flutter/impeller/playground/playground_test.h index 26db90635c..2d01cae763 100644 --- a/engine/src/flutter/impeller/playground/playground_test.h +++ b/engine/src/flutter/impeller/playground/playground_test.h @@ -7,7 +7,6 @@ #include #include "flutter/fml/macros.h" -#include "flutter/fml/time/time_delta.h" #include "flutter/testing/testing.h" #include "impeller/geometry/scalar.h" #include "impeller/playground/playground.h" @@ -35,13 +34,7 @@ class PlaygroundTest : public Playground, // |Playground| std::string GetWindowTitle() const override; - /// @brief Get the amount of time elapsed from the start of the playground - /// test's execution. - Scalar GetSecondsElapsed() const; - private: - fml::TimeDelta start_time_; - FML_DISALLOW_COPY_AND_ASSIGN(PlaygroundTest); };