Skip to content

Commit

Permalink
Move Surface and friends to flow/ (flutter#18938)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbreng committed Jun 9, 2020
1 parent b99b4a5 commit 66d85bc
Show file tree
Hide file tree
Showing 30 changed files with 84 additions and 97 deletions.
16 changes: 7 additions & 9 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ FILE: ../../../flutter/flow/compositor_context.cc
FILE: ../../../flutter/flow/compositor_context.h
FILE: ../../../flutter/flow/embedded_views.cc
FILE: ../../../flutter/flow/embedded_views.h
FILE: ../../../flutter/flow/gl_context_switch.cc
FILE: ../../../flutter/flow/gl_context_switch.h
FILE: ../../../flutter/flow/gl_context_switch_unittests.cc
FILE: ../../../flutter/flow/instrumentation.cc
FILE: ../../../flutter/flow/instrumentation.h
FILE: ../../../flutter/flow/layers/backdrop_filter_layer.cc
Expand Down Expand Up @@ -102,6 +105,10 @@ FILE: ../../../flutter/flow/scene_update_context.h
FILE: ../../../flutter/flow/skia_gpu_object.cc
FILE: ../../../flutter/flow/skia_gpu_object.h
FILE: ../../../flutter/flow/skia_gpu_object_unittests.cc
FILE: ../../../flutter/flow/surface.cc
FILE: ../../../flutter/flow/surface.h
FILE: ../../../flutter/flow/surface_frame.cc
FILE: ../../../flutter/flow/surface_frame.h
FILE: ../../../flutter/flow/texture.cc
FILE: ../../../flutter/flow/texture.h
FILE: ../../../flutter/flow/texture_unittests.cc
Expand Down Expand Up @@ -576,11 +583,6 @@ FILE: ../../../flutter/shell/common/engine.cc
FILE: ../../../flutter/shell/common/engine.h
FILE: ../../../flutter/shell/common/fixtures/shell_test.dart
FILE: ../../../flutter/shell/common/fixtures/shelltest_screenshot.png
FILE: ../../../flutter/shell/common/gl_context_switch.cc
FILE: ../../../flutter/shell/common/gl_context_switch.h
FILE: ../../../flutter/shell/common/gl_context_switch_test.cc
FILE: ../../../flutter/shell/common/gl_context_switch_test.h
FILE: ../../../flutter/shell/common/gl_context_switch_unittests.cc
FILE: ../../../flutter/shell/common/input_events_unittests.cc
FILE: ../../../flutter/shell/common/isolate_configuration.cc
FILE: ../../../flutter/shell/common/isolate_configuration.h
Expand Down Expand Up @@ -616,10 +618,6 @@ FILE: ../../../flutter/shell/common/shell_test_platform_view_vulkan.h
FILE: ../../../flutter/shell/common/shell_unittests.cc
FILE: ../../../flutter/shell/common/skia_event_tracer_impl.cc
FILE: ../../../flutter/shell/common/skia_event_tracer_impl.h
FILE: ../../../flutter/shell/common/surface.cc
FILE: ../../../flutter/shell/common/surface.h
FILE: ../../../flutter/shell/common/surface_frame.cc
FILE: ../../../flutter/shell/common/surface_frame.h
FILE: ../../../flutter/shell/common/switches.cc
FILE: ../../../flutter/shell/common/switches.h
FILE: ../../../flutter/shell/common/thread_host.cc
Expand Down
10 changes: 9 additions & 1 deletion flow/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ source_set("flow") {
"compositor_context.h",
"embedded_views.cc",
"embedded_views.h",
"gl_context_switch.cc",
"gl_context_switch.h",
"instrumentation.cc",
"instrumentation.h",
"layers/backdrop_filter_layer.cc",
Expand Down Expand Up @@ -62,6 +64,10 @@ source_set("flow") {
"rtree.h",
"skia_gpu_object.cc",
"skia_gpu_object.h",
"surface.cc",
"surface.h",
"surface_frame.cc",
"surface_frame.h",
"texture.cc",
"texture.h",
]
Expand All @@ -73,7 +79,6 @@ source_set("flow") {
deps = [
"//flutter/common",
"//flutter/fml",
"//flutter/shell/common:common_standalone",
"//third_party/skia",
]

Expand Down Expand Up @@ -103,6 +108,8 @@ source_set("flow_testing") {
testonly = true

sources = [
"testing/gl_context_switch_test.cc",
"testing/gl_context_switch_test.h",
"testing/layer_test.h",
"testing/mock_layer.cc",
"testing/mock_layer.h",
Expand All @@ -126,6 +133,7 @@ executable("flow_unittests") {
"flow_run_all_unittests.cc",
"flow_test_utils.cc",
"flow_test_utils.h",
"gl_context_switch_unittests.cc",
"layers/backdrop_filter_layer_unittests.cc",
"layers/clip_path_layer_unittests.cc",
"layers/clip_rect_layer_unittests.cc",
Expand Down
2 changes: 1 addition & 1 deletion flow/embedded_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#include <vector>

#include "flutter/flow/surface_frame.h"
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/raster_thread_merger.h"
#include "flutter/shell/common/surface_frame.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkPoint.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gl_context_switch.h"
#include "flutter/flow/gl_context_switch.h"

namespace flutter {

Expand All @@ -11,16 +11,20 @@ SwitchableGLContext::SwitchableGLContext() = default;
SwitchableGLContext::~SwitchableGLContext() = default;

GLContextResult::GLContextResult() = default;

GLContextResult::~GLContextResult() = default;

GLContextResult::GLContextResult(bool static_result) : result_(static_result){};

bool GLContextResult::GetResult() {
return result_;
};

GLContextDefaultResult::~GLContextDefaultResult() = default;
GLContextDefaultResult::GLContextDefaultResult(bool static_result)
: GLContextResult(static_result){};

GLContextDefaultResult::~GLContextDefaultResult() = default;

GLContextSwitch::GLContextSwitch(std::unique_ptr<SwitchableGLContext> context)
: context_(std::move(context)) {
FML_CHECK(context_ != nullptr);
Expand Down
57 changes: 27 additions & 30 deletions shell/common/gl_context_switch.h → flow/gl_context_switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_SHELL_COMMON_GL_CONTEXT_SWITCH_H_
#define FLUTTER_SHELL_COMMON_GL_CONTEXT_SWITCH_H_
#ifndef FLUTTER_FLOW_GL_CONTEXT_SWITCH_H_
#define FLUTTER_FLOW_GL_CONTEXT_SWITCH_H_

#include <functional>
#include <memory>
Expand All @@ -14,42 +14,39 @@

namespace flutter {

//------------------------------------------------------------------------------
/// An abstract class represents a gl context that can be switched by
/// GLContextSwitch
///
/// The subclass should wrap a "Context" object inside this class. For example,
/// in iOS while using GL rendering surface, the subclass should wrap an
/// |EAGLContext|.
// This interface represents a gl context that can be switched by
// |GLContextSwitch|.
//
// The implementation should wrap a "Context" object inside this class. For
// example, in iOS while using a GL rendering surface, the implementation should
// wrap an |EAGLContext|.
class SwitchableGLContext {
public:
//------------------------------------------------------------------------------
/// Implement this to set the context wrapped by this |SwitchableGLContext|
/// object to the current context.
virtual bool SetCurrent() = 0;

//------------------------------------------------------------------------------
/// Implement this to remove the context wrapped by this |SwitchableGLContext|
/// object from current context;
virtual bool RemoveCurrent() = 0;

SwitchableGLContext();

virtual ~SwitchableGLContext();

// Implement this to set the context wrapped by this |SwitchableGLContext|
// object to the current context.
virtual bool SetCurrent() = 0;

// Implement this to remove the context wrapped by this |SwitchableGLContext|
// object from current context;
virtual bool RemoveCurrent() = 0;

FML_DISALLOW_COPY_AND_ASSIGN(SwitchableGLContext);
};

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

} // namespace flutter

#endif
#endif // FLUTTER_FLOW_GL_CONTEXT_SWITCH_H_
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include <future>
#include <memory>

#include "flutter/shell/common/gl_context_switch.h"
#include "gl_context_switch_test.h"
#include "flutter/flow/gl_context_switch.h"
#include "flutter/flow/testing/gl_context_switch_test.h"
#include "gtest/gtest.h"

namespace flutter {
namespace testing {

TEST_F(GLContextSwitchTest, SwitchKeepsContextCurrentWhileInScope) {
TEST(GLContextSwitchTest, SwitchKeepsContextCurrentWhileInScope) {
{
auto test_gl_context = std::make_unique<TestSwitchableGLContext>(0);
auto context_switch = GLContextSwitch(std::move(test_gl_context));
Expand Down
2 changes: 1 addition & 1 deletion shell/common/surface.cc → flow/surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/common/surface.h"
#include "flutter/flow/surface.h"

namespace flutter {

Expand Down
8 changes: 4 additions & 4 deletions shell/common/surface.h → flow/surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_SHELL_COMMON_SURFACE_H_
#define FLUTTER_SHELL_COMMON_SURFACE_H_
#ifndef FLUTTER_FLOW_SURFACE_H_
#define FLUTTER_FLOW_SURFACE_H_

#include <memory>

#include "flutter/flow/compositor_context.h"
#include "flutter/flow/embedded_views.h"
#include "flutter/flow/surface_frame.h"
#include "flutter/fml/macros.h"
#include "flutter/shell/common/surface_frame.h"

namespace flutter {

Expand Down Expand Up @@ -39,4 +39,4 @@ class Surface {

} // namespace flutter

#endif // FLUTTER_SHELL_COMMON_SURFACE_H_
#endif // FLUTTER_FLOW_SURFACE_H_
2 changes: 1 addition & 1 deletion shell/common/surface_frame.cc → flow/surface_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/common/surface_frame.h"
#include "flutter/flow/surface_frame.h"
#include "flutter/fml/logging.h"

namespace flutter {
Expand Down
12 changes: 6 additions & 6 deletions shell/common/surface_frame.h → flow/surface_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_SHELL_COMMON_SURFACE_FRAME_H_
#define FLUTTER_SHELL_COMMON_SURFACE_FRAME_H_
#ifndef FLUTTER_FLOW_SURFACE_FRAME_H_
#define FLUTTER_FLOW_SURFACE_FRAME_H_

#include <memory>

#include "flutter/flow/gl_context_switch.h"
#include "flutter/fml/macros.h"
#include "flutter/shell/common/gl_context_switch.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkSurface.h"

namespace flutter {

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

} // namespace flutter

#endif // FLUTTER_SHELL_COMMON_SURFACE_FRAME_H_
#endif // FLUTTER_FLOW_SURFACE_FRAME_H_
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef FLUTTER_SHELL_RENDERER_CONTEXT_TEST_H_
#define FLUTTER_SHELL_RENDERER_CONTEXT_TEST_H_

#include "gl_context_switch.h"
#include "flutter/flow/gl_context_switch.h"
#include "gtest/gtest.h"

namespace flutter {
Expand Down Expand Up @@ -43,6 +43,8 @@ class TestSwitchableGLContext : public SwitchableGLContext {

FML_DISALLOW_COPY_AND_ASSIGN(TestSwitchableGLContext);
};

} // namespace testing
} // namespace flutter

#endif // FLUTTER_SHELL_RENDERER_CONTEXT_TEST_H_
21 changes: 0 additions & 21 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ source_set("common") {
"shell_io_manager.h",
"skia_event_tracer_impl.cc",
"skia_event_tracer_impl.h",
"surface.cc",
"surface.h",
"switches.cc",
"switches.h",
"thread_host.cc",
Expand All @@ -118,7 +116,6 @@ source_set("common") {
]

deps = [
":common_standalone",
"//flutter/assets",
"//flutter/common",
"//flutter/flow",
Expand All @@ -140,20 +137,6 @@ source_set("common") {
public_configs = [ "//flutter:config" ]
}

source_set("common_standalone") {
sources = [
"gl_context_switch.cc",
"gl_context_switch.h",
"surface_frame.cc",
"surface_frame.h",
]

deps = [
"//flutter/fml",
"//third_party/skia",
]
}

template("shell_host_executable") {
executable(target_name) {
testonly = true
Expand Down Expand Up @@ -203,9 +186,6 @@ if (enable_unittests) {
testonly = true

sources = [
"gl_context_switch_test.cc",
"gl_context_switch_test.h",
"gl_context_switch_unittests.cc",
"shell_test.cc",
"shell_test.h",
"shell_test_external_view_embedder.cc",
Expand All @@ -217,7 +197,6 @@ if (enable_unittests) {
]

public_deps = [
":common_standalone",
"//flutter/flow",
"//flutter/fml/dart",
"//flutter/lib/ui",
Expand Down
2 changes: 1 addition & 1 deletion shell/common/platform_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <memory>

#include "flutter/common/task_runners.h"
#include "flutter/flow/surface.h"
#include "flutter/flow/texture.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/memory/weak_ptr.h"
Expand All @@ -18,7 +19,6 @@
#include "flutter/lib/ui/window/pointer_data_packet_converter.h"
#include "flutter/lib/ui/window/viewport_metrics.h"
#include "flutter/shell/common/pointer_data_dispatcher.h"
#include "flutter/shell/common/surface.h"
#include "flutter/shell/common/vsync_waiter.h"
#include "third_party/skia/include/core/SkSize.h"
#include "third_party/skia/include/gpu/GrContext.h"
Expand Down
Loading

0 comments on commit 66d85bc

Please sign in to comment.