Make all shell unit tests use the OpenGL rasterizer. (#9746)

The software backend was used earlier.
This commit is contained in:
Chinmay Garde 2019-07-10 13:47:56 -07:00 committed by GitHub
parent bc57291ff4
commit aca0482362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 90 additions and 61 deletions

View File

@ -139,43 +139,46 @@ template("shell_host_executable") {
}
}
shell_gpu_configuration("shell_unittests_gpu_configuration") {
enable_software = true
enable_vulkan = false
enable_gl = false
enable_metal = false
}
test_fixtures("shell_unittests_fixtures") {
dart_main = "fixtures/shell_test.dart"
}
shell_host_executable("shell_unittests") {
sources = [
"pipeline_unittests.cc",
"shell_test.cc",
"shell_test.h",
"shell_unittests.cc",
]
deps = [
":shell_unittests_fixtures",
":shell_unittests_gpu_configuration",
"$flutter_root/common",
"$flutter_root/flow",
"$flutter_root/shell",
"$flutter_root/testing:dart",
]
}
shell_host_executable("shell_benchmarks") {
sources = [
"shell_benchmarks.cc",
]
deps = [
":shell_unittests_fixtures",
"$flutter_root/benchmarking",
"$flutter_root/testing:testing_lib",
]
if (current_toolchain == host_toolchain) {
shell_gpu_configuration("shell_unittests_gpu_configuration") {
enable_software = true
enable_vulkan = false
enable_gl = true
enable_metal = false
}
test_fixtures("shell_unittests_fixtures") {
dart_main = "fixtures/shell_test.dart"
}
shell_host_executable("shell_unittests") {
sources = [
"pipeline_unittests.cc",
"shell_test.cc",
"shell_test.h",
"shell_unittests.cc",
]
deps = [
":shell_unittests_fixtures",
":shell_unittests_gpu_configuration",
"$flutter_root/common",
"$flutter_root/flow",
"$flutter_root/shell",
"$flutter_root/testing:dart",
"$flutter_root/testing:opengl",
]
}
shell_host_executable("shell_benchmarks") {
sources = [
"shell_benchmarks.cc",
]
deps = [
":shell_unittests_fixtures",
"$flutter_root/benchmarking",
"$flutter_root/testing:testing_lib",
]
}
}

View File

@ -11,6 +11,7 @@
#include "flutter/fml/make_copyable.h"
#include "flutter/fml/mapping.h"
#include "flutter/runtime/dart_vm.h"
#include "flutter/shell/gpu/gpu_surface_gl.h"
#include "flutter/testing/testing.h"
namespace flutter {
@ -200,21 +201,35 @@ ShellTestPlatformView::~ShellTestPlatformView() = default;
// |PlatformView|
std::unique_ptr<Surface> ShellTestPlatformView::CreateRenderingSurface() {
return std::make_unique<GPUSurfaceSoftware>(this);
return std::make_unique<GPUSurfaceGL>(this);
}
// |GPUSurfaceSoftwareDelegate|
sk_sp<SkSurface> ShellTestPlatformView::AcquireBackingStore(
const SkISize& size) {
SkImageInfo image_info = SkImageInfo::MakeN32Premul(
size.width(), size.height(), SkColorSpace::MakeSRGB());
return SkSurface::MakeRaster(image_info);
// |GPUSurfaceGLDelegate|
bool ShellTestPlatformView::GLContextMakeCurrent() {
return gl_surface_.MakeCurrent();
}
// |GPUSurfaceSoftwareDelegate|
bool ShellTestPlatformView::PresentBackingStore(
sk_sp<SkSurface> backing_store) {
return true;
// |GPUSurfaceGLDelegate|
bool ShellTestPlatformView::GLContextClearCurrent() {
return gl_surface_.ClearCurrent();
}
// |GPUSurfaceGLDelegate|
bool ShellTestPlatformView::GLContextPresent() {
return gl_surface_.Present();
}
// |GPUSurfaceGLDelegate|
intptr_t ShellTestPlatformView::GLContextFBO() const {
return gl_surface_.GetFramebuffer();
}
// |GPUSurfaceGLDelegate|
GPUSurfaceGLDelegate::GLProcResolver ShellTestPlatformView::GetGLProcResolver()
const {
return [surface = &gl_surface_](const char* name) -> void* {
return surface->GetProcAddress(name);
};
}
} // namespace testing

View File

@ -12,8 +12,9 @@
#include "flutter/shell/common/run_configuration.h"
#include "flutter/shell/common/shell.h"
#include "flutter/shell/common/thread_host.h"
#include "flutter/shell/gpu/gpu_surface_software.h"
#include "flutter/shell/gpu/gpu_surface_gl_delegate.h"
#include "flutter/testing/test_dart_native_resolver.h"
#include "flutter/testing/test_gl_surface.h"
#include "flutter/testing/thread_test.h"
namespace flutter {
@ -66,8 +67,7 @@ class ShellTest : public ThreadTest {
void SetSnapshotsAndAssets(Settings& settings);
};
class ShellTestPlatformView : public PlatformView,
public GPUSurfaceSoftwareDelegate {
class ShellTestPlatformView : public PlatformView, public GPUSurfaceGLDelegate {
public:
ShellTestPlatformView(PlatformView::Delegate& delegate,
TaskRunners task_runners);
@ -75,14 +75,25 @@ class ShellTestPlatformView : public PlatformView,
~ShellTestPlatformView() override;
private:
TestGLSurface gl_surface_;
// |PlatformView|
std::unique_ptr<Surface> CreateRenderingSurface() override;
// |GPUSurfaceSoftwareDelegate|
virtual sk_sp<SkSurface> AcquireBackingStore(const SkISize& size) override;
// |GPUSurfaceGLDelegate|
bool GLContextMakeCurrent() override;
// |GPUSurfaceSoftwareDelegate|
virtual bool PresentBackingStore(sk_sp<SkSurface> backing_store) override;
// |GPUSurfaceGLDelegate|
bool GLContextClearCurrent() override;
// |GPUSurfaceGLDelegate|
bool GLContextPresent() override;
// |GPUSurfaceGLDelegate|
intptr_t GLContextFBO() const override;
// |GPUSurfaceGLDelegate|
GLProcResolver GetGLProcResolver() const override;
FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformView);
};

View File

@ -203,7 +203,7 @@ bool TestGLSurface::Present() {
return result == EGL_TRUE;
}
uint32_t TestGLSurface::GetFramebuffer() {
uint32_t TestGLSurface::GetFramebuffer() const {
// Return FBO0
return 0;
}
@ -220,7 +220,7 @@ bool TestGLSurface::MakeResourceCurrent() {
return result == EGL_TRUE;
}
void* TestGLSurface::GetProcAddress(const char* name) {
void* TestGLSurface::GetProcAddress(const char* name) const {
if (name == nullptr) {
return nullptr;
}

View File

@ -25,11 +25,11 @@ class TestGLSurface {
bool Present();
uint32_t GetFramebuffer();
uint32_t GetFramebuffer() const;
bool MakeResourceCurrent();
void* GetProcAddress(const char* name);
void* GetProcAddress(const char* name) const;
sk_sp<GrContext> CreateContext();