Commit 9a1084cc authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Use SkPath instead of gfx::Path for highlight path view property

Change-Id: I5671d95901a93f227d14f24eb89d5cbfe588727b
Reviewed-on: https://chromium-review.googlesource.com/c/1277271Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599262}
parent f3d8f051
...@@ -168,13 +168,13 @@ int GetInkDropCornerRadius(const views::View* host_view) { ...@@ -168,13 +168,13 @@ int GetInkDropCornerRadius(const views::View* host_view) {
views::EMPHASIS_MAXIMUM, host_view->size()); views::EMPHASIS_MAXIMUM, host_view->size());
} }
// Returns a gfx::Path for bookmark inkdrops and focus rings. // Returns a |SkPath| for bookmark inkdrops and focus rings.
std::unique_ptr<gfx::Path> CreateBookmarkHighlightPath( std::unique_ptr<SkPath> CreateBookmarkHighlightPath(
views::InkDropHostView* host_view) { views::InkDropHostView* host_view) {
gfx::Rect rect(host_view->size()); gfx::Rect rect(host_view->size());
rect.Inset(GetInkDropInsets()); rect.Inset(GetInkDropInsets());
auto path = std::make_unique<gfx::Path>(); auto path = std::make_unique<SkPath>();
const int radius = GetInkDropCornerRadius(host_view); const int radius = GetInkDropCornerRadius(host_view);
path->addRoundRect(gfx::RectToSkRect(rect), radius, radius); path->addRoundRect(gfx::RectToSkRect(rect), radius, radius);
return path; return path;
......
...@@ -25,7 +25,7 @@ gfx::Insets GetToolbarInkDropInsets(const views::View* host_view, ...@@ -25,7 +25,7 @@ gfx::Insets GetToolbarInkDropInsets(const views::View* host_view,
return inkdrop_insets; return inkdrop_insets;
} }
std::unique_ptr<gfx::Path> CreateToolbarHighlightPath( std::unique_ptr<SkPath> CreateToolbarHighlightPath(
const views::View* host_view, const views::View* host_view,
const gfx::Insets& margin_insets) { const gfx::Insets& margin_insets) {
gfx::Rect rect(host_view->size()); gfx::Rect rect(host_view->size());
...@@ -34,7 +34,7 @@ std::unique_ptr<gfx::Path> CreateToolbarHighlightPath( ...@@ -34,7 +34,7 @@ std::unique_ptr<gfx::Path> CreateToolbarHighlightPath(
const int radii = ChromeLayoutProvider::Get()->GetCornerRadiusMetric( const int radii = ChromeLayoutProvider::Get()->GetCornerRadiusMetric(
views::EMPHASIS_MAXIMUM, rect.size()); views::EMPHASIS_MAXIMUM, rect.size());
auto path = std::make_unique<gfx::Path>(); auto path = std::make_unique<SkPath>();
path->addRoundRect(gfx::RectToSkRect(rect), radii, radii); path->addRoundRect(gfx::RectToSkRect(rect), radii, radii);
return path; return path;
} }
......
...@@ -44,7 +44,7 @@ gfx::Insets GetToolbarInkDropInsets(const views::View* host_view, ...@@ -44,7 +44,7 @@ gfx::Insets GetToolbarInkDropInsets(const views::View* host_view,
// focus rings so that they are derived from the same actual SkPath or other // focus rings so that they are derived from the same actual SkPath or other
// shared primitive. That way they would be significantly easier to keep in // shared primitive. That way they would be significantly easier to keep in
// sync. This method at least reuses GetToolbarInkDropInsets. // sync. This method at least reuses GetToolbarInkDropInsets.
std::unique_ptr<gfx::Path> CreateToolbarHighlightPath( std::unique_ptr<SkPath> CreateToolbarHighlightPath(
const views::View* host_view, const views::View* host_view,
const gfx::Insets& margin_insets); const gfx::Insets& margin_insets);
......
...@@ -171,7 +171,7 @@ std::unique_ptr<InkDropHighlight> InkDropHostView::CreateInkDropHighlight() ...@@ -171,7 +171,7 @@ std::unique_ptr<InkDropHighlight> InkDropHostView::CreateInkDropHighlight()
} }
std::unique_ptr<views::InkDropMask> InkDropHostView::CreateInkDropMask() const { std::unique_ptr<views::InkDropMask> InkDropHostView::CreateInkDropMask() const {
if (gfx::Path* highlight_path = GetProperty(kHighlightPathKey)) if (SkPath* highlight_path = GetProperty(kHighlightPathKey))
return std::make_unique<views::PathInkDropMask>(size(), *highlight_path); return std::make_unique<views::PathInkDropMask>(size(), *highlight_path);
return nullptr; return nullptr;
......
...@@ -78,7 +78,7 @@ void CircleInkDropMask::OnPaintLayer(const ui::PaintContext& context) { ...@@ -78,7 +78,7 @@ void CircleInkDropMask::OnPaintLayer(const ui::PaintContext& context) {
// PathInkDropMask // PathInkDropMask
PathInkDropMask::PathInkDropMask(const gfx::Size& layer_size, PathInkDropMask::PathInkDropMask(const gfx::Size& layer_size,
const gfx::Path& path) const SkPath& path)
: InkDropMask(layer_size), path_(path) {} : InkDropMask(layer_size), path_(path) {}
void PathInkDropMask::OnPaintLayer(const ui::PaintContext& context) { void PathInkDropMask::OnPaintLayer(const ui::PaintContext& context) {
......
...@@ -80,13 +80,13 @@ class VIEWS_EXPORT CircleInkDropMask : public InkDropMask { ...@@ -80,13 +80,13 @@ class VIEWS_EXPORT CircleInkDropMask : public InkDropMask {
// An ink-drop mask that paints a specified path. // An ink-drop mask that paints a specified path.
class VIEWS_EXPORT PathInkDropMask : public InkDropMask { class VIEWS_EXPORT PathInkDropMask : public InkDropMask {
public: public:
PathInkDropMask(const gfx::Size& layer_size, const gfx::Path& path); PathInkDropMask(const gfx::Size& layer_size, const SkPath& path);
private: private:
// InkDropMask: // InkDropMask:
void OnPaintLayer(const ui::PaintContext& context) override; void OnPaintLayer(const ui::PaintContext& context) override;
gfx::Path path_; SkPath path_;
DISALLOW_COPY_AND_ASSIGN(PathInkDropMask); DISALLOW_COPY_AND_ASSIGN(PathInkDropMask);
}; };
......
...@@ -134,7 +134,7 @@ Button* BubbleFrameView::CreateCloseButton(ButtonListener* listener) { ...@@ -134,7 +134,7 @@ Button* BubbleFrameView::CreateCloseButton(ButtonListener* listener) {
close_button->SizeToPreferredSize(); close_button->SizeToPreferredSize();
// Let the close button use a circular inkdrop shape. // Let the close button use a circular inkdrop shape.
auto highlight_path = std::make_unique<gfx::Path>(); auto highlight_path = std::make_unique<SkPath>();
highlight_path->addOval(gfx::RectToSkRect(gfx::Rect(close_button->size()))); highlight_path->addOval(gfx::RectToSkRect(gfx::Rect(close_button->size())));
close_button->SetProperty(kHighlightPathKey, highlight_path.release()); close_button->SetProperty(kHighlightPathKey, highlight_path.release());
......
...@@ -81,7 +81,7 @@ void FocusRing::OnPaint(gfx::Canvas* canvas) { ...@@ -81,7 +81,7 @@ void FocusRing::OnPaint(gfx::Canvas* canvas) {
SkPath path = path_; SkPath path = path_;
if (path.isEmpty()) { if (path.isEmpty()) {
gfx::Path* highlight_path = parent()->GetProperty(kHighlightPathKey); SkPath* highlight_path = parent()->GetProperty(kHighlightPathKey);
if (highlight_path) if (highlight_path)
path = *highlight_path; path = *highlight_path;
} }
......
...@@ -20,7 +20,7 @@ DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, gfx::Insets*); ...@@ -20,7 +20,7 @@ DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, gfx::Insets*);
DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT,
views::BubbleDialogDelegateView*); views::BubbleDialogDelegateView*);
DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, gfx::Path*); DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, SkPath*);
namespace views { namespace views {
...@@ -29,6 +29,6 @@ DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Insets, kMarginsKey, nullptr); ...@@ -29,6 +29,6 @@ DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Insets, kMarginsKey, nullptr);
DEFINE_UI_CLASS_PROPERTY_KEY(views::BubbleDialogDelegateView*, DEFINE_UI_CLASS_PROPERTY_KEY(views::BubbleDialogDelegateView*,
kAnchoredDialogKey, kAnchoredDialogKey,
nullptr); nullptr);
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Path, kHighlightPathKey, nullptr); DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(SkPath, kHighlightPathKey, nullptr);
} // namespace views } // namespace views
...@@ -8,9 +8,10 @@ ...@@ -8,9 +8,10 @@
#include "ui/base/class_property.h" #include "ui/base/class_property.h"
#include "ui/views/views_export.h" #include "ui/views/views_export.h"
class SkPath;
namespace gfx { namespace gfx {
class Insets; class Insets;
class Path;
} // namespace gfx } // namespace gfx
namespace views { namespace views {
...@@ -34,8 +35,7 @@ VIEWS_EXPORT extern const ui::ClassProperty<BubbleDialogDelegateView*>* const ...@@ -34,8 +35,7 @@ VIEWS_EXPORT extern const ui::ClassProperty<BubbleDialogDelegateView*>* const
// A property to store a highlight path related to the view. This is nominally // A property to store a highlight path related to the view. This is nominally
// used by the default inkdrop and focus ring that are both used to highlight // used by the default inkdrop and focus ring that are both used to highlight
// the view in different ways. // the view in different ways.
VIEWS_EXPORT extern const ui::ClassProperty<gfx::Path*>* const VIEWS_EXPORT extern const ui::ClassProperty<SkPath*>* const kHighlightPathKey;
kHighlightPathKey;
} // namespace views } // namespace views
...@@ -47,5 +47,5 @@ VIEWS_EXPORT extern const ui::ClassProperty<gfx::Path*>* const ...@@ -47,5 +47,5 @@ VIEWS_EXPORT extern const ui::ClassProperty<gfx::Path*>* const
DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, gfx::Insets*); DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, gfx::Insets*);
DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT,
views::BubbleDialogDelegateView*); views::BubbleDialogDelegateView*);
DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, gfx::Path*); DECLARE_EXPORTED_UI_CLASS_PROPERTY_TYPE(VIEWS_EXPORT, SkPath*);
#endif // UI_VIEWS_VIEW_PROPERTIES_H_ #endif // UI_VIEWS_VIEW_PROPERTIES_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment