Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Move GetSecondsElapsed to Playground #38375

Merged
merged 1 commit into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions impeller/playground/compute_playground_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions impeller/playground/compute_playground_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down
7 changes: 7 additions & 0 deletions impeller/playground/playground.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <optional>
#include <sstream>

#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"
Expand Down Expand Up @@ -126,6 +127,8 @@ void Playground::SetupWindow() {
return;
}
renderer_ = std::move(renderer);

start_time_ = fml::TimePoint::Now().ToEpochDelta();
}

void Playground::TeardownWindow() {
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions impeller/playground/playground.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<Context> GetContext() const;

bool OpenPlaygroundHere(const Renderer::RenderCallback& render_callback);
Expand Down Expand Up @@ -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<GLFWInitializer> glfw_initializer_;
std::unique_ptr<PlaygroundImpl> impl_;
Expand Down
6 changes: 0 additions & 6 deletions impeller/playground/playground_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ void PlaygroundTest::SetUp() {

SetupContext(GetParam());
SetupWindow();

start_time_ = fml::TimePoint::Now().ToEpochDelta();
}

void PlaygroundTest::TearDown() {
Expand Down Expand Up @@ -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
7 changes: 0 additions & 7 deletions impeller/playground/playground_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <memory>

#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"
Expand Down Expand Up @@ -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);
};

Expand Down