Do nothing if the params didn't change when compositing iOS platform views. (flutter/engine#8999)

This commit is contained in:
Chris Yang 2019-06-03 13:08:29 -07:00 committed by GitHub
parent f9e3011d9d
commit 33d335d61e
3 changed files with 16 additions and 1 deletions

View File

@ -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,

View File

@ -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();
}

View File

@ -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