Commit aba45baa authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

Revert "Support rounded rects that don't have the same radius on all 4 corners"

This reverts commit 64679b34.

Reason for revert: I need this functionality at another level of the stack (directly in Skia), reverting this not to add unnecessary complication.

Original change's description:
> Support rounded rects that don't have the same radius on all 4 corners
> 
> Bug: 805612
> Change-Id: I86af86a62fe2e46691db6bfb2b24da404c93ec1d
> Reviewed-on: https://chromium-review.googlesource.com/1130059
> Commit-Queue: Manu Cornet <manucornet@chromium.org>
> Reviewed-by: Xiaoqian Dai <xdai@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#573528}

TBR=xdai@chromium.org,manucornet@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 805612
Change-Id: I6011952531594bba81c565e1a4bc004654399ece
Reviewed-on: https://chromium-review.googlesource.com/1188702Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585881}
parent e36b160e
...@@ -10,33 +10,16 @@ ...@@ -10,33 +10,16 @@
namespace ash { namespace ash {
RoundedRectView::RoundedRectView(int corner_radius, SkColor background_color) RoundedRectView::RoundedRectView(int corner_radius, SkColor background_color)
: RoundedRectView(corner_radius, : corner_radius_(corner_radius), background_color_(background_color) {}
corner_radius,
corner_radius,
corner_radius,
background_color) {}
RoundedRectView::RoundedRectView(int top_left_radius,
int top_right_radius,
int bottom_right_radius,
int bottom_left_radius,
SkColor background_color)
: top_left_radius_(top_left_radius),
top_right_radius_(top_right_radius),
bottom_right_radius_(bottom_right_radius),
bottom_left_radius_(bottom_left_radius),
background_color_(background_color) {}
RoundedRectView::~RoundedRectView() = default; RoundedRectView::~RoundedRectView() = default;
void RoundedRectView::OnPaint(gfx::Canvas* canvas) { void RoundedRectView::OnPaint(gfx::Canvas* canvas) {
views::View::OnPaint(canvas); views::View::OnPaint(canvas);
const SkScalar kRadius[8] = { SkScalar radius = SkIntToScalar(corner_radius_);
SkIntToScalar(top_left_radius_), SkIntToScalar(top_left_radius_), const SkScalar kRadius[8] = {radius, radius, radius, radius,
SkIntToScalar(top_right_radius_), SkIntToScalar(top_right_radius_), radius, radius, radius, radius};
SkIntToScalar(bottom_right_radius_), SkIntToScalar(bottom_right_radius_),
SkIntToScalar(bottom_left_radius_), SkIntToScalar(bottom_left_radius_)};
SkPath path; SkPath path;
gfx::Rect bounds(size()); gfx::Rect bounds(size());
path.addRoundRect(gfx::RectToSkRect(bounds), kRadius); path.addRoundRect(gfx::RectToSkRect(bounds), kRadius);
...@@ -53,26 +36,12 @@ void RoundedRectView::SetBackgroundColor(SkColor background_color) { ...@@ -53,26 +36,12 @@ void RoundedRectView::SetBackgroundColor(SkColor background_color) {
SchedulePaint(); SchedulePaint();
} }
void RoundedRectView::SetCornerRadius(int top_left_radius, void RoundedRectView::SetCornerRadius(int radius) {
int top_right_radius, if (corner_radius_ == radius)
int bottom_right_radius,
int bottom_left_radius) {
if (top_left_radius_ == top_left_radius &&
top_right_radius_ == top_right_radius &&
bottom_right_radius_ == bottom_right_radius &&
bottom_left_radius_ == bottom_left_radius) {
return; return;
}
top_left_radius_ = top_left_radius; corner_radius_ = radius;
top_right_radius_ = top_right_radius;
bottom_right_radius_ = bottom_right_radius;
bottom_left_radius_ = bottom_left_radius;
SchedulePaint(); SchedulePaint();
} }
void RoundedRectView::SetCornerRadius(int radius) {
SetCornerRadius(radius, radius, radius, radius);
}
} // namespace ash } // namespace ash
...@@ -22,28 +22,16 @@ namespace ash { ...@@ -22,28 +22,16 @@ namespace ash {
class RoundedRectView : public views::View { class RoundedRectView : public views::View {
public: public:
RoundedRectView(int corner_radius, SkColor background_color); RoundedRectView(int corner_radius, SkColor background_color);
RoundedRectView(int top_left_radius,
int top_right_radius,
int bottom_right_radius,
int bottom_left_radius,
SkColor background_color);
~RoundedRectView() override; ~RoundedRectView() override;
void SetBackgroundColor(SkColor background_color); void SetBackgroundColor(SkColor background_color);
void SetCornerRadius(int top_left_radius,
int top_right_radius,
int bottom_right_radius,
int bottom_left_radius);
void SetCornerRadius(int radius); void SetCornerRadius(int radius);
// views::View: // views::View:
void OnPaint(gfx::Canvas* canvas) override; void OnPaint(gfx::Canvas* canvas) override;
private: private:
int top_left_radius_; int corner_radius_;
int top_right_radius_;
int bottom_right_radius_;
int bottom_left_radius_;
SkColor background_color_; SkColor background_color_;
DISALLOW_COPY_AND_ASSIGN(RoundedRectView); DISALLOW_COPY_AND_ASSIGN(RoundedRectView);
......
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