diff --git a/flow/embedded_views.cc b/flow/embedded_views.cc index 737288136ab71..e6ce73fdeef94 100644 --- a/flow/embedded_views.cc +++ b/flow/embedded_views.cc @@ -10,37 +10,37 @@ bool ExternalViewEmbedder::SubmitFrame(GrContext* context) { return false; }; -void MutatorsStack::pushClipRect(const SkRect& rect) { +void MutatorsStack::PushClipRect(const SkRect& rect) { std::shared_ptr element = std::make_shared(rect); vector_.push_back(element); }; -void MutatorsStack::pushClipRRect(const SkRRect& rrect) { +void MutatorsStack::PushClipRRect(const SkRRect& rrect) { std::shared_ptr element = std::make_shared(rrect); vector_.push_back(element); }; -void MutatorsStack::pushClipPath(const SkPath& path) { +void MutatorsStack::PushClipPath(const SkPath& path) { std::shared_ptr element = std::make_shared(path); vector_.push_back(element); }; -void MutatorsStack::pushTransform(const SkMatrix& matrix) { +void MutatorsStack::PushTransform(const SkMatrix& matrix) { std::shared_ptr element = std::make_shared(matrix); vector_.push_back(element); }; -void MutatorsStack::pop() { +void MutatorsStack::Pop() { vector_.pop_back(); }; const std::vector>::const_reverse_iterator -MutatorsStack::top() const { +MutatorsStack::Top() const { return vector_.rend(); }; const std::vector>::const_reverse_iterator -MutatorsStack::bottom() const { +MutatorsStack::Bottom() const { return vector_.rbegin(); }; diff --git a/flow/embedded_views.h b/flow/embedded_views.h index 1b641665e3690..8f35f64238939 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -54,27 +54,25 @@ class Mutator { explicit Mutator(const SkMatrix& matrix) : type_(transform), matrix_(matrix) {} - const MutatorType& type() const { return type_; } - const SkRect& rect() const { return rect_; } - const SkRRect& rrect() const { return rrect_; } - const SkPath& path() const { return *path_; } - const SkMatrix& matrix() const { return matrix_; } + const MutatorType& GetType() const { return type_; } + const SkRect& GetRect() const { return rect_; } + const SkRRect& GetRRect() const { return rrect_; } + const SkPath& GetPath() const { return *path_; } + const SkMatrix& GetMatrix() const { return matrix_; } bool operator==(const Mutator& other) const { if (type_ != other.type_) { return false; } - if (type_ == clip_rect && rect_ == other.rect_) { - return true; - } - if (type_ == clip_rrect && rrect_ == other.rrect_) { - return true; - } - if (type_ == clip_path && *path_ == *other.path_) { - return true; - } - if (type_ == transform && matrix_ == other.matrix_) { - return true; + switch (type_) { + case clip_rect: + return rect_ == other.rect_; + case clip_rrect: + return rrect_ == other.rrect_; + case clip_path: + return *path_ == *other.path_; + case transform: + return matrix_ == other.matrix_; } return false; @@ -82,7 +80,7 @@ class Mutator { bool operator!=(const Mutator& other) const { return !operator==(other); } - bool isClipType() { + bool IsClipType() { return type_ == clip_rect || type_ == clip_rrect || type_ == clip_path; } @@ -117,20 +115,20 @@ class MutatorsStack { public: MutatorsStack() = default; - void pushClipRect(const SkRect& rect); - void pushClipRRect(const SkRRect& rrect); - void pushClipPath(const SkPath& path); - void pushTransform(const SkMatrix& matrix); + void PushClipRect(const SkRect& rect); + void PushClipRRect(const SkRRect& rrect); + void PushClipPath(const SkPath& path); + void PushTransform(const SkMatrix& matrix); // Removes the `Mutator` on the top of the stack // and destroys it. - void pop(); + void Pop(); // Returns an iterator pointing to the top of the stack. - const std::vector>::const_reverse_iterator top() + const std::vector>::const_reverse_iterator Top() const; // Returns an iterator pointing to the bottom of the stack. - const std::vector>::const_reverse_iterator bottom() + const std::vector>::const_reverse_iterator Bottom() const; bool operator==(const MutatorsStack& other) const { diff --git a/flow/layers/clip_path_layer.cc b/flow/layers/clip_path_layer.cc index cb7c8454e4743..c81b3a2190182 100644 --- a/flow/layers/clip_path_layer.cc +++ b/flow/layers/clip_path_layer.cc @@ -23,14 +23,14 @@ void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkRect previous_cull_rect = context->cull_rect; SkRect clip_path_bounds = clip_path_.getBounds(); if (context->cull_rect.intersect(clip_path_bounds)) { - context->mutators_stack.pushClipPath(clip_path_); + context->mutators_stack.PushClipPath(clip_path_); SkRect child_paint_bounds = SkRect::MakeEmpty(); PrerollChildren(context, matrix, &child_paint_bounds); if (child_paint_bounds.intersect(clip_path_bounds)) { set_paint_bounds(child_paint_bounds); } - context->mutators_stack.pop(); + context->mutators_stack.Pop(); } context->cull_rect = previous_cull_rect; } diff --git a/flow/layers/clip_rect_layer.cc b/flow/layers/clip_rect_layer.cc index 3f6cda5954be0..084b0957c1ac9 100644 --- a/flow/layers/clip_rect_layer.cc +++ b/flow/layers/clip_rect_layer.cc @@ -16,14 +16,14 @@ ClipRectLayer::~ClipRectLayer() = default; void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkRect previous_cull_rect = context->cull_rect; if (context->cull_rect.intersect(clip_rect_)) { - context->mutators_stack.pushClipRect(clip_rect_); + context->mutators_stack.PushClipRect(clip_rect_); SkRect child_paint_bounds = SkRect::MakeEmpty(); PrerollChildren(context, matrix, &child_paint_bounds); if (child_paint_bounds.intersect(clip_rect_)) { set_paint_bounds(child_paint_bounds); } - context->mutators_stack.pop(); + context->mutators_stack.Pop(); } context->cull_rect = previous_cull_rect; } diff --git a/flow/layers/clip_rrect_layer.cc b/flow/layers/clip_rrect_layer.cc index 7cd7dd24d1ee7..d810bb70f7448 100644 --- a/flow/layers/clip_rrect_layer.cc +++ b/flow/layers/clip_rrect_layer.cc @@ -17,14 +17,14 @@ void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkRect previous_cull_rect = context->cull_rect; SkRect clip_rrect_bounds = clip_rrect_.getBounds(); if (context->cull_rect.intersect(clip_rrect_bounds)) { - context->mutators_stack.pushClipRRect(clip_rrect_); + context->mutators_stack.PushClipRRect(clip_rrect_); SkRect child_paint_bounds = SkRect::MakeEmpty(); PrerollChildren(context, matrix, &child_paint_bounds); if (child_paint_bounds.intersect(clip_rrect_bounds)) { set_paint_bounds(child_paint_bounds); } - context->mutators_stack.pop(); + context->mutators_stack.Pop(); } context->cull_rect = previous_cull_rect; } diff --git a/flow/layers/transform_layer.cc b/flow/layers/transform_layer.cc index f1c2b013dfba5..5a7af132c68f2 100644 --- a/flow/layers/transform_layer.cc +++ b/flow/layers/transform_layer.cc @@ -29,7 +29,7 @@ TransformLayer::~TransformLayer() = default; void TransformLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkMatrix child_matrix; child_matrix.setConcat(matrix, transform_); - context->mutators_stack.pushTransform(transform_); + context->mutators_stack.PushTransform(transform_); SkRect previous_cull_rect = context->cull_rect; SkMatrix inverse_transform_; // Perspective projections don't produce rectangles that are useful for @@ -47,7 +47,7 @@ void TransformLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { set_paint_bounds(child_paint_bounds); context->cull_rect = previous_cull_rect; - context->mutators_stack.pop(); + context->mutators_stack.Pop(); } #if defined(OS_FUCHSIA) diff --git a/flow/mutators_stack_unittests.cc b/flow/mutators_stack_unittests.cc index c306eb63780ae..47f1b20e6067d 100644 --- a/flow/mutators_stack_unittests.cc +++ b/flow/mutators_stack_unittests.cc @@ -17,8 +17,8 @@ TEST(MutatorsStack, CopyConstructor) { MutatorsStack stack; auto rrect = SkRRect::MakeEmpty(); auto rect = SkRect::MakeEmpty(); - stack.pushClipRect(rect); - stack.pushClipRRect(rrect); + stack.PushClipRect(rect); + stack.PushClipRRect(rrect); MutatorsStack copy = MutatorsStack(stack); ASSERT_TRUE(copy == stack); } @@ -26,74 +26,74 @@ TEST(MutatorsStack, CopyConstructor) { TEST(MutatorsStack, PushClipRect) { MutatorsStack stack; auto rect = SkRect::MakeEmpty(); - stack.pushClipRect(rect); - auto iter = stack.bottom(); - ASSERT_TRUE(iter->get()->type() == MutatorType::clip_rect); - ASSERT_TRUE(iter->get()->rect() == rect); + stack.PushClipRect(rect); + auto iter = stack.Bottom(); + ASSERT_TRUE(iter->get()->GetType() == MutatorType::clip_rect); + ASSERT_TRUE(iter->get()->GetRect() == rect); } TEST(MutatorsStack, PushClipRRect) { MutatorsStack stack; auto rrect = SkRRect::MakeEmpty(); - stack.pushClipRRect(rrect); - auto iter = stack.bottom(); - ASSERT_TRUE(iter->get()->type() == MutatorType::clip_rrect); - ASSERT_TRUE(iter->get()->rrect() == rrect); + stack.PushClipRRect(rrect); + auto iter = stack.Bottom(); + ASSERT_TRUE(iter->get()->GetType() == MutatorType::clip_rrect); + ASSERT_TRUE(iter->get()->GetRRect() == rrect); } TEST(MutatorsStack, PushClipPath) { flutter::MutatorsStack stack; SkPath path; - stack.pushClipPath(path); - auto iter = stack.bottom(); - ASSERT_TRUE(iter->get()->type() == flutter::MutatorType::clip_path); - ASSERT_TRUE(iter->get()->path() == path); + stack.PushClipPath(path); + auto iter = stack.Bottom(); + ASSERT_TRUE(iter->get()->GetType() == flutter::MutatorType::clip_path); + ASSERT_TRUE(iter->get()->GetPath() == path); } TEST(MutatorsStack, PushTransform) { MutatorsStack stack; SkMatrix matrix; matrix.setIdentity(); - stack.pushTransform(matrix); - auto iter = stack.bottom(); - ASSERT_TRUE(iter->get()->type() == MutatorType::transform); - ASSERT_TRUE(iter->get()->matrix() == matrix); + stack.PushTransform(matrix); + auto iter = stack.Bottom(); + ASSERT_TRUE(iter->get()->GetType() == MutatorType::transform); + ASSERT_TRUE(iter->get()->GetMatrix() == matrix); } TEST(MutatorsStack, Pop) { MutatorsStack stack; SkMatrix matrix; matrix.setIdentity(); - stack.pushTransform(matrix); - stack.pop(); - auto iter = stack.bottom(); - ASSERT_TRUE(iter == stack.top()); + stack.PushTransform(matrix); + stack.Pop(); + auto iter = stack.Bottom(); + ASSERT_TRUE(iter == stack.Top()); } TEST(MutatorsStack, Traversal) { MutatorsStack stack; SkMatrix matrix; matrix.setIdentity(); - stack.pushTransform(matrix); + stack.PushTransform(matrix); auto rect = SkRect::MakeEmpty(); - stack.pushClipRect(rect); + stack.PushClipRect(rect); auto rrect = SkRRect::MakeEmpty(); - stack.pushClipRRect(rrect); - auto iter = stack.bottom(); + stack.PushClipRRect(rrect); + auto iter = stack.Bottom(); int index = 0; - while (iter != stack.top()) { + while (iter != stack.Top()) { switch (index) { case 0: - ASSERT_TRUE(iter->get()->type() == MutatorType::clip_rrect); - ASSERT_TRUE(iter->get()->rrect() == rrect); + ASSERT_TRUE(iter->get()->GetType() == MutatorType::clip_rrect); + ASSERT_TRUE(iter->get()->GetRRect() == rrect); break; case 1: - ASSERT_TRUE(iter->get()->type() == MutatorType::clip_rect); - ASSERT_TRUE(iter->get()->rect() == rect); + ASSERT_TRUE(iter->get()->GetType() == MutatorType::clip_rect); + ASSERT_TRUE(iter->get()->GetRect() == rect); break; case 2: - ASSERT_TRUE(iter->get()->type() == MutatorType::transform); - ASSERT_TRUE(iter->get()->matrix() == matrix); + ASSERT_TRUE(iter->get()->GetType() == MutatorType::transform); + ASSERT_TRUE(iter->get()->GetMatrix() == matrix); break; default: break; @@ -106,23 +106,23 @@ TEST(MutatorsStack, Traversal) { TEST(MutatorsStack, Equality) { MutatorsStack stack; SkMatrix matrix = SkMatrix::MakeScale(1, 1); - stack.pushTransform(matrix); + stack.PushTransform(matrix); SkRect rect = SkRect::MakeEmpty(); - stack.pushClipRect(rect); + stack.PushClipRect(rect); SkRRect rrect = SkRRect::MakeEmpty(); - stack.pushClipRRect(rrect); + stack.PushClipRRect(rrect); SkPath path; - stack.pushClipPath(path); + stack.PushClipPath(path); MutatorsStack stackOther; SkMatrix matrixOther = SkMatrix::MakeScale(1, 1); - stackOther.pushTransform(matrixOther); + stackOther.PushTransform(matrixOther); SkRect rectOther = SkRect::MakeEmpty(); - stackOther.pushClipRect(rectOther); + stackOther.PushClipRect(rectOther); SkRRect rrectOther = SkRRect::MakeEmpty(); - stackOther.pushClipRRect(rrectOther); + stackOther.PushClipRRect(rrectOther); SkPath otherPath; - stackOther.pushClipPath(otherPath); + stackOther.PushClipPath(otherPath); ASSERT_TRUE(stack == stackOther); } @@ -130,24 +130,24 @@ TEST(MutatorsStack, Equality) { TEST(Mutator, Initialization) { SkRect rect = SkRect::MakeEmpty(); Mutator mutator = Mutator(rect); - ASSERT_TRUE(mutator.type() == MutatorType::clip_rect); - ASSERT_TRUE(mutator.rect() == rect); + ASSERT_TRUE(mutator.GetType() == MutatorType::clip_rect); + ASSERT_TRUE(mutator.GetRect() == rect); SkRRect rrect = SkRRect::MakeEmpty(); Mutator mutator2 = Mutator(rrect); - ASSERT_TRUE(mutator2.type() == MutatorType::clip_rrect); - ASSERT_TRUE(mutator2.rrect() == rrect); + ASSERT_TRUE(mutator2.GetType() == MutatorType::clip_rrect); + ASSERT_TRUE(mutator2.GetRRect() == rrect); SkPath path; Mutator mutator3 = Mutator(path); - ASSERT_TRUE(mutator3.type() == MutatorType::clip_path); - ASSERT_TRUE(mutator3.path() == path); + ASSERT_TRUE(mutator3.GetType() == MutatorType::clip_path); + ASSERT_TRUE(mutator3.GetPath() == path); SkMatrix matrix; matrix.setIdentity(); Mutator mutator4 = Mutator(matrix); - ASSERT_TRUE(mutator4.type() == MutatorType::transform); - ASSERT_TRUE(mutator4.matrix() == matrix); + ASSERT_TRUE(mutator4.GetType() == MutatorType::transform); + ASSERT_TRUE(mutator4.GetMatrix() == matrix); } TEST(Mutator, CopyConstructor) { diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 33c5332baa96d..f0cb6939e6c04 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -205,10 +205,10 @@ } int FlutterPlatformViewsController::CountClips(const MutatorsStack& mutators_stack) { - std::vector>::const_reverse_iterator iter = mutators_stack.bottom(); + std::vector>::const_reverse_iterator iter = mutators_stack.Bottom(); int clipCount = 0; - while (iter != mutators_stack.top()) { - if ((*iter)->isClipType()) { + while (iter != mutators_stack.Top()) { + if ((*iter)->IsClipType()) { clipCount++; } ++iter; @@ -256,11 +256,11 @@ head.clipsToBounds = YES; ResetAnchor(head.layer); - std::vector>::const_reverse_iterator iter = mutators_stack.bottom(); - while (iter != mutators_stack.top()) { - switch ((*iter)->type()) { + std::vector>::const_reverse_iterator iter = mutators_stack.Bottom(); + while (iter != mutators_stack.Top()) { + switch ((*iter)->GetType()) { case transform: { - CATransform3D transform = GetCATransform3DFromSkMatrix((*iter)->matrix()); + CATransform3D transform = GetCATransform3DFromSkMatrix((*iter)->GetMatrix()); head.layer.transform = CATransform3DConcat(head.layer.transform, transform); break; } @@ -269,10 +269,10 @@ case clip_path: { ChildClippingView* clipView = (ChildClippingView*)head.superview; clipView.layer.transform = CATransform3DIdentity; - [clipView setClip:(*iter)->type() - rect:(*iter)->rect() - rrect:(*iter)->rrect() - path:(*iter)->path()]; + [clipView setClip:(*iter)->GetType() + rect:(*iter)->GetRect() + rrect:(*iter)->GetRRect() + path:(*iter)->GetPath()]; head.clipsToBounds = YES; ResetAnchor(clipView.layer); head = clipView;