Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: ui/views/animation/ink_drop_painted_layer_delegates.cc

Issue 2400563004: Adjust shadow and stroke of MdTextButton. (Closed)
Patch Set: dont schedule paint, add a lot of consts Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/animation/ink_drop_painted_layer_delegates.h ('k') | ui/views/controls/button/md_text_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/ink_drop_painted_layer_delegates.cc
diff --git a/ui/views/animation/ink_drop_painted_layer_delegates.cc b/ui/views/animation/ink_drop_painted_layer_delegates.cc
index 6eb553435999ac81bc9687bff87b23493f53d1be..75609d7a2fc97c3c6bbccf04b83e8fbb66d1434b 100644
--- a/ui/views/animation/ink_drop_painted_layer_delegates.cc
+++ b/ui/views/animation/ink_drop_painted_layer_delegates.cc
@@ -6,6 +6,7 @@
#include "third_party/skia/include/core/SkDrawLooper.h"
#include "third_party/skia/include/core/SkPaint.h"
+#include "third_party/skia/include/core/SkRRect.h"
#include "ui/compositor/paint_recorder.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
@@ -132,10 +133,12 @@ void RoundedRectangleLayerDelegate::OnPaintLayer(
BorderShadowLayerDelegate::BorderShadowLayerDelegate(
const std::vector<gfx::ShadowValue>& shadows,
const gfx::Rect& shadowed_area_bounds,
+ SkColor fill_color,
int corner_radius)
: BasePaintedLayerDelegate(gfx::kPlaceholderColor),
shadows_(shadows),
bounds_(shadowed_area_bounds),
+ fill_color_(fill_color),
corner_radius_(corner_radius) {}
BorderShadowLayerDelegate::~BorderShadowLayerDelegate() {}
@@ -152,22 +155,24 @@ gfx::Vector2dF BorderShadowLayerDelegate::GetCenteringOffset() const {
void BorderShadowLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
SkPaint paint;
- paint.setLooper(gfx::CreateShadowDrawLooperCorrectBlur(shadows_));
paint.setStyle(SkPaint::kFill_Style);
paint.setAntiAlias(true);
- paint.setColor(SK_ColorTRANSPARENT);
+ paint.setColor(fill_color_);
+
gfx::RectF rrect_bounds =
gfx::RectF(bounds_ - GetPaintedBounds().OffsetFromOrigin());
+ SkRRect r_rect = SkRRect::MakeRectXY(gfx::RectFToSkRect(rrect_bounds),
+ corner_radius_, corner_radius_);
+ // First the fill color.
ui::PaintRecorder recorder(context, GetPaintedBounds().size());
- recorder.canvas()->DrawRoundRect(rrect_bounds, corner_radius_, paint);
-
- SkPaint clear_paint;
- clear_paint.setAntiAlias(true);
- clear_paint.setXfermodeMode(SkXfermode::kClear_Mode);
- // If we don't care about actually clearing preexisting buffer content,
- // this could be replaced with a kDifference clip for the draw above.
- recorder.canvas()->DrawRoundRect(rrect_bounds, corner_radius_, clear_paint);
+ recorder.canvas()->sk_canvas()->drawRRect(r_rect, paint);
+
+ // Now the shadow.
+ paint.setLooper(gfx::CreateShadowDrawLooperCorrectBlur(shadows_));
+ recorder.canvas()->sk_canvas()->clipRRect(r_rect, SkRegion::kDifference_Op,
+ true);
+ recorder.canvas()->sk_canvas()->drawRRect(r_rect, paint);
}
} // namespace views
« no previous file with comments | « ui/views/animation/ink_drop_painted_layer_delegates.h ('k') | ui/views/controls/button/md_text_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698