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

Unified Diff: ui/views/controls/glow_hover_controller.cc

Issue 1418563016: Use the new DrawHighlight() helper to replace GlowHoverController::Draw(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nuke #includes Created 5 years, 1 month 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/controls/glow_hover_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/glow_hover_controller.cc
diff --git a/ui/views/controls/glow_hover_controller.cc b/ui/views/controls/glow_hover_controller.cc
index 5ce23fada491260632e1d0fd101c535c38b7eb25..d621cea93bdeff2d36e2bc4803505e753c6fab20 100644
--- a/ui/views/controls/glow_hover_controller.cc
+++ b/ui/views/controls/glow_hover_controller.cc
@@ -4,10 +4,6 @@
#include "ui/views/controls/glow_hover_controller.h"
-#include "third_party/skia/include/effects/SkGradientShader.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/image/image_skia.h"
-#include "ui/gfx/image/image_skia_operations.h"
#include "ui/views/view.h"
namespace views {
@@ -72,49 +68,13 @@ double GlowHoverController::GetAnimationValue() const {
return animation_.GetCurrentValue();
}
-bool GlowHoverController::ShouldDraw() const {
- return animation_.IsShowing() || animation_.is_animating();
+SkAlpha GlowHoverController::GetAlpha() const {
+ return static_cast<SkAlpha>(gfx::ToFlooredInt(
+ 0.5 + animation_.CurrentValueBetween(0., 255 * opacity_scale_)));
}
-void GlowHoverController::Draw(gfx::Canvas* canvas,
- const gfx::ImageSkia& mask_image) const {
- if (!ShouldDraw())
- return;
-
- // Draw a radial gradient to hover_canvas.
- gfx::Canvas hover_canvas(gfx::Size(mask_image.width(), mask_image.height()),
- canvas->image_scale(),
- false);
-
- // Draw a radial gradient to hover_canvas.
- int radius = view_->width() / 3;
-
- SkPoint center_point;
- center_point.iset(location_.x(), location_.y());
- SkColor colors[2];
- int hover_alpha =
- static_cast<int>(255 * opacity_scale_ * animation_.GetCurrentValue());
- colors[0] = SkColorSetARGB(hover_alpha, 255, 255, 255);
- colors[1] = SkColorSetARGB(0, 255, 255, 255);
- skia::RefPtr<SkShader> shader = skia::AdoptRef(
- SkGradientShader::CreateRadial(
- center_point, SkIntToScalar(radius), colors, NULL, 2,
- SkShader::kClamp_TileMode));
- // Shader can end up null when radius = 0.
- // If so, this results in default full tab glow behavior.
- if (shader) {
- SkPaint paint;
- paint.setStyle(SkPaint::kFill_Style);
- paint.setAntiAlias(true);
- paint.setShader(shader.get());
- hover_canvas.DrawRect(gfx::Rect(location_.x() - radius,
- location_.y() - radius,
- radius * 2, radius * 2), paint);
- }
- gfx::ImageSkia result = gfx::ImageSkiaOperations::CreateMaskedImage(
- gfx::ImageSkia(hover_canvas.ExtractImageRep()), mask_image);
- canvas->DrawImageInt(result, (view_->width() - mask_image.width()) / 2,
- (view_->height() - mask_image.height()) / 2);
+bool GlowHoverController::ShouldDraw() const {
+ return animation_.IsShowing() || animation_.is_animating();
}
void GlowHoverController::AnimationEnded(const gfx::Animation* animation) {
« no previous file with comments | « ui/views/controls/glow_hover_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698