mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Do nothing if the params didn't change when compositing iOS platform views. (flutter/engine#8999)
This commit is contained in:
parent
f9e3011d9d
commit
33d335d61e
@ -18,6 +18,10 @@ class EmbeddedViewParams {
|
||||
public:
|
||||
SkPoint offsetPixels;
|
||||
SkSize sizePoints;
|
||||
|
||||
bool operator==(const EmbeddedViewParams& other) const {
|
||||
return offsetPixels == other.offsetPixels && sizePoints == other.sizePoints;
|
||||
}
|
||||
};
|
||||
|
||||
// This is only used on iOS when running in a non headless mode,
|
||||
|
||||
@ -187,7 +187,14 @@ SkCanvas* FlutterPlatformViewsController::CompositeEmbeddedView(
|
||||
const flutter::EmbeddedViewParams& params) {
|
||||
// TODO(amirh): assert that this is running on the platform thread once we support the iOS
|
||||
// embedded views thread configuration.
|
||||
// TODO(amirh): do nothing if the params didn't change.
|
||||
|
||||
// Do nothing if the params didn't change.
|
||||
if (current_composition_params_.count(view_id) == 1 &&
|
||||
current_composition_params_[view_id] == params) {
|
||||
return picture_recorders_[view_id]->getRecordingCanvas();
|
||||
}
|
||||
current_composition_params_[view_id] = params;
|
||||
|
||||
CGFloat screenScale = [[UIScreen mainScreen] scale];
|
||||
CGRect rect =
|
||||
CGRectMake(params.offsetPixels.x() / screenScale, params.offsetPixels.y() / screenScale,
|
||||
@ -209,6 +216,7 @@ void FlutterPlatformViewsController::Reset() {
|
||||
composition_order_.clear();
|
||||
active_composition_order_.clear();
|
||||
picture_recorders_.clear();
|
||||
current_composition_params_.clear();
|
||||
}
|
||||
|
||||
bool FlutterPlatformViewsController::SubmitFrame(bool gl_rendering,
|
||||
@ -288,6 +296,7 @@ void FlutterPlatformViewsController::DisposeViews() {
|
||||
views_.erase(viewId);
|
||||
touch_interceptors_.erase(viewId);
|
||||
overlays_.erase(viewId);
|
||||
current_composition_params_.erase(viewId);
|
||||
}
|
||||
views_to_dispose_.clear();
|
||||
}
|
||||
|
||||
@ -88,6 +88,8 @@ class FlutterPlatformViewsController {
|
||||
std::map<std::string, fml::scoped_nsobject<NSObject<FlutterPlatformViewFactory>>> factories_;
|
||||
std::map<int64_t, fml::scoped_nsobject<NSObject<FlutterPlatformView>>> views_;
|
||||
std::map<int64_t, fml::scoped_nsobject<FlutterTouchInterceptingView>> touch_interceptors_;
|
||||
// Mapping a platform view ID to its latest composition params.
|
||||
std::map<int64_t, EmbeddedViewParams> current_composition_params_;
|
||||
std::map<int64_t, std::unique_ptr<FlutterPlatformViewLayer>> overlays_;
|
||||
// The GrContext that is currently used by all of the overlay surfaces.
|
||||
// We track this to know when the GrContext for the Flutter app has changed
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user