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

Commit aca0482

Browse files
authored
Make all shell unit tests use the OpenGL rasterizer. (#9746)
The software backend was used earlier.
1 parent bc57291 commit aca0482

File tree

5 files changed

+85
-56
lines changed

5 files changed

+85
-56
lines changed

shell/common/BUILD.gn

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -139,43 +139,46 @@ template("shell_host_executable") {
139139
}
140140
}
141141

142-
shell_gpu_configuration("shell_unittests_gpu_configuration") {
143-
enable_software = true
144-
enable_vulkan = false
145-
enable_gl = false
146-
enable_metal = false
147-
}
142+
if (current_toolchain == host_toolchain) {
143+
shell_gpu_configuration("shell_unittests_gpu_configuration") {
144+
enable_software = true
145+
enable_vulkan = false
146+
enable_gl = true
147+
enable_metal = false
148+
}
148149

149-
test_fixtures("shell_unittests_fixtures") {
150-
dart_main = "fixtures/shell_test.dart"
151-
}
150+
test_fixtures("shell_unittests_fixtures") {
151+
dart_main = "fixtures/shell_test.dart"
152+
}
152153

153-
shell_host_executable("shell_unittests") {
154-
sources = [
155-
"pipeline_unittests.cc",
156-
"shell_test.cc",
157-
"shell_test.h",
158-
"shell_unittests.cc",
159-
]
154+
shell_host_executable("shell_unittests") {
155+
sources = [
156+
"pipeline_unittests.cc",
157+
"shell_test.cc",
158+
"shell_test.h",
159+
"shell_unittests.cc",
160+
]
160161

161-
deps = [
162-
":shell_unittests_fixtures",
163-
":shell_unittests_gpu_configuration",
164-
"$flutter_root/common",
165-
"$flutter_root/flow",
166-
"$flutter_root/shell",
167-
"$flutter_root/testing:dart",
168-
]
169-
}
162+
deps = [
163+
":shell_unittests_fixtures",
164+
":shell_unittests_gpu_configuration",
165+
"$flutter_root/common",
166+
"$flutter_root/flow",
167+
"$flutter_root/shell",
168+
"$flutter_root/testing:dart",
169+
"$flutter_root/testing:opengl",
170+
]
171+
}
170172

171-
shell_host_executable("shell_benchmarks") {
172-
sources = [
173-
"shell_benchmarks.cc",
174-
]
173+
shell_host_executable("shell_benchmarks") {
174+
sources = [
175+
"shell_benchmarks.cc",
176+
]
175177

176-
deps = [
177-
":shell_unittests_fixtures",
178-
"$flutter_root/benchmarking",
179-
"$flutter_root/testing:testing_lib",
180-
]
178+
deps = [
179+
":shell_unittests_fixtures",
180+
"$flutter_root/benchmarking",
181+
"$flutter_root/testing:testing_lib",
182+
]
183+
}
181184
}

shell/common/shell_test.cc

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "flutter/fml/make_copyable.h"
1212
#include "flutter/fml/mapping.h"
1313
#include "flutter/runtime/dart_vm.h"
14+
#include "flutter/shell/gpu/gpu_surface_gl.h"
1415
#include "flutter/testing/testing.h"
1516

1617
namespace flutter {
@@ -200,21 +201,35 @@ ShellTestPlatformView::~ShellTestPlatformView() = default;
200201

201202
// |PlatformView|
202203
std::unique_ptr<Surface> ShellTestPlatformView::CreateRenderingSurface() {
203-
return std::make_unique<GPUSurfaceSoftware>(this);
204+
return std::make_unique<GPUSurfaceGL>(this);
204205
}
205206

206-
// |GPUSurfaceSoftwareDelegate|
207-
sk_sp<SkSurface> ShellTestPlatformView::AcquireBackingStore(
208-
const SkISize& size) {
209-
SkImageInfo image_info = SkImageInfo::MakeN32Premul(
210-
size.width(), size.height(), SkColorSpace::MakeSRGB());
211-
return SkSurface::MakeRaster(image_info);
207+
// |GPUSurfaceGLDelegate|
208+
bool ShellTestPlatformView::GLContextMakeCurrent() {
209+
return gl_surface_.MakeCurrent();
212210
}
213211

214-
// |GPUSurfaceSoftwareDelegate|
215-
bool ShellTestPlatformView::PresentBackingStore(
216-
sk_sp<SkSurface> backing_store) {
217-
return true;
212+
// |GPUSurfaceGLDelegate|
213+
bool ShellTestPlatformView::GLContextClearCurrent() {
214+
return gl_surface_.ClearCurrent();
215+
}
216+
217+
// |GPUSurfaceGLDelegate|
218+
bool ShellTestPlatformView::GLContextPresent() {
219+
return gl_surface_.Present();
220+
}
221+
222+
// |GPUSurfaceGLDelegate|
223+
intptr_t ShellTestPlatformView::GLContextFBO() const {
224+
return gl_surface_.GetFramebuffer();
225+
}
226+
227+
// |GPUSurfaceGLDelegate|
228+
GPUSurfaceGLDelegate::GLProcResolver ShellTestPlatformView::GetGLProcResolver()
229+
const {
230+
return [surface = &gl_surface_](const char* name) -> void* {
231+
return surface->GetProcAddress(name);
232+
};
218233
}
219234

220235
} // namespace testing

shell/common/shell_test.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
#include "flutter/shell/common/run_configuration.h"
1313
#include "flutter/shell/common/shell.h"
1414
#include "flutter/shell/common/thread_host.h"
15-
#include "flutter/shell/gpu/gpu_surface_software.h"
15+
#include "flutter/shell/gpu/gpu_surface_gl_delegate.h"
1616
#include "flutter/testing/test_dart_native_resolver.h"
17+
#include "flutter/testing/test_gl_surface.h"
1718
#include "flutter/testing/thread_test.h"
1819

1920
namespace flutter {
@@ -66,23 +67,33 @@ class ShellTest : public ThreadTest {
6667
void SetSnapshotsAndAssets(Settings& settings);
6768
};
6869

69-
class ShellTestPlatformView : public PlatformView,
70-
public GPUSurfaceSoftwareDelegate {
70+
class ShellTestPlatformView : public PlatformView, public GPUSurfaceGLDelegate {
7171
public:
7272
ShellTestPlatformView(PlatformView::Delegate& delegate,
7373
TaskRunners task_runners);
7474

7575
~ShellTestPlatformView() override;
7676

7777
private:
78+
TestGLSurface gl_surface_;
79+
7880
// |PlatformView|
7981
std::unique_ptr<Surface> CreateRenderingSurface() override;
8082

81-
// |GPUSurfaceSoftwareDelegate|
82-
virtual sk_sp<SkSurface> AcquireBackingStore(const SkISize& size) override;
83+
// |GPUSurfaceGLDelegate|
84+
bool GLContextMakeCurrent() override;
85+
86+
// |GPUSurfaceGLDelegate|
87+
bool GLContextClearCurrent() override;
88+
89+
// |GPUSurfaceGLDelegate|
90+
bool GLContextPresent() override;
91+
92+
// |GPUSurfaceGLDelegate|
93+
intptr_t GLContextFBO() const override;
8394

84-
// |GPUSurfaceSoftwareDelegate|
85-
virtual bool PresentBackingStore(sk_sp<SkSurface> backing_store) override;
95+
// |GPUSurfaceGLDelegate|
96+
GLProcResolver GetGLProcResolver() const override;
8697

8798
FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformView);
8899
};

testing/test_gl_surface.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ bool TestGLSurface::Present() {
203203
return result == EGL_TRUE;
204204
}
205205

206-
uint32_t TestGLSurface::GetFramebuffer() {
206+
uint32_t TestGLSurface::GetFramebuffer() const {
207207
// Return FBO0
208208
return 0;
209209
}
@@ -220,7 +220,7 @@ bool TestGLSurface::MakeResourceCurrent() {
220220
return result == EGL_TRUE;
221221
}
222222

223-
void* TestGLSurface::GetProcAddress(const char* name) {
223+
void* TestGLSurface::GetProcAddress(const char* name) const {
224224
if (name == nullptr) {
225225
return nullptr;
226226
}

testing/test_gl_surface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ class TestGLSurface {
2525

2626
bool Present();
2727

28-
uint32_t GetFramebuffer();
28+
uint32_t GetFramebuffer() const;
2929

3030
bool MakeResourceCurrent();
3131

32-
void* GetProcAddress(const char* name);
32+
void* GetProcAddress(const char* name) const;
3333

3434
sk_sp<GrContext> CreateContext();
3535

0 commit comments

Comments
 (0)