mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] Fix stuttering in playgrounds due to precision issue (flutter/engine#37035)
This commit is contained in:
parent
ca9bbfe90c
commit
2351864d34
@ -2053,8 +2053,7 @@ TEST_P(EntityTest, RuntimeEffect) {
|
||||
Scalar iTime;
|
||||
Vector2 iResolution;
|
||||
} frag_uniforms = {
|
||||
.iTime = static_cast<Scalar>(
|
||||
fml::TimePoint::Now().ToEpochDelta().ToSecondsF()),
|
||||
.iTime = static_cast<Scalar>(GetSecondsElapsed()),
|
||||
.iResolution = Vector2(GetWindowSize().width, GetWindowSize().height),
|
||||
};
|
||||
auto uniform_data = std::make_shared<std::vector<uint8_t>>();
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/fml/time/time_point.h"
|
||||
|
||||
#include "impeller/playground/playground_test.h"
|
||||
|
||||
namespace impeller {
|
||||
@ -22,6 +24,8 @@ void PlaygroundTest::SetUp() {
|
||||
}
|
||||
|
||||
SetupWindow(GetParam());
|
||||
|
||||
start_time_ = fml::TimePoint::Now().ToEpochDelta();
|
||||
}
|
||||
|
||||
void PlaygroundTest::TearDown() {
|
||||
@ -59,4 +63,8 @@ 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,7 +7,9 @@
|
||||
#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"
|
||||
|
||||
namespace impeller {
|
||||
@ -33,7 +35,13 @@ 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);
|
||||
};
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/fml/time/time_point.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "impeller/base/strings.h"
|
||||
#include "impeller/fixtures/array.frag.h"
|
||||
@ -92,7 +91,7 @@ TEST_P(RendererTest, CanCreateBoxPrimitive) {
|
||||
pass.GetTransientsBuffer().EmplaceUniform(uniforms));
|
||||
|
||||
FS::FrameInfo frame_info;
|
||||
frame_info.current_time = fml::TimePoint::Now().ToEpochDelta().ToSecondsF();
|
||||
frame_info.current_time = GetSecondsElapsed();
|
||||
frame_info.cursor_position = GetCursorPosition();
|
||||
frame_info.window_size.x = GetWindowSize().width;
|
||||
frame_info.window_size.y = GetWindowSize().height;
|
||||
@ -181,7 +180,7 @@ TEST_P(RendererTest, CanRenderPerspectiveCube) {
|
||||
cmd.BindVertices(vertex_buffer);
|
||||
|
||||
VS::UniformBuffer uniforms;
|
||||
Scalar time = fml::TimePoint::Now().ToEpochDelta().ToSecondsF();
|
||||
Scalar time = GetSecondsElapsed();
|
||||
euler_angles = Vector3(0.19 * time, 0.7 * time, 0.43 * time);
|
||||
|
||||
uniforms.mvp =
|
||||
@ -244,7 +243,7 @@ TEST_P(RendererTest, CanRenderMultiplePrimitives) {
|
||||
cmd.BindVertices(vertex_buffer);
|
||||
|
||||
FS::FrameInfo frame_info;
|
||||
frame_info.current_time = fml::TimePoint::Now().ToEpochDelta().ToSecondsF();
|
||||
frame_info.current_time = GetSecondsElapsed();
|
||||
frame_info.cursor_position = GetCursorPosition();
|
||||
frame_info.window_size.x = GetWindowSize().width;
|
||||
frame_info.window_size.y = GetWindowSize().height;
|
||||
@ -359,7 +358,7 @@ TEST_P(RendererTest, CanRenderToTexture) {
|
||||
cmd.BindVertices(vertex_buffer);
|
||||
|
||||
FS::FrameInfo frame_info;
|
||||
frame_info.current_time = fml::TimePoint::Now().ToEpochDelta().ToSecondsF();
|
||||
frame_info.current_time = GetSecondsElapsed();
|
||||
frame_info.cursor_position = GetCursorPosition();
|
||||
frame_info.window_size.x = GetWindowSize().width;
|
||||
frame_info.window_size.y = GetWindowSize().height;
|
||||
@ -722,7 +721,7 @@ TEST_P(RendererTest, TheImpeller) {
|
||||
|
||||
FS::FragInfo fs_uniform;
|
||||
fs_uniform.texture_size = Point(size);
|
||||
fs_uniform.time = fml::TimePoint::Now().ToEpochDelta().ToSecondsF();
|
||||
fs_uniform.time = GetSecondsElapsed();
|
||||
FS::BindFragInfo(cmd,
|
||||
pass.GetTransientsBuffer().EmplaceUniform(fs_uniform));
|
||||
FS::BindBlueNoise(cmd, blue_noise, noise_sampler);
|
||||
@ -768,7 +767,7 @@ TEST_P(RendererTest, ArrayUniforms) {
|
||||
VS::BindVertInfo(cmd,
|
||||
pass.GetTransientsBuffer().EmplaceUniform(vs_uniform));
|
||||
|
||||
auto time = fml::TimePoint::Now().ToEpochDelta().ToSecondsF();
|
||||
auto time = GetSecondsElapsed();
|
||||
auto y_pos = [&time](float x) {
|
||||
return 400 + 10 * std::cos(time * 5 + x / 6);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user