make EmbeddedViewParams a unique ptr (flutter/engine#9640)
This commit is contained in:
@@ -190,8 +190,9 @@ class ExternalViewEmbedder {
|
||||
virtual std::vector<SkCanvas*> GetCurrentCanvases() = 0;
|
||||
|
||||
// Must be called on the UI thread.
|
||||
virtual SkCanvas* CompositeEmbeddedView(int view_id,
|
||||
const EmbeddedViewParams& params) = 0;
|
||||
virtual SkCanvas* CompositeEmbeddedView(
|
||||
int view_id,
|
||||
std::unique_ptr<flutter::EmbeddedViewParams> params) = 0;
|
||||
|
||||
virtual bool SubmitFrame(GrContext* context);
|
||||
|
||||
|
||||
@@ -32,15 +32,16 @@ void PlatformViewLayer::Paint(PaintContext& context) const {
|
||||
"does not support embedding";
|
||||
return;
|
||||
}
|
||||
EmbeddedViewParams params;
|
||||
std::unique_ptr<EmbeddedViewParams> params =
|
||||
std::make_unique<EmbeddedViewParams>();
|
||||
SkMatrix transform = context.leaf_nodes_canvas->getTotalMatrix();
|
||||
params.offsetPixels =
|
||||
params->offsetPixels =
|
||||
SkPoint::Make(transform.getTranslateX(), transform.getTranslateY());
|
||||
params.sizePoints = size_;
|
||||
params.mutatorsStack = context.mutators_stack;
|
||||
params->sizePoints = size_;
|
||||
params->mutatorsStack = context.mutators_stack;
|
||||
|
||||
SkCanvas* canvas =
|
||||
context.view_embedder->CompositeEmbeddedView(view_id_, params);
|
||||
context.view_embedder->CompositeEmbeddedView(view_id_, std::move(params));
|
||||
context.leaf_nodes_canvas = canvas;
|
||||
}
|
||||
} // namespace flutter
|
||||
|
||||
@@ -231,7 +231,6 @@ UIView* FlutterPlatformViewsController::ReconstructClipViewsChain(int number_of_
|
||||
void FlutterPlatformViewsController::ApplyMutators(const MutatorsStack& mutators_stack,
|
||||
UIView* embedded_view) {
|
||||
FML_DCHECK(CATransform3DEqualToTransform(embedded_view.layer.transform, CATransform3DIdentity));
|
||||
|
||||
UIView* head = embedded_view;
|
||||
head.clipsToBounds = YES;
|
||||
ResetAnchor(head.layer);
|
||||
@@ -275,13 +274,13 @@ void FlutterPlatformViewsController::ApplyMutators(const MutatorsStack& mutators
|
||||
|
||||
void FlutterPlatformViewsController::CompositeWithParams(
|
||||
int view_id,
|
||||
const flutter::EmbeddedViewParams& params) {
|
||||
CGRect frame = CGRectMake(0, 0, params.sizePoints.width(), params.sizePoints.height());
|
||||
std::unique_ptr<flutter::EmbeddedViewParams> params) {
|
||||
CGRect frame = CGRectMake(0, 0, params->sizePoints.width(), params->sizePoints.height());
|
||||
UIView* touchInterceptor = touch_interceptors_[view_id].get();
|
||||
touchInterceptor.layer.transform = CATransform3DIdentity;
|
||||
touchInterceptor.frame = frame;
|
||||
|
||||
int currentClippingCount = CountClips(params.mutatorsStack);
|
||||
int currentClippingCount = CountClips(params->mutatorsStack);
|
||||
int previousClippingCount = clip_count_[view_id];
|
||||
if (currentClippingCount != previousClippingCount) {
|
||||
clip_count_[view_id] = currentClippingCount;
|
||||
@@ -292,22 +291,22 @@ void FlutterPlatformViewsController::CompositeWithParams(
|
||||
ReconstructClipViewsChain(currentClippingCount, touchInterceptor, oldPlatformViewRoot);
|
||||
root_views_[view_id] = fml::scoped_nsobject<UIView>([newPlatformViewRoot retain]);
|
||||
}
|
||||
ApplyMutators(params.mutatorsStack, touchInterceptor);
|
||||
ApplyMutators(params->mutatorsStack, touchInterceptor);
|
||||
}
|
||||
|
||||
SkCanvas* FlutterPlatformViewsController::CompositeEmbeddedView(
|
||||
int view_id,
|
||||
const flutter::EmbeddedViewParams& params) {
|
||||
std::unique_ptr<flutter::EmbeddedViewParams> params) {
|
||||
// TODO(amirh): assert that this is running on the platform thread once we support the iOS
|
||||
// embedded views thread configuration.
|
||||
|
||||
// Do nothing if the params didn't change.
|
||||
if (current_composition_params_.count(view_id) == 1 &&
|
||||
current_composition_params_[view_id] == params) {
|
||||
current_composition_params_[view_id] == *params.get()) {
|
||||
return picture_recorders_[view_id]->getRecordingCanvas();
|
||||
}
|
||||
current_composition_params_[view_id] = EmbeddedViewParams(params);
|
||||
CompositeWithParams(view_id, params);
|
||||
current_composition_params_[view_id] = EmbeddedViewParams(*params.get());
|
||||
CompositeWithParams(view_id, std::move(params));
|
||||
|
||||
return picture_recorders_[view_id]->getRecordingCanvas();
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class FlutterPlatformViewsController {
|
||||
|
||||
std::vector<SkCanvas*> GetCurrentCanvases();
|
||||
|
||||
SkCanvas* CompositeEmbeddedView(int view_id, const flutter::EmbeddedViewParams& params);
|
||||
SkCanvas* CompositeEmbeddedView(int view_id, std::unique_ptr<flutter::EmbeddedViewParams> params);
|
||||
|
||||
// Discards all platform views instances and auxiliary resources.
|
||||
void Reset();
|
||||
@@ -184,7 +184,7 @@ class FlutterPlatformViewsController {
|
||||
//
|
||||
// After each clip operation, we update the head to the super view of the current head.
|
||||
void ApplyMutators(const MutatorsStack& mutators_stack, UIView* embedded_view);
|
||||
void CompositeWithParams(int view_id, const flutter::EmbeddedViewParams& params);
|
||||
void CompositeWithParams(int view_id, std::unique_ptr<flutter::EmbeddedViewParams> params);
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(FlutterPlatformViewsController);
|
||||
};
|
||||
|
||||
@@ -61,7 +61,8 @@ class IOSSurfaceGL final : public IOSSurface,
|
||||
std::vector<SkCanvas*> GetCurrentCanvases() override;
|
||||
|
||||
// |flutter::ExternalViewEmbedder|
|
||||
SkCanvas* CompositeEmbeddedView(int view_id, const flutter::EmbeddedViewParams& params) override;
|
||||
SkCanvas* CompositeEmbeddedView(int view_id,
|
||||
std::unique_ptr<flutter::EmbeddedViewParams> params) override;
|
||||
|
||||
// |flutter::ExternalViewEmbedder|
|
||||
bool SubmitFrame(GrContext* context) override;
|
||||
|
||||
@@ -102,10 +102,10 @@ std::vector<SkCanvas*> IOSSurfaceGL::GetCurrentCanvases() {
|
||||
}
|
||||
|
||||
SkCanvas* IOSSurfaceGL::CompositeEmbeddedView(int view_id,
|
||||
const flutter::EmbeddedViewParams& params) {
|
||||
std::unique_ptr<flutter::EmbeddedViewParams> params) {
|
||||
FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController();
|
||||
FML_CHECK(platform_views_controller != nullptr);
|
||||
return platform_views_controller->CompositeEmbeddedView(view_id, params);
|
||||
return platform_views_controller->CompositeEmbeddedView(view_id, std::move(params));
|
||||
}
|
||||
|
||||
bool IOSSurfaceGL::SubmitFrame(GrContext* context) {
|
||||
|
||||
@@ -55,7 +55,8 @@ class IOSSurfaceSoftware final : public IOSSurface,
|
||||
std::vector<SkCanvas*> GetCurrentCanvases() override;
|
||||
|
||||
// |flutter::ExternalViewEmbedder|
|
||||
SkCanvas* CompositeEmbeddedView(int view_id, const flutter::EmbeddedViewParams& params) override;
|
||||
SkCanvas* CompositeEmbeddedView(int view_id,
|
||||
std::unique_ptr<flutter::EmbeddedViewParams> params) override;
|
||||
|
||||
// |flutter::ExternalViewEmbedder|
|
||||
bool SubmitFrame(GrContext* context) override;
|
||||
|
||||
@@ -153,11 +153,12 @@ std::vector<SkCanvas*> IOSSurfaceSoftware::GetCurrentCanvases() {
|
||||
return platform_views_controller->GetCurrentCanvases();
|
||||
}
|
||||
|
||||
SkCanvas* IOSSurfaceSoftware::CompositeEmbeddedView(int view_id,
|
||||
const flutter::EmbeddedViewParams& params) {
|
||||
SkCanvas* IOSSurfaceSoftware::CompositeEmbeddedView(
|
||||
int view_id,
|
||||
std::unique_ptr<flutter::EmbeddedViewParams> params) {
|
||||
FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController();
|
||||
FML_CHECK(platform_views_controller != nullptr);
|
||||
return platform_views_controller->CompositeEmbeddedView(view_id, params);
|
||||
return platform_views_controller->CompositeEmbeddedView(view_id, std::move(params));
|
||||
}
|
||||
|
||||
bool IOSSurfaceSoftware::SubmitFrame(GrContext* context) {
|
||||
|
||||
Reference in New Issue
Block a user