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

Unified Diff: ash/shelf/voice_interaction_overlay.cc

Issue 2951583002: Update voice interaction icon shadow (Closed)
Patch Set: fix const Created 3 years, 6 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 | « no previous file | ui/gfx/shadow_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/voice_interaction_overlay.cc
diff --git a/ash/shelf/voice_interaction_overlay.cc b/ash/shelf/voice_interaction_overlay.cc
index caecc5755632a67f01c1f5560ce23c488f725d9f..21602386fd8dbc24ae56d1e309ceee5eaf5e5ec6 100644
--- a/ash/shelf/voice_interaction_overlay.cc
+++ b/ash/shelf/voice_interaction_overlay.cc
@@ -39,6 +39,7 @@
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/scoped_canvas.h"
+#include "ui/gfx/skia_paint_util.h"
#include "ui/views/animation/flood_fill_ink_drop_ripple.h"
#include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/animation/ink_drop_mask.h"
@@ -73,55 +74,29 @@ constexpr float kBackgroundStartSizeDip = 10.f;
constexpr float kBackgroundSizeDip = 48.f;
constexpr int kBackgroundStartDelayMs = 100;
constexpr int kBackgroundOpacityDurationMs = 200;
-constexpr float kBackgroundShadowSizeDip = 12;
-
-class CircleImageSource : public gfx::CanvasImageSource {
- public:
- CircleImageSource(float radius, float padding)
- : CanvasImageSource(
- gfx::Size((radius + padding) * 2, (radius + padding) * 2),
- false),
- radius_(radius),
- padding_(padding) {}
- ~CircleImageSource() override {}
-
- private:
- void Draw(gfx::Canvas* canvas) override {
- cc::PaintFlags flags;
- flags.setColor(SK_ColorWHITE);
- flags.setAntiAlias(true);
- flags.setStyle(cc::PaintFlags::kFill_Style);
- canvas->DrawCircle(gfx::PointF(radius_ + padding_, radius_ + padding_),
- radius_, flags);
- }
-
- float radius_;
- float padding_;
-
- DISALLOW_COPY_AND_ASSIGN(CircleImageSource);
-};
+constexpr float kBackgroundShadowElevationDip = 24.f;
class VoiceInteractionIconBackground : public ui::Layer,
public ui::LayerDelegate {
public:
- VoiceInteractionIconBackground()
- : Layer(ui::LAYER_NOT_DRAWN),
- shadow_values_(1,
- gfx::ShadowValue(gfx::Vector2d(0, 0),
- kBackgroundShadowSizeDip,
- SkColorSetARGB(0x54, 0, 0, 0))) {
+ VoiceInteractionIconBackground() : Layer(ui::LAYER_NOT_DRAWN) {
set_name("VoiceInteractionOverlay:BACKGROUND_LAYER");
SetBounds(gfx::Rect(0, 0, kBackgroundInitSizeDip, kBackgroundInitSizeDip));
SetFillsBoundsOpaquely(false);
SetMasksToBounds(false);
+ shadow_values_ =
+ gfx::ShadowValue::MakeMdShadowValues(kBackgroundShadowElevationDip);
+ const gfx::Insets shadow_margin =
+ gfx::ShadowValue::GetMargin(shadow_values_);
+
shadow_layer_.reset(new ui::Layer());
shadow_layer_->set_delegate(this);
shadow_layer_->SetFillsBoundsOpaquely(false);
shadow_layer_->SetBounds(
- gfx::Rect(-kBackgroundShadowSizeDip, -kBackgroundShadowSizeDip,
- kBackgroundInitSizeDip + kBackgroundShadowSizeDip * 2,
- kBackgroundInitSizeDip + kBackgroundShadowSizeDip * 2));
+ gfx::Rect(shadow_margin.left(), shadow_margin.top(),
+ kBackgroundInitSizeDip - shadow_margin.width(),
+ kBackgroundInitSizeDip - shadow_margin.height()));
Add(shadow_layer_.get());
}
~VoiceInteractionIconBackground() override{};
@@ -131,17 +106,18 @@ class VoiceInteractionIconBackground : public ui::Layer,
// Radius is based on the parent layer size, the shadow layer is expanded
// to make room for the shadow.
float radius = size().width() / 2.f;
- CircleImageSource* circle_image =
- new CircleImageSource(radius, kBackgroundShadowSizeDip);
- gfx::ImageSkia background_with_shadow =
- gfx::ImageSkiaOperations::CreateImageWithDropShadow(
- gfx::ImageSkia(circle_image, circle_image->size()), shadow_values_);
- ui::PaintRecorder recorder(context, background_with_shadow.size());
+ ui::PaintRecorder recorder(context, shadow_layer_->size());
gfx::Canvas* canvas = recorder.canvas();
- float shadow_offset =
- (shadow_layer_->size().width() - background_with_shadow.width()) / 2.f;
- canvas->DrawImageInt(background_with_shadow, shadow_offset, shadow_offset);
+
+ cc::PaintFlags flags;
+ flags.setColor(SK_ColorWHITE);
+ flags.setAntiAlias(true);
+ flags.setStyle(cc::PaintFlags::kFill_Style);
+ flags.setLooper(gfx::CreateShadowDrawLooper(shadow_values_));
+ gfx::Rect shadow_bounds = shadow_layer_->bounds();
+ canvas->DrawCircle({radius - shadow_bounds.x(), radius - shadow_bounds.y()},
+ radius, flags);
}
void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {}
« no previous file with comments | « no previous file | ui/gfx/shadow_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698