This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Refactor ShellTest to allow for different ShellTestPlatformViews #15972
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include "flutter/shell/common/shell_test_platform_view.h" | ||
| #include "flutter/shell/common/shell_test_platform_view_gl.h" | ||
|
|
||
| namespace flutter { | ||
| namespace testing { | ||
|
|
||
| std::unique_ptr<ShellTestPlatformView> ShellTestPlatformView::Create( | ||
| PlatformView::Delegate& delegate, | ||
| TaskRunners task_runners, | ||
| std::shared_ptr<ShellTestVsyncClock> vsync_clock, | ||
| CreateVsyncWaiter create_vsync_waiter) { | ||
| return std::make_unique<ShellTestPlatformViewGL>( | ||
| delegate, task_runners, vsync_clock, create_vsync_waiter); | ||
| } | ||
|
|
||
| } // namespace testing | ||
| } // namespace flutter | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_SHELL_COMMON_SHELL_TEST_PLATFORM_VIEW_H_ | ||
| #define FLUTTER_SHELL_COMMON_SHELL_TEST_PLATFORM_VIEW_H_ | ||
|
|
||
| #include "flutter/shell/common/platform_view.h" | ||
| #include "flutter/shell/common/vsync_waiters_test.h" | ||
|
|
||
| namespace flutter { | ||
| namespace testing { | ||
|
|
||
| class ShellTestPlatformView : public PlatformView { | ||
| public: | ||
| static std::unique_ptr<ShellTestPlatformView> Create( | ||
| PlatformView::Delegate& delegate, | ||
| TaskRunners task_runners, | ||
| std::shared_ptr<ShellTestVsyncClock> vsync_clock, | ||
| CreateVsyncWaiter create_vsync_waiter); | ||
|
|
||
| virtual void SimulateVSync() = 0; | ||
|
|
||
| protected: | ||
| ShellTestPlatformView(PlatformView::Delegate& delegate, | ||
| TaskRunners task_runners) | ||
| : PlatformView(delegate, task_runners) {} | ||
|
|
||
| FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformView); | ||
| }; | ||
|
|
||
| } // namespace testing | ||
| } // namespace flutter | ||
|
|
||
| #endif // FLUTTER_SHELL_COMMON_SHELL_TEST_PLATFORM_VIEW_GL_H_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include "flutter/shell/common/shell_test_platform_view_gl.h" | ||
| #include "flutter/shell/gpu/gpu_surface_gl.h" | ||
|
|
||
| namespace flutter { | ||
| namespace testing { | ||
|
|
||
| ShellTestPlatformViewGL::ShellTestPlatformViewGL( | ||
| PlatformView::Delegate& delegate, | ||
| TaskRunners task_runners, | ||
| std::shared_ptr<ShellTestVsyncClock> vsync_clock, | ||
| CreateVsyncWaiter create_vsync_waiter) | ||
| : ShellTestPlatformView(delegate, std::move(task_runners)), | ||
| gl_surface_(SkISize::Make(800, 600)), | ||
| create_vsync_waiter_(std::move(create_vsync_waiter)), | ||
| vsync_clock_(vsync_clock) {} | ||
|
|
||
| ShellTestPlatformViewGL::~ShellTestPlatformViewGL() = default; | ||
|
|
||
| std::unique_ptr<VsyncWaiter> ShellTestPlatformViewGL::CreateVSyncWaiter() { | ||
| return create_vsync_waiter_(); | ||
| } | ||
|
|
||
| void ShellTestPlatformViewGL::SimulateVSync() { | ||
| vsync_clock_->SimulateVSync(); | ||
| } | ||
|
|
||
| // |PlatformView| | ||
| std::unique_ptr<Surface> ShellTestPlatformViewGL::CreateRenderingSurface() { | ||
| return std::make_unique<GPUSurfaceGL>(this, true); | ||
| } | ||
|
|
||
| // |PlatformView| | ||
| PointerDataDispatcherMaker ShellTestPlatformViewGL::GetDispatcherMaker() { | ||
| return [](DefaultPointerDataDispatcher::Delegate& delegate) { | ||
| return std::make_unique<SmoothPointerDataDispatcher>(delegate); | ||
| }; | ||
| } | ||
|
|
||
| // |GPUSurfaceGLDelegate| | ||
| bool ShellTestPlatformViewGL::GLContextMakeCurrent() { | ||
| return gl_surface_.MakeCurrent(); | ||
| } | ||
|
|
||
| // |GPUSurfaceGLDelegate| | ||
| bool ShellTestPlatformViewGL::GLContextClearCurrent() { | ||
| return gl_surface_.ClearCurrent(); | ||
| } | ||
|
|
||
| // |GPUSurfaceGLDelegate| | ||
| bool ShellTestPlatformViewGL::GLContextPresent() { | ||
| return gl_surface_.Present(); | ||
| } | ||
|
|
||
| // |GPUSurfaceGLDelegate| | ||
| intptr_t ShellTestPlatformViewGL::GLContextFBO() const { | ||
| return gl_surface_.GetFramebuffer(); | ||
| } | ||
|
|
||
| // |GPUSurfaceGLDelegate| | ||
| GPUSurfaceGLDelegate::GLProcResolver | ||
| ShellTestPlatformViewGL::GetGLProcResolver() const { | ||
| return [surface = &gl_surface_](const char* name) -> void* { | ||
| return surface->GetProcAddress(name); | ||
| }; | ||
| } | ||
|
|
||
| // |GPUSurfaceGLDelegate| | ||
| ExternalViewEmbedder* ShellTestPlatformViewGL::GetExternalViewEmbedder() { | ||
| return nullptr; | ||
| } | ||
|
|
||
| } // namespace testing | ||
| } // namespace flutter |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really aim for all our tests to be as cross platform as possible. Towards this end, there is no reason that Vulkan can only be tested on Fuchsia (since it is either available or can be emulated everywhere). I suggest making this configurable via an enum that the test can select at runtime (or skip if not available). I was undertaking just such an effort that would collide with this one so I have closed it. But feel free to refer to #14023 for a guide on my thought process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So @iskakaushik suggested I remove the Vulkan stubs entirely for now, land the changes to the rest of the ShellTestPlatformView, and iterate on the rendering API runtime changes in a future PR.
My plan was to have Vulkan not tied to Fuchsia and this was more of a stepping stone towards getting there, but after Kaushik's suggestion I agree it'd be better to land this in distinct pieces so we don't end up with behemoth patches.