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

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

Merged
merged 2 commits into from
Jul 10, 2019
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
71 changes: 37 additions & 34 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
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"
}
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",
]
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",
]
}
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",
]
shell_host_executable("shell_benchmarks") {
sources = [
"shell_benchmarks.cc",
]

deps = [
":shell_unittests_fixtures",
"$flutter_root/benchmarking",
"$flutter_root/testing:testing_lib",
]
deps = [
":shell_unittests_fixtures",
"$flutter_root/benchmarking",
"$flutter_root/testing:testing_lib",
]
}
}
37 changes: 26 additions & 11 deletions shell/common/shell_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
25 changes: 18 additions & 7 deletions shell/common/shell_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -66,23 +67,33 @@ 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);

~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;

// |GPUSurfaceGLDelegate|
bool GLContextClearCurrent() override;

// |GPUSurfaceGLDelegate|
bool GLContextPresent() override;

// |GPUSurfaceGLDelegate|
intptr_t GLContextFBO() const override;

// |GPUSurfaceSoftwareDelegate|
virtual bool PresentBackingStore(sk_sp<SkSurface> backing_store) override;
// |GPUSurfaceGLDelegate|
GLProcResolver GetGLProcResolver() const override;

FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformView);
};
Expand Down
4 changes: 2 additions & 2 deletions testing/test_gl_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ bool TestGLSurface::Present() {
return result == EGL_TRUE;
}

uint32_t TestGLSurface::GetFramebuffer() {
uint32_t TestGLSurface::GetFramebuffer() const {
// Return FBO0
return 0;
}
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions testing/test_gl_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down