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

Commit cf90132

Browse files
authored
Revert "[Impeller] Reland: Add Impeller Metal support in the embedder API (#42411) (#42545)"
This reverts commit 2b353ae.
1 parent 4e80c6f commit cf90132

File tree

51 files changed

+240
-1154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+240
-1154
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,8 +1485,6 @@ ORIGIN: ../../../flutter/impeller/renderer/backend/metal/surface_mtl.h + ../../.
14851485
ORIGIN: ../../../flutter/impeller/renderer/backend/metal/surface_mtl.mm + ../../../flutter/LICENSE
14861486
ORIGIN: ../../../flutter/impeller/renderer/backend/metal/texture_mtl.h + ../../../flutter/LICENSE
14871487
ORIGIN: ../../../flutter/impeller/renderer/backend/metal/texture_mtl.mm + ../../../flutter/LICENSE
1488-
ORIGIN: ../../../flutter/impeller/renderer/backend/metal/texture_wrapper_mtl.h + ../../../flutter/LICENSE
1489-
ORIGIN: ../../../flutter/impeller/renderer/backend/metal/texture_wrapper_mtl.mm + ../../../flutter/LICENSE
14901488
ORIGIN: ../../../flutter/impeller/renderer/backend/metal/vertex_descriptor_mtl.h + ../../../flutter/LICENSE
14911489
ORIGIN: ../../../flutter/impeller/renderer/backend/metal/vertex_descriptor_mtl.mm + ../../../flutter/LICENSE
14921490
ORIGIN: ../../../flutter/impeller/renderer/backend/vulkan/allocator_vk.cc + ../../../flutter/LICENSE
@@ -2806,19 +2804,13 @@ ORIGIN: ../../../flutter/shell/platform/embedder/embedder_render_target.cc + ../
28062804
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_render_target.h + ../../../flutter/LICENSE
28072805
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_render_target_cache.cc + ../../../flutter/LICENSE
28082806
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_render_target_cache.h + ../../../flutter/LICENSE
2809-
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_render_target_impeller.cc + ../../../flutter/LICENSE
2810-
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_render_target_impeller.h + ../../../flutter/LICENSE
2811-
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_render_target_skia.cc + ../../../flutter/LICENSE
2812-
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_render_target_skia.h + ../../../flutter/LICENSE
28132807
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_struct_macros.h + ../../../flutter/LICENSE
28142808
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface.cc + ../../../flutter/LICENSE
28152809
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface.h + ../../../flutter/LICENSE
28162810
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_gl.cc + ../../../flutter/LICENSE
28172811
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_gl.h + ../../../flutter/LICENSE
28182812
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_metal.h + ../../../flutter/LICENSE
28192813
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_metal.mm + ../../../flutter/LICENSE
2820-
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_metal_impeller.h + ../../../flutter/LICENSE
2821-
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_metal_impeller.mm + ../../../flutter/LICENSE
28222814
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_software.cc + ../../../flutter/LICENSE
28232815
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_software.h + ../../../flutter/LICENSE
28242816
ORIGIN: ../../../flutter/shell/platform/embedder/embedder_surface_vulkan.cc + ../../../flutter/LICENSE
@@ -4162,8 +4154,6 @@ FILE: ../../../flutter/impeller/renderer/backend/metal/surface_mtl.h
41624154
FILE: ../../../flutter/impeller/renderer/backend/metal/surface_mtl.mm
41634155
FILE: ../../../flutter/impeller/renderer/backend/metal/texture_mtl.h
41644156
FILE: ../../../flutter/impeller/renderer/backend/metal/texture_mtl.mm
4165-
FILE: ../../../flutter/impeller/renderer/backend/metal/texture_wrapper_mtl.h
4166-
FILE: ../../../flutter/impeller/renderer/backend/metal/texture_wrapper_mtl.mm
41674157
FILE: ../../../flutter/impeller/renderer/backend/metal/vertex_descriptor_mtl.h
41684158
FILE: ../../../flutter/impeller/renderer/backend/metal/vertex_descriptor_mtl.mm
41694159
FILE: ../../../flutter/impeller/renderer/backend/vulkan/allocator_vk.cc
@@ -5499,19 +5489,13 @@ FILE: ../../../flutter/shell/platform/embedder/embedder_render_target.cc
54995489
FILE: ../../../flutter/shell/platform/embedder/embedder_render_target.h
55005490
FILE: ../../../flutter/shell/platform/embedder/embedder_render_target_cache.cc
55015491
FILE: ../../../flutter/shell/platform/embedder/embedder_render_target_cache.h
5502-
FILE: ../../../flutter/shell/platform/embedder/embedder_render_target_impeller.cc
5503-
FILE: ../../../flutter/shell/platform/embedder/embedder_render_target_impeller.h
5504-
FILE: ../../../flutter/shell/platform/embedder/embedder_render_target_skia.cc
5505-
FILE: ../../../flutter/shell/platform/embedder/embedder_render_target_skia.h
55065492
FILE: ../../../flutter/shell/platform/embedder/embedder_struct_macros.h
55075493
FILE: ../../../flutter/shell/platform/embedder/embedder_surface.cc
55085494
FILE: ../../../flutter/shell/platform/embedder/embedder_surface.h
55095495
FILE: ../../../flutter/shell/platform/embedder/embedder_surface_gl.cc
55105496
FILE: ../../../flutter/shell/platform/embedder/embedder_surface_gl.h
55115497
FILE: ../../../flutter/shell/platform/embedder/embedder_surface_metal.h
55125498
FILE: ../../../flutter/shell/platform/embedder/embedder_surface_metal.mm
5513-
FILE: ../../../flutter/shell/platform/embedder/embedder_surface_metal_impeller.h
5514-
FILE: ../../../flutter/shell/platform/embedder/embedder_surface_metal_impeller.mm
55155499
FILE: ../../../flutter/shell/platform/embedder/embedder_surface_software.cc
55165500
FILE: ../../../flutter/shell/platform/embedder/embedder_surface_software.h
55175501
FILE: ../../../flutter/shell/platform/embedder/embedder_surface_vulkan.cc

flow/BUILD.gn

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import("//build/fuchsia/sdk.gni")
66
import("//flutter/common/config.gni")
7-
import("//flutter/impeller/tools/impeller.gni")
87
import("//flutter/shell/config.gni")
98
import("//flutter/testing/testing.gni")
109

@@ -97,10 +96,6 @@ source_set("flow") {
9796
"//third_party/skia",
9897
]
9998

100-
if (impeller_supports_rendering) {
101-
deps += [ "//flutter/impeller" ]
102-
}
103-
10499
public_deps = [ "//flutter/display_list" ]
105100
}
106101

flow/embedded_views.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ bool DisplayListEmbedderViewSlice::recording_ended() {
4242
return builder_ == nullptr;
4343
}
4444

45-
void ExternalViewEmbedder::SubmitFrame(
46-
GrDirectContext* context,
47-
const std::shared_ptr<impeller::AiksContext>& aiks_context,
48-
std::unique_ptr<SurfaceFrame> frame) {
45+
void ExternalViewEmbedder::SubmitFrame(GrDirectContext* context,
46+
std::unique_ptr<SurfaceFrame> frame) {
4947
frame->Submit();
5048
};
5149

flow/embedded_views.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#ifndef FLUTTER_FLOW_EMBEDDED_VIEWS_H_
66
#define FLUTTER_FLOW_EMBEDDED_VIEWS_H_
77

8-
#include <memory>
98
#include <vector>
109

1110
#include "flutter/display_list/dl_builder.h"
@@ -23,16 +22,6 @@
2322
#include "third_party/skia/include/core/SkSize.h"
2423
#include "third_party/skia/include/core/SkSurface.h"
2524

26-
#if IMPELLER_SUPPORTS_RENDERING
27-
#include "flutter/impeller/aiks/aiks_context.h" // nogncheck
28-
#include "flutter/impeller/renderer/context.h" // nogncheck
29-
#else // IMPELLER_SUPPORTS_RENDERING
30-
namespace impeller {
31-
class Context;
32-
class AiksContext;
33-
} // namespace impeller
34-
#endif // !IMPELLER_SUPPORTS_RENDERING
35-
3625
class GrDirectContext;
3726

3827
namespace flutter {
@@ -425,10 +414,8 @@ class ExternalViewEmbedder {
425414
// This method can mutate the root Skia canvas before submitting the frame.
426415
//
427416
// It can also allocate frames for overlay surfaces to compose hybrid views.
428-
virtual void SubmitFrame(
429-
GrDirectContext* context,
430-
const std::shared_ptr<impeller::AiksContext>& aiks_context,
431-
std::unique_ptr<SurfaceFrame> frame);
417+
virtual void SubmitFrame(GrDirectContext* context,
418+
std::unique_ptr<SurfaceFrame> frame);
432419

433420
// This method provides the embedder a way to do additional tasks after
434421
// |SubmitFrame|. For example, merge task runners if `should_resubmit_frame`

impeller/playground/backend/metal/playground_impl_mtl.mm

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

122122
auto drawable =
123123
SurfaceMTL::GetMetalDrawableAndValidate(context, data_->metal_layer);
124-
return SurfaceMTL::MakeFromMetalLayerDrawable(context, drawable);
124+
return SurfaceMTL::WrapCurrentMetalLayerDrawable(context, drawable);
125125
}
126126

127127
} // namespace impeller

impeller/renderer/backend/metal/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ impeller_component("metal") {
4242
"surface_mtl.mm",
4343
"texture_mtl.h",
4444
"texture_mtl.mm",
45-
"texture_wrapper_mtl.h",
46-
"texture_wrapper_mtl.mm",
4745
"vertex_descriptor_mtl.h",
4846
"vertex_descriptor_mtl.mm",
4947
]

impeller/renderer/backend/metal/context_mtl.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
#include "impeller/renderer/capabilities.h"
2222
#include "impeller/renderer/context.h"
2323

24-
#if TARGET_OS_SIMULATOR
25-
#define IMPELLER_CA_METAL_LAYER_AVAILABLE API_AVAILABLE(macos(10.11), ios(13.0))
26-
#else // TARGET_OS_SIMULATOR
27-
#define IMPELLER_CA_METAL_LAYER_AVAILABLE API_AVAILABLE(macos(10.11), ios(8.0))
28-
#endif // TARGET_OS_SIMULATOR
29-
3024
namespace impeller {
3125

3226
class ContextMTL final : public Context,
@@ -44,14 +38,6 @@ class ContextMTL final : public Context,
4438
std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch,
4539
const std::string& label);
4640

47-
static std::shared_ptr<ContextMTL> Create(
48-
id<MTLDevice> device,
49-
id<MTLCommandQueue> command_queue,
50-
const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries_data,
51-
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner,
52-
std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch,
53-
const std::string& label);
54-
5541
// |Context|
5642
~ContextMTL() override;
5743

@@ -104,7 +90,6 @@ class ContextMTL final : public Context,
10490

10591
ContextMTL(
10692
id<MTLDevice> device,
107-
id<MTLCommandQueue> command_queue,
10893
NSArray<id<MTLLibrary>>* shader_libraries,
10994
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner,
11095
std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch);

impeller/renderer/backend/metal/context_mtl.mm

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
#include <Foundation/Foundation.h>
88

9-
#include "flutter/fml/concurrent_message_loop.h"
109
#include "flutter/fml/file.h"
1110
#include "flutter/fml/logging.h"
1211
#include "flutter/fml/paths.h"
13-
#include "flutter/fml/synchronization/sync_switch.h"
1412
#include "impeller/core/sampler_descriptor.h"
1513
#include "impeller/renderer/backend/metal/sampler_library_mtl.h"
1614
#include "impeller/renderer/capabilities.h"
@@ -69,12 +67,10 @@ static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
6967

7068
ContextMTL::ContextMTL(
7169
id<MTLDevice> device,
72-
id<MTLCommandQueue> command_queue,
7370
NSArray<id<MTLLibrary>>* shader_libraries,
7471
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner,
7572
std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch)
7673
: device_(device),
77-
command_queue_(command_queue),
7874
worker_task_runner_(std::move(worker_task_runner)),
7975
is_gpu_disabled_sync_switch_(std::move(is_gpu_disabled_sync_switch)) {
8076
// Validate device.
@@ -100,6 +96,16 @@ static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
10096
shader_library_ = std::move(library);
10197
}
10298

99+
// Setup command queue.
100+
{
101+
command_queue_ = device_.newCommandQueue;
102+
if (!command_queue_) {
103+
VALIDATION_LOG << "Could not setup the command queue.";
104+
return;
105+
}
106+
command_queue_.label = @"Impeller Command Queue";
107+
}
108+
103109
// Setup the pipeline library.
104110
{
105111
pipeline_library_ =
@@ -198,28 +204,13 @@ static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
198204
return ::MTLCreateSystemDefaultDevice();
199205
}
200206

201-
static id<MTLCommandQueue> CreateMetalCommandQueue(id<MTLDevice> device) {
202-
auto command_queue = device.newCommandQueue;
203-
if (!command_queue) {
204-
VALIDATION_LOG << "Could not setup the command queue.";
205-
return nullptr;
206-
}
207-
command_queue.label = @"Impeller Command Queue";
208-
return command_queue;
209-
}
210-
211207
std::shared_ptr<ContextMTL> ContextMTL::Create(
212208
const std::vector<std::string>& shader_library_paths,
213209
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner,
214210
std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch) {
215211
auto device = CreateMetalDevice();
216-
auto command_queue = CreateMetalCommandQueue(device);
217-
if (!command_queue) {
218-
return nullptr;
219-
}
220212
auto context = std::shared_ptr<ContextMTL>(new ContextMTL(
221-
device, command_queue,
222-
MTLShaderLibraryFromFilePaths(device, shader_library_paths),
213+
device, MTLShaderLibraryFromFilePaths(device, shader_library_paths),
223214
std::move(worker_task_runner), std::move(is_gpu_disabled_sync_switch)));
224215
if (!context->IsValid()) {
225216
FML_LOG(ERROR) << "Could not create Metal context.";
@@ -232,35 +223,11 @@ static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
232223
const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries_data,
233224
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner,
234225
std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch,
235-
const std::string& library_label) {
226+
const std::string& label) {
236227
auto device = CreateMetalDevice();
237-
auto command_queue = CreateMetalCommandQueue(device);
238-
if (!command_queue) {
239-
return nullptr;
240-
}
241-
auto context = std::shared_ptr<ContextMTL>(new ContextMTL(
242-
device, command_queue,
243-
MTLShaderLibraryFromFileData(device, shader_libraries_data,
244-
library_label),
245-
std::move(worker_task_runner), std::move(is_gpu_disabled_sync_switch)));
246-
if (!context->IsValid()) {
247-
FML_LOG(ERROR) << "Could not create Metal context.";
248-
return nullptr;
249-
}
250-
return context;
251-
}
252-
253-
std::shared_ptr<ContextMTL> ContextMTL::Create(
254-
id<MTLDevice> device,
255-
id<MTLCommandQueue> command_queue,
256-
const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries_data,
257-
std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner,
258-
std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch,
259-
const std::string& library_label) {
260228
auto context = std::shared_ptr<ContextMTL>(new ContextMTL(
261-
device, command_queue,
262-
MTLShaderLibraryFromFileData(device, shader_libraries_data,
263-
library_label),
229+
device,
230+
MTLShaderLibraryFromFileData(device, shader_libraries_data, label),
264231
std::move(worker_task_runner), std::move(is_gpu_disabled_sync_switch)));
265232
if (!context->IsValid()) {
266233
FML_LOG(ERROR) << "Could not create Metal context.";

impeller/renderer/backend/metal/surface_mtl.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#pragma once
66

77
#include <QuartzCore/CAMetalLayer.h>
8-
#include <memory>
98

109
#include "flutter/fml/macros.h"
1110
#include "impeller/geometry/rect.h"
@@ -38,15 +37,10 @@ class SurfaceMTL final : public Surface {
3837
const std::shared_ptr<Context>& context,
3938
CAMetalLayer* layer);
4039

41-
static std::unique_ptr<SurfaceMTL> MakeFromMetalLayerDrawable(
40+
static std::unique_ptr<SurfaceMTL> WrapCurrentMetalLayerDrawable(
4241
const std::shared_ptr<Context>& context,
4342
id<CAMetalDrawable> drawable,
4443
std::optional<IRect> clip_rect = std::nullopt);
45-
46-
static std::unique_ptr<SurfaceMTL> MakeFromTexture(
47-
const std::shared_ptr<Context>& context,
48-
id<MTLTexture> texture,
49-
std::optional<IRect> clip_rect);
5044
#pragma GCC diagnostic pop
5145

5246
// |Surface|
@@ -64,8 +58,6 @@ class SurfaceMTL final : public Surface {
6458
std::weak_ptr<Context> context_;
6559
std::shared_ptr<Texture> resolve_texture_;
6660
id<CAMetalDrawable> drawable_ = nil;
67-
std::shared_ptr<Texture> source_texture_;
68-
std::shared_ptr<Texture> destination_texture_;
6961
bool requires_blit_ = false;
7062
std::optional<IRect> clip_rect_;
7163

@@ -75,8 +67,6 @@ class SurfaceMTL final : public Surface {
7567
const RenderTarget& target,
7668
std::shared_ptr<Texture> resolve_texture,
7769
id<CAMetalDrawable> drawable,
78-
std::shared_ptr<Texture> source_texture,
79-
std::shared_ptr<Texture> destination_texture,
8070
bool requires_blit,
8171
std::optional<IRect> clip_rect);
8272

0 commit comments

Comments
 (0)