Skip to content

Commit f5ee86e

Browse files
author
George Wright
authored
Do not create a TestGLSurface for software-only rendering in EmbedderTest (flutter#21301)
1 parent a5d1b5a commit f5ee86e

9 files changed

+18
-29
lines changed

shell/platform/embedder/tests/embedder_config_builder.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ FlutterProjectArgs& EmbedderConfigBuilder::GetProjectArgs() {
107107
void EmbedderConfigBuilder::SetSoftwareRendererConfig(SkISize surface_size) {
108108
renderer_config_.type = FlutterRendererType::kSoftware;
109109
renderer_config_.software = software_renderer_config_;
110-
111-
// TODO(chinmaygarde): The compositor still uses a GL surface for operation.
112-
// Once this is no longer the case, don't setup the GL surface when using the
113-
// software renderer config.
114-
context_.SetupOpenGLSurface(surface_size);
110+
context_.SetupSurface(surface_size);
115111
}
116112

117113
void EmbedderConfigBuilder::SetOpenGLFBOCallBack() {
@@ -141,7 +137,7 @@ void EmbedderConfigBuilder::SetOpenGLPresentCallBack() {
141137
void EmbedderConfigBuilder::SetOpenGLRendererConfig(SkISize surface_size) {
142138
renderer_config_.type = FlutterRendererType::kOpenGL;
143139
renderer_config_.open_gl = opengl_renderer_config_;
144-
context_.SetupOpenGLSurface(surface_size);
140+
context_.SetupSurface(surface_size);
145141
}
146142

147143
void EmbedderConfigBuilder::SetAssetsPath() {

shell/platform/embedder/tests/embedder_test_compositor.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ EmbedderTestCompositor::EmbedderTestCompositor(SkISize surface_size,
1515
sk_sp<GrDirectContext> context)
1616
: surface_size_(surface_size), context_(context) {
1717
FML_CHECK(!surface_size_.isEmpty()) << "Surface size must not be empty";
18-
FML_CHECK(context_);
1918
}
2019

2120
EmbedderTestCompositor::~EmbedderTestCompositor() = default;

shell/platform/embedder/tests/embedder_test_compositor_software.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ namespace flutter {
1212
namespace testing {
1313

1414
EmbedderTestCompositorSoftware::EmbedderTestCompositorSoftware(
15-
SkISize surface_size,
16-
sk_sp<GrDirectContext> context)
17-
: EmbedderTestCompositor(surface_size, context) {}
15+
SkISize surface_size)
16+
: EmbedderTestCompositor(surface_size, nullptr) {}
1817

1918
EmbedderTestCompositorSoftware::~EmbedderTestCompositorSoftware() = default;
2019

@@ -54,10 +53,9 @@ bool EmbedderTestCompositorSoftware::UpdateOffscrenComposition(
5453

5554
break;
5655
case kFlutterLayerContentTypePlatformView:
57-
layer_image =
58-
platform_view_renderer_callback_
59-
? platform_view_renderer_callback_(*layer, context_.get())
60-
: nullptr;
56+
layer_image = platform_view_renderer_callback_
57+
? platform_view_renderer_callback_(*layer, nullptr)
58+
: nullptr;
6159
canvas_offset = SkIPoint::Make(layer->offset.x, layer->offset.y);
6260
break;
6361
};

shell/platform/embedder/tests/embedder_test_compositor_software.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ namespace testing {
1212

1313
class EmbedderTestCompositorSoftware : public EmbedderTestCompositor {
1414
public:
15-
EmbedderTestCompositorSoftware(SkISize surface_size,
16-
sk_sp<GrDirectContext> context);
15+
EmbedderTestCompositorSoftware(SkISize surface_size);
1716

1817
~EmbedderTestCompositorSoftware() override;
1918

shell/platform/embedder/tests/embedder_test_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class EmbedderTestContext {
131131

132132
void SetNextSceneCallback(const NextSceneCallback& next_scene_callback);
133133

134-
virtual void SetupOpenGLSurface(SkISize surface_size) = 0;
134+
virtual void SetupSurface(SkISize surface_size) = 0;
135135

136136
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestContext);
137137
};

shell/platform/embedder/tests/embedder_test_context_gl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ EmbedderTestContextGL::~EmbedderTestContextGL() {
2323
SetGLGetFBOCallback(nullptr);
2424
}
2525

26-
void EmbedderTestContextGL::SetupOpenGLSurface(SkISize surface_size) {
26+
void EmbedderTestContextGL::SetupSurface(SkISize surface_size) {
2727
FML_CHECK(!gl_surface_);
2828
gl_surface_ = std::make_unique<TestGLSurface>(surface_size);
2929
}

shell/platform/embedder/tests/embedder_test_context_gl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class EmbedderTestContextGL : public EmbedderTestContext {
6262
GLGetFBOCallback gl_get_fbo_callback_;
6363
GLPresentCallback gl_present_callback_;
6464

65-
void SetupOpenGLSurface(SkISize surface_size) override;
65+
void SetupSurface(SkISize surface_size) override;
6666

6767
bool GLMakeCurrent();
6868

shell/platform/embedder/tests/embedder_test_context_software.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,13 @@ size_t EmbedderTestContextSoftware::GetSurfacePresentCount() const {
3434
return software_surface_present_count_;
3535
}
3636

37-
void EmbedderTestContextSoftware::SetupOpenGLSurface(SkISize surface_size) {
38-
FML_CHECK(!gl_surface_);
39-
gl_surface_ = std::make_unique<TestGLSurface>(surface_size);
37+
void EmbedderTestContextSoftware::SetupSurface(SkISize surface_size) {
38+
surface_size_ = surface_size;
4039
}
4140

4241
void EmbedderTestContextSoftware::SetupCompositor() {
43-
FML_CHECK(!compositor_) << "Already ssetup a compositor in this context.";
44-
FML_CHECK(gl_surface_)
45-
<< "Setup the GL surface before setting up a compositor.";
46-
compositor_ = std::make_unique<EmbedderTestCompositorSoftware>(
47-
gl_surface_->GetSurfaceSize(), gl_surface_->GetGrContext());
42+
FML_CHECK(!compositor_) << "Already setup a compositor in this context.";
43+
compositor_ = std::make_unique<EmbedderTestCompositorSoftware>(surface_size_);
4844
}
4945

5046
} // namespace testing

shell/platform/embedder/tests/embedder_test_context_software.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ class EmbedderTestContextSoftware : public EmbedderTestContext {
2424
virtual void SetupCompositor() override;
2525

2626
private:
27-
std::unique_ptr<TestGLSurface> gl_surface_;
27+
sk_sp<SkSurface> surface_;
28+
SkISize surface_size_;
2829
size_t software_surface_present_count_ = 0;
29-
void SetupOpenGLSurface(SkISize surface_size) override;
30+
void SetupSurface(SkISize surface_size) override;
3031

3132
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestContextSoftware);
3233
};

0 commit comments

Comments
 (0)