Skip to content

Commit ede7f95

Browse files
bderoloic-sharma
authored andcommitted
[Impeller] Move GetSecondsElapsed to Playground (flutter#38375)
1 parent 2f3e725 commit ede7f95

File tree

6 files changed

+14
-21
lines changed

6 files changed

+14
-21
lines changed

impeller/playground/compute_playground_test.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,4 @@ std::string ComputePlaygroundTest::GetWindowTitle() const {
6262
return FormatWindowTitle(flutter::testing::GetCurrentTestName());
6363
}
6464

65-
Scalar ComputePlaygroundTest::GetSecondsElapsed() const {
66-
return (fml::TimePoint::Now().ToEpochDelta() - start_time_).ToSecondsF();
67-
}
68-
6965
} // namespace impeller

impeller/playground/compute_playground_test.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ class ComputePlaygroundTest
3636
// |Playground|
3737
std::string GetWindowTitle() const override;
3838

39-
/// @brief Get the amount of time elapsed from the start of the playground
40-
/// test's execution.
41-
Scalar GetSecondsElapsed() const;
42-
4339
private:
4440
fml::TimeDelta start_time_;
4541

impeller/playground/playground.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <optional>
88
#include <sstream>
99

10+
#include "fml/time/time_point.h"
1011
#include "impeller/image/decompressed_image.h"
1112
#include "impeller/renderer/command_buffer.h"
1213
#include "impeller/runtime_stage/runtime_stage.h"
@@ -126,6 +127,8 @@ void Playground::SetupWindow() {
126127
return;
127128
}
128129
renderer_ = std::move(renderer);
130+
131+
start_time_ = fml::TimePoint::Now().ToEpochDelta();
129132
}
130133

131134
void Playground::TeardownWindow() {
@@ -165,6 +168,10 @@ Point Playground::GetContentScale() const {
165168
return impl_->GetContentScale();
166169
}
167170

171+
Scalar Playground::GetSecondsElapsed() const {
172+
return (fml::TimePoint::Now().ToEpochDelta() - start_time_).ToSecondsF();
173+
}
174+
168175
void Playground::SetCursorPosition(Point pos) {
169176
cursor_position_ = pos;
170177
}

impeller/playground/playground.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "flutter/fml/closure.h"
1010
#include "flutter/fml/macros.h"
11+
#include "flutter/fml/time/time_delta.h"
1112

1213
#include "impeller/geometry/point.h"
1314
#include "impeller/renderer/renderer.h"
@@ -50,6 +51,10 @@ class Playground {
5051

5152
Point GetContentScale() const;
5253

54+
/// @brief Get the amount of time elapsed from the start of the playground's
55+
/// execution.
56+
Scalar GetSecondsElapsed() const;
57+
5358
std::shared_ptr<Context> GetContext() const;
5459

5560
bool OpenPlaygroundHere(const Renderer::RenderCallback& render_callback);
@@ -80,6 +85,8 @@ class Playground {
8085
static const bool is_enabled_ = false;
8186
#endif // IMPELLER_ENABLE_PLAYGROUND
8287

88+
fml::TimeDelta start_time_;
89+
8390
struct GLFWInitializer;
8491
std::unique_ptr<GLFWInitializer> glfw_initializer_;
8592
std::unique_ptr<PlaygroundImpl> impl_;

impeller/playground/playground_test.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ void PlaygroundTest::SetUp() {
2525

2626
SetupContext(GetParam());
2727
SetupWindow();
28-
29-
start_time_ = fml::TimePoint::Now().ToEpochDelta();
3028
}
3129

3230
void PlaygroundTest::TearDown() {
@@ -63,8 +61,4 @@ std::string PlaygroundTest::GetWindowTitle() const {
6361
return FormatWindowTitle(flutter::testing::GetCurrentTestName());
6462
}
6563

66-
Scalar PlaygroundTest::GetSecondsElapsed() const {
67-
return (fml::TimePoint::Now().ToEpochDelta() - start_time_).ToSecondsF();
68-
}
69-
7064
} // namespace impeller

impeller/playground/playground_test.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <memory>
88

99
#include "flutter/fml/macros.h"
10-
#include "flutter/fml/time/time_delta.h"
1110
#include "flutter/testing/testing.h"
1211
#include "impeller/geometry/scalar.h"
1312
#include "impeller/playground/playground.h"
@@ -35,13 +34,7 @@ class PlaygroundTest : public Playground,
3534
// |Playground|
3635
std::string GetWindowTitle() const override;
3736

38-
/// @brief Get the amount of time elapsed from the start of the playground
39-
/// test's execution.
40-
Scalar GetSecondsElapsed() const;
41-
4237
private:
43-
fml::TimeDelta start_time_;
44-
4538
FML_DISALLOW_COPY_AND_ASSIGN(PlaygroundTest);
4639
};
4740

0 commit comments

Comments
 (0)