From 09eeecf86d746ca9e4ad2324bf59a98687a0a607 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Tue, 20 Jul 2021 13:14:08 -0700 Subject: [PATCH] Cleanup unused entries in entity. --- engine/src/flutter/impeller/.clang-tidy | 4 + engine/src/flutter/impeller/aiks/BUILD.gn | 2 + engine/src/flutter/impeller/entity/entity.cc | 75 +--------------- engine/src/flutter/impeller/entity/entity.h | 85 +------------------ .../impeller/geometry/path_component.cc | 1 + 5 files changed, 9 insertions(+), 158 deletions(-) diff --git a/engine/src/flutter/impeller/.clang-tidy b/engine/src/flutter/impeller/.clang-tidy index 17cf0e2daf..28a352346a 100644 --- a/engine/src/flutter/impeller/.clang-tidy +++ b/engine/src/flutter/impeller/.clang-tidy @@ -7,6 +7,10 @@ FormatStyle: none CheckOptions: - key: readability-identifier-naming.PrivateMemberCase value: 'lower_case' + - key: readability-identifier-naming.EnumConstantCase + value: 'CamelCase' + - key: readability-identifier-naming.EnumConstantPrefix + value: 'k' - key: readability-identifier-naming.PrivateMemberSuffix value: '_' - key: readability-identifier-naming.PublicMethodCase diff --git a/engine/src/flutter/impeller/aiks/BUILD.gn b/engine/src/flutter/impeller/aiks/BUILD.gn index c2276fe759..c6fe348cd6 100644 --- a/engine/src/flutter/impeller/aiks/BUILD.gn +++ b/engine/src/flutter/impeller/aiks/BUILD.gn @@ -10,6 +10,8 @@ impeller_component("aiks") { "canvas.h", "paint.cc", "paint.h", + "image.cc" + "image.h" ] public_deps = [ diff --git a/engine/src/flutter/impeller/entity/entity.cc b/engine/src/flutter/impeller/entity/entity.cc index b837161ffa..510a72d0e9 100644 --- a/engine/src/flutter/impeller/entity/entity.cc +++ b/engine/src/flutter/impeller/entity/entity.cc @@ -10,43 +10,6 @@ Entity::Entity() = default; Entity::~Entity() = default; -Rect Entity::GetFrame() const { - Point origin(position_.x - (bounds_.size.width * anchor_point_.x), - position_.y - (bounds_.size.height * anchor_point_.y)); - - return Rect(origin, bounds_.size); -} - -void Entity::SetFrame(const Rect& frame) { - SetBounds(Rect(bounds_.origin, frame.size)); - SetPosition(Point(frame.origin.x + (anchor_point_.x * frame.size.width), - frame.origin.y + (anchor_point_.y * frame.size.height))); -} - -const Rect& Entity::GetBounds() const { - return bounds_; -} - -void Entity::SetBounds(const Rect& bounds) { - bounds_ = bounds; -} - -const Point& Entity::GetPosition() const { - return position_; -} - -void Entity::SetPosition(const Point& position) { - position_ = position; -} - -const Point& Entity::GetAnchorPoint() const { - return anchor_point_; -} - -void Entity::SetAnchorPoint(const Point& anchorPoint) { - anchor_point_ = anchorPoint; -} - const Matrix& Entity::GetTransformation() const { return transformation_; } @@ -55,34 +18,6 @@ void Entity::SetTransformation(const Matrix& transformation) { transformation_ = transformation; } -Matrix Entity::GetModelMatrix() const { - /* - * The translation accounts for the offset in the origin of the bounds - * of the entity and its position about its anchor point. - */ - auto translation = Matrix::MakeTranslation( - {-bounds_.origin.x + position_.x - (bounds_.size.width * anchor_point_.x), - -bounds_.origin.y + position_.y - - (bounds_.size.height * anchor_point_.y)}); - - /* - * The transformation of an entity is applied about is anchor point. However, - * if the transformation is identity, we can avoid having to calculate the - * matrix adjustment and also the two matrix multiplications. - */ - - if (transformation_.IsIdentity()) { - return translation; - } - - auto anchorAdjustment = - Matrix::MakeTranslation({-anchor_point_.x * bounds_.size.width, - -anchor_point_.y * bounds_.size.height}); - - return translation * anchorAdjustment.Invert() * transformation_ * - anchorAdjustment; -} - const Color& Entity::GetBackgroundColor() const { return background_color_; } @@ -91,14 +26,6 @@ void Entity::SetBackgroundColor(const Color& backgroundColor) { background_color_ = backgroundColor; } -const double& Entity::GetOpacity() const { - return opacity_; -} - -void Entity::SetOpacity(double opacity) { - opacity_ = opacity; -} - const Color& Entity::GetStrokeColor() const { return stroke_color_; } @@ -112,7 +39,7 @@ double Entity::GetStrokeSize() const { } void Entity::SetStrokeSize(double strokeSize) { - stroke_size_ = strokeSize; + stroke_size_ = std::max(strokeSize, 0.0); } const Path& Entity::GetPath() const { diff --git a/engine/src/flutter/impeller/entity/entity.h b/engine/src/flutter/impeller/entity/entity.h index 9554cc21e6..2c35974498 100644 --- a/engine/src/flutter/impeller/entity/entity.h +++ b/engine/src/flutter/impeller/entity/entity.h @@ -18,66 +18,6 @@ class Entity { ~Entity(); - /** - * The frame specifies the origin and size of the entity in the coordinate - * space of its parent. This is a computed property derived from the bounds - * of the entity and its position. - * - * @return the frame of the entity - */ - Rect GetFrame() const; - - /** - * Set the frame of the entity - * - * @param frame the new frame - */ - void SetFrame(const Rect& frame); - - /** - * The bounds specifies the origin and size of the entity in its own - * coordinate space. - * - * @return the bounds of the entity - */ - const Rect& GetBounds() const; - - /** - * Set the bounds of the entity - * - * @param bounds the new bounds - */ - void SetBounds(const Rect& bounds); - - /** - * The position specifies the coordinates of the anchor position of the - * entity relative to its parent - * - * @return the position of the entity - */ - const Point& GetPosition() const; - - /** - * Sets the position of the entity - * - * @param point the new position - */ - void SetPosition(const Point& point); - - /** - * The position of the anchor point within this node in unit space - * - * @return the anchor point - */ - const Point& GetAnchorPoint() const; - - /** - * Sets the new anchor point of this node - * - * @param anchorPoint the new anchor point - */ - void SetAnchorPoint(const Point& anchorPoint); - /** * The transformation that is applied to the entity about its anchor point * @@ -92,13 +32,6 @@ class Entity { */ void SetTransformation(const Matrix& transformation); - /** - * The model matrix of the entity - * - * @return the view matrix - */ - Matrix GetModelMatrix() const; - /** * The background color of the entity * @@ -113,21 +46,6 @@ class Entity { */ void SetBackgroundColor(const Color& backgroundColor); - /** - * The opacity of the entity. 0.0 is fully transparent and 1.0 is fully - * opaque. Default it 1.0. - * - * @return the opacity of the entity - */ - const double& GetOpacity() const; - - /** - * Set the new opacity of the entity - * - * @param opacity the new opacity - */ - void SetOpacity(double opacity); - const Color& GetStrokeColor() const; void SetStrokeColor(const Color& strokeColor); @@ -148,8 +66,7 @@ class Entity { Color background_color_; Path path_; - double opacity_ = 1.0; - Color stroke_color_ = Color::Black(); + Color stroke_color_; double stroke_size_ = 1.0; FML_DISALLOW_COPY_AND_ASSIGN(Entity); diff --git a/engine/src/flutter/impeller/geometry/path_component.cc b/engine/src/flutter/impeller/geometry/path_component.cc index f7055c39b7..58a1b46915 100644 --- a/engine/src/flutter/impeller/geometry/path_component.cc +++ b/engine/src/flutter/impeller/geometry/path_component.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "path_component.h" + #include namespace impeller {