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

Commit 13df260

Browse files
committed
Move Surface and friends to flow/
Circular dependencies are cropping up between shell/common/ and flow/, so just move all of this stuff down into flow itself. These classes are all rasterization-related anyways. shell/common/ has Dart dependenices, and a future CL will create non-product and product permutations of any target with Dart dependencies. Moving all of the rasterization-related code to its own library with no Dart dependencies means no permutations need to be made of it. Tested: Just compile, this is a mechanical change
1 parent f581f42 commit 13df260

30 files changed

+84
-97
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ FILE: ../../../flutter/flow/compositor_context.cc
2828
FILE: ../../../flutter/flow/compositor_context.h
2929
FILE: ../../../flutter/flow/embedded_views.cc
3030
FILE: ../../../flutter/flow/embedded_views.h
31+
FILE: ../../../flutter/flow/gl_context_switch.cc
32+
FILE: ../../../flutter/flow/gl_context_switch.h
33+
FILE: ../../../flutter/flow/gl_context_switch_unittests.cc
3134
FILE: ../../../flutter/flow/instrumentation.cc
3235
FILE: ../../../flutter/flow/instrumentation.h
3336
FILE: ../../../flutter/flow/layers/backdrop_filter_layer.cc
@@ -102,6 +105,10 @@ FILE: ../../../flutter/flow/scene_update_context.h
102105
FILE: ../../../flutter/flow/skia_gpu_object.cc
103106
FILE: ../../../flutter/flow/skia_gpu_object.h
104107
FILE: ../../../flutter/flow/skia_gpu_object_unittests.cc
108+
FILE: ../../../flutter/flow/surface.cc
109+
FILE: ../../../flutter/flow/surface.h
110+
FILE: ../../../flutter/flow/surface_frame.cc
111+
FILE: ../../../flutter/flow/surface_frame.h
105112
FILE: ../../../flutter/flow/texture.cc
106113
FILE: ../../../flutter/flow/texture.h
107114
FILE: ../../../flutter/flow/texture_unittests.cc
@@ -576,11 +583,6 @@ FILE: ../../../flutter/shell/common/engine.cc
576583
FILE: ../../../flutter/shell/common/engine.h
577584
FILE: ../../../flutter/shell/common/fixtures/shell_test.dart
578585
FILE: ../../../flutter/shell/common/fixtures/shelltest_screenshot.png
579-
FILE: ../../../flutter/shell/common/gl_context_switch.cc
580-
FILE: ../../../flutter/shell/common/gl_context_switch.h
581-
FILE: ../../../flutter/shell/common/gl_context_switch_test.cc
582-
FILE: ../../../flutter/shell/common/gl_context_switch_test.h
583-
FILE: ../../../flutter/shell/common/gl_context_switch_unittests.cc
584586
FILE: ../../../flutter/shell/common/input_events_unittests.cc
585587
FILE: ../../../flutter/shell/common/isolate_configuration.cc
586588
FILE: ../../../flutter/shell/common/isolate_configuration.h
@@ -616,10 +618,6 @@ FILE: ../../../flutter/shell/common/shell_test_platform_view_vulkan.h
616618
FILE: ../../../flutter/shell/common/shell_unittests.cc
617619
FILE: ../../../flutter/shell/common/skia_event_tracer_impl.cc
618620
FILE: ../../../flutter/shell/common/skia_event_tracer_impl.h
619-
FILE: ../../../flutter/shell/common/surface.cc
620-
FILE: ../../../flutter/shell/common/surface.h
621-
FILE: ../../../flutter/shell/common/surface_frame.cc
622-
FILE: ../../../flutter/shell/common/surface_frame.h
623621
FILE: ../../../flutter/shell/common/switches.cc
624622
FILE: ../../../flutter/shell/common/switches.h
625623
FILE: ../../../flutter/shell/common/thread_host.cc

flow/BUILD.gn

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ source_set("flow") {
1414
"compositor_context.h",
1515
"embedded_views.cc",
1616
"embedded_views.h",
17+
"gl_context_switch.cc",
18+
"gl_context_switch.h",
1719
"instrumentation.cc",
1820
"instrumentation.h",
1921
"layers/backdrop_filter_layer.cc",
@@ -62,6 +64,10 @@ source_set("flow") {
6264
"rtree.h",
6365
"skia_gpu_object.cc",
6466
"skia_gpu_object.h",
67+
"surface.cc",
68+
"surface.h",
69+
"surface_frame.cc",
70+
"surface_frame.h",
6571
"texture.cc",
6672
"texture.h",
6773
]
@@ -73,7 +79,6 @@ source_set("flow") {
7379
deps = [
7480
"//flutter/common",
7581
"//flutter/fml",
76-
"//flutter/shell/common:common_standalone",
7782
"//third_party/skia",
7883
]
7984

@@ -103,6 +108,8 @@ source_set("flow_testing") {
103108
testonly = true
104109

105110
sources = [
111+
"testing/gl_context_switch_test.cc",
112+
"testing/gl_context_switch_test.h",
106113
"testing/layer_test.h",
107114
"testing/mock_layer.cc",
108115
"testing/mock_layer.h",
@@ -126,6 +133,7 @@ executable("flow_unittests") {
126133
"flow_run_all_unittests.cc",
127134
"flow_test_utils.cc",
128135
"flow_test_utils.h",
136+
"gl_context_switch_unittests.cc",
129137
"layers/backdrop_filter_layer_unittests.cc",
130138
"layers/clip_path_layer_unittests.cc",
131139
"layers/clip_rect_layer_unittests.cc",

flow/embedded_views.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
#include <vector>
99

10+
#include "flutter/flow/surface_frame.h"
1011
#include "flutter/fml/memory/ref_counted.h"
1112
#include "flutter/fml/raster_thread_merger.h"
12-
#include "flutter/shell/common/surface_frame.h"
1313
#include "third_party/skia/include/core/SkCanvas.h"
1414
#include "third_party/skia/include/core/SkPath.h"
1515
#include "third_party/skia/include/core/SkPoint.h"

shell/common/gl_context_switch.cc renamed to flow/gl_context_switch.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include "gl_context_switch.h"
5+
#include "flutter/flow/gl_context_switch.h"
66

77
namespace flutter {
88

@@ -11,16 +11,20 @@ SwitchableGLContext::SwitchableGLContext() = default;
1111
SwitchableGLContext::~SwitchableGLContext() = default;
1212

1313
GLContextResult::GLContextResult() = default;
14+
1415
GLContextResult::~GLContextResult() = default;
16+
1517
GLContextResult::GLContextResult(bool static_result) : result_(static_result){};
18+
1619
bool GLContextResult::GetResult() {
1720
return result_;
1821
};
1922

20-
GLContextDefaultResult::~GLContextDefaultResult() = default;
2123
GLContextDefaultResult::GLContextDefaultResult(bool static_result)
2224
: GLContextResult(static_result){};
2325

26+
GLContextDefaultResult::~GLContextDefaultResult() = default;
27+
2428
GLContextSwitch::GLContextSwitch(std::unique_ptr<SwitchableGLContext> context)
2529
: context_(std::move(context)) {
2630
FML_CHECK(context_ != nullptr);

shell/common/gl_context_switch.h renamed to flow/gl_context_switch.h

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifndef FLUTTER_SHELL_COMMON_GL_CONTEXT_SWITCH_H_
6-
#define FLUTTER_SHELL_COMMON_GL_CONTEXT_SWITCH_H_
5+
#ifndef FLUTTER_FLOW_GL_CONTEXT_SWITCH_H_
6+
#define FLUTTER_FLOW_GL_CONTEXT_SWITCH_H_
77

88
#include <functional>
99
#include <memory>
@@ -14,42 +14,39 @@
1414

1515
namespace flutter {
1616

17-
//------------------------------------------------------------------------------
18-
/// An abstract class represents a gl context that can be switched by
19-
/// GLContextSwitch
20-
///
21-
/// The subclass should wrap a "Context" object inside this class. For example,
22-
/// in iOS while using GL rendering surface, the subclass should wrap an
23-
/// |EAGLContext|.
17+
// This interface represents a gl context that can be switched by
18+
// |GLContextSwitch|.
19+
//
20+
// The implementation should wrap a "Context" object inside this class. For
21+
// example, in iOS while using a GL rendering surface, the implementation should
22+
// wrap an |EAGLContext|.
2423
class SwitchableGLContext {
2524
public:
26-
//------------------------------------------------------------------------------
27-
/// Implement this to set the context wrapped by this |SwitchableGLContext|
28-
/// object to the current context.
29-
virtual bool SetCurrent() = 0;
30-
31-
//------------------------------------------------------------------------------
32-
/// Implement this to remove the context wrapped by this |SwitchableGLContext|
33-
/// object from current context;
34-
virtual bool RemoveCurrent() = 0;
35-
3625
SwitchableGLContext();
3726

3827
virtual ~SwitchableGLContext();
3928

29+
// Implement this to set the context wrapped by this |SwitchableGLContext|
30+
// object to the current context.
31+
virtual bool SetCurrent() = 0;
32+
33+
// Implement this to remove the context wrapped by this |SwitchableGLContext|
34+
// object from current context;
35+
virtual bool RemoveCurrent() = 0;
36+
4037
FML_DISALLOW_COPY_AND_ASSIGN(SwitchableGLContext);
4138
};
4239

43-
//------------------------------------------------------------------------------
44-
/// Represents the result of setting a gl context.
45-
/// This class exists because context results are used in places applies to all
46-
/// the platforms. On certain platforms(for example lower end iOS devices that
47-
/// uses gl), a |GLContextSwitch| is required to protect flutter's gl contect
48-
/// from being polluted by other programs(embedded platform views). A
49-
/// |GLContextSwitch| is a subclass of |GLContextResult|, which can be returned
50-
/// on platforms that requires context switching. A |GLContextDefaultResult| is
51-
/// also a subclass of |GLContextResult|, which can be returned on platforms
52-
/// that doesn't require context switching.
40+
// Represents the result of setting a gl context.
41+
//
42+
// This class exists because context results are used in places applies to all
43+
// the platforms. On certain platforms(for example lower end iOS devices that
44+
// uses gl), a |GLContextSwitch| is required to protect flutter's gl contect
45+
// from being polluted by other programs(embedded platform views). A
46+
// |GLContextSwitch| is a subclass of |GLContextResult|, which can be returned
47+
// on platforms that requires context switching. A |GLContextDefaultResult| is
48+
// also a subclass of |GLContextResult|, which can be returned on platforms
49+
// that doesn't require context switching.
5350
class GLContextResult {
5451
public:
5552
GLContextResult();
@@ -114,4 +111,4 @@ class GLContextSwitch final : public GLContextResult {
114111

115112
} // namespace flutter
116113

117-
#endif
114+
#endif // FLUTTER_FLOW_GL_CONTEXT_SWITCH_H_

shell/common/gl_context_switch_unittests.cc renamed to flow/gl_context_switch_unittests.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
#include <future>
88
#include <memory>
99

10-
#include "flutter/shell/common/gl_context_switch.h"
11-
#include "gl_context_switch_test.h"
10+
#include "flutter/flow/gl_context_switch.h"
11+
#include "flutter/flow/testing/gl_context_switch_test.h"
1212
#include "gtest/gtest.h"
1313

1414
namespace flutter {
1515
namespace testing {
1616

17-
TEST_F(GLContextSwitchTest, SwitchKeepsContextCurrentWhileInScope) {
17+
TEST(GLContextSwitchTest, SwitchKeepsContextCurrentWhileInScope) {
1818
{
1919
auto test_gl_context = std::make_unique<TestSwitchableGLContext>(0);
2020
auto context_switch = GLContextSwitch(std::move(test_gl_context));

shell/common/surface.cc renamed to flow/surface.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include "flutter/shell/common/surface.h"
5+
#include "flutter/flow/surface.h"
66

77
namespace flutter {
88

shell/common/surface.h renamed to flow/surface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifndef FLUTTER_SHELL_COMMON_SURFACE_H_
6-
#define FLUTTER_SHELL_COMMON_SURFACE_H_
5+
#ifndef FLUTTER_FLOW_SURFACE_H_
6+
#define FLUTTER_FLOW_SURFACE_H_
77

88
#include <memory>
99

1010
#include "flutter/flow/compositor_context.h"
1111
#include "flutter/flow/embedded_views.h"
12+
#include "flutter/flow/surface_frame.h"
1213
#include "flutter/fml/macros.h"
13-
#include "flutter/shell/common/surface_frame.h"
1414

1515
namespace flutter {
1616

@@ -39,4 +39,4 @@ class Surface {
3939

4040
} // namespace flutter
4141

42-
#endif // FLUTTER_SHELL_COMMON_SURFACE_H_
42+
#endif // FLUTTER_FLOW_SURFACE_H_

shell/common/surface_frame.cc renamed to flow/surface_frame.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include "flutter/shell/common/surface_frame.h"
5+
#include "flutter/flow/surface_frame.h"
66
#include "flutter/fml/logging.h"
77

88
namespace flutter {

shell/common/surface_frame.h renamed to flow/surface_frame.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifndef FLUTTER_SHELL_COMMON_SURFACE_FRAME_H_
6-
#define FLUTTER_SHELL_COMMON_SURFACE_FRAME_H_
5+
#ifndef FLUTTER_FLOW_SURFACE_FRAME_H_
6+
#define FLUTTER_FLOW_SURFACE_FRAME_H_
77

88
#include <memory>
99

10+
#include "flutter/flow/gl_context_switch.h"
1011
#include "flutter/fml/macros.h"
11-
#include "flutter/shell/common/gl_context_switch.h"
1212
#include "third_party/skia/include/core/SkCanvas.h"
1313
#include "third_party/skia/include/core/SkSurface.h"
1414

1515
namespace flutter {
1616

17-
/// Represents a Frame that has been fully configured for the underlying client
18-
/// rendering API. A frame may only be submitted once.
17+
// This class represents a frame that has been fully configured for the
18+
// underlying client rendering API. A frame may only be submitted once.
1919
class SurfaceFrame {
2020
public:
2121
using SubmitCallback =
@@ -56,4 +56,4 @@ class SurfaceFrame {
5656

5757
} // namespace flutter
5858

59-
#endif // FLUTTER_SHELL_COMMON_SURFACE_FRAME_H_
59+
#endif // FLUTTER_FLOW_SURFACE_FRAME_H_

0 commit comments

Comments
 (0)