-
Notifications
You must be signed in to change notification settings - Fork 6k
Implement asynchronous texture uploads when using the Metal backend on iOS. #17039
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ class GPUSurfaceGL : public Surface { | |
| GPUSurfaceGLDelegate* delegate, | ||
| bool render_to_surface); | ||
|
|
||
| // |Surface| | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar nit on these. |
||
| ~GPUSurfaceGL() override; | ||
|
|
||
| // |Surface| | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,6 @@ | |
| #include "flutter/shell/common/rasterizer.h" | ||
| #include "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h" | ||
| #include "flutter/shell/platform/darwin/ios/ios_surface_gl.h" | ||
| #if FLUTTER_SHELL_ENABLE_METAL | ||
| #include "flutter/shell/platform/darwin/ios/ios_surface_metal.h" | ||
| #endif | ||
| #include "flutter/shell/platform/darwin/ios/ios_surface_software.h" | ||
| #include "third_party/skia/include/utils/mac/SkCGUtils.h" | ||
|
|
||
|
|
@@ -50,18 +47,10 @@ - (instancetype)init { | |
| - (instancetype)initWithContentsScale:(CGFloat)contentsScale { | ||
| self = [self init]; | ||
|
|
||
| if ([self.layer isKindOfClass:[CAEAGLLayer class]]) { | ||
| CAEAGLLayer* layer = reinterpret_cast<CAEAGLLayer*>(self.layer); | ||
| layer.allowsGroupOpacity = NO; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we dropping this here? According to https://developer.apple.com/documentation/quartzcore/calayer/1621277-allowsgroupopacity?language=objc this defaults to |
||
| layer.contentsScale = contentsScale; | ||
| layer.rasterizationScale = contentsScale; | ||
| #if FLUTTER_SHELL_ENABLE_METAL | ||
| } else if ([self.layer isKindOfClass:[CAMetalLayer class]]) { | ||
| CAMetalLayer* layer = reinterpret_cast<CAMetalLayer*>(self.layer); | ||
| layer.allowsGroupOpacity = NO; | ||
| layer.contentsScale = contentsScale; | ||
| layer.rasterizationScale = contentsScale; | ||
| #endif // FLUTTER_SHELL_ENABLE_METAL | ||
| if ([self.layer isKindOfClass:[CAEAGLLayer class]] || | ||
| [self.layer isKindOfClass:[CAMetalLayer class]]) { | ||
| self.layer.contentsScale = contentsScale; | ||
| self.layer.rasterizationScale = contentsScale; | ||
| } | ||
|
|
||
| return self; | ||
|
|
@@ -72,27 +61,11 @@ + (Class)layerClass { | |
| } | ||
|
|
||
| - (std::unique_ptr<flutter::IOSSurface>)createSurface: | ||
| (std::shared_ptr<flutter::IOSGLContext>)gl_context { | ||
| if ([self.layer isKindOfClass:[CAEAGLLayer class]]) { | ||
| fml::scoped_nsobject<CAEAGLLayer> eagl_layer( | ||
| reinterpret_cast<CAEAGLLayer*>([self.layer retain])); | ||
| if (@available(iOS 9.0, *)) { | ||
| eagl_layer.get().presentsWithTransaction = YES; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this break platform views on iOS? |
||
| } | ||
| return std::make_unique<flutter::IOSSurfaceGL>(std::move(eagl_layer), gl_context); | ||
| #if FLUTTER_SHELL_ENABLE_METAL | ||
| } else if ([self.layer isKindOfClass:[CAMetalLayer class]]) { | ||
| fml::scoped_nsobject<CAMetalLayer> metalLayer( | ||
| reinterpret_cast<CAMetalLayer*>([self.layer retain])); | ||
| if (@available(iOS 8.0, *)) { | ||
| metalLayer.get().presentsWithTransaction = YES; | ||
| } | ||
| return std::make_unique<flutter::IOSSurfaceMetal>(std::move(metalLayer)); | ||
| #endif // FLUTTER_SHELL_ENABLE_METAL | ||
| } else { | ||
| fml::scoped_nsobject<CALayer> layer(reinterpret_cast<CALayer*>([self.layer retain])); | ||
| return std::make_unique<flutter::IOSSurfaceSoftware>(std::move(layer), nullptr); | ||
| } | ||
| (std::shared_ptr<flutter::IOSContext>)ios_context { | ||
| return flutter::IOSSurface::Create(std::move(ios_context), // context | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will now throw if we're on a simulator, right? |
||
| fml::scoped_nsobject<CALayer>{[self.layer retain]}, // layer | ||
| nullptr // platform views controller | ||
| ); | ||
| } | ||
|
|
||
| // TODO(amirh): implement drawLayer to support snapshotting. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit can we split tracing that does not depend on this PR into a separate PR?
We've had some issues recently where adding more tracing has run into timeouts in the devicelab, and if that happens here it'll be nice to know that's all it is and not some other change in this PR.
Also, if this has to get reverted for some reason the tracing will stay.