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

Unified Diff: chrome/browser/ui/views/tabs/tab.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: Correct conditional 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
Index: chrome/browser/ui/views/tabs/tab.cc
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index c2d651c08c32c37d2f18b134dfbb981cfc64b5dd..0a6ff6e1485ee9fe69f054c48db14d6920e0bce5 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -1225,6 +1225,11 @@ void Tab::PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas,
// bottom.
const int toolbar_overlap = tab_insets.bottom() - 1;
+ const SkScalar radius = SkFloatToScalar(width() / 3.f);
+ const bool draw_hover = hover_controller_.ShouldDraw() && radius > 0;
+ SkPoint hover_location(PointToSkPoint(hover_controller_.location()));
+ const SkAlpha hover_alpha = hover_controller_.GetAlpha();
Peter Kasting 2015/11/04 23:47:10 If you're wondering why this block is way up here
+
// Draw everything to a temporary canvas so we can extract an image for use in
// masking the hover glow.
gfx::Canvas background_canvas(size(), canvas->image_scale(), false);
@@ -1260,9 +1265,13 @@ void Tab::PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas,
gfx::ImageSkia background_image(background_canvas.ExtractImageRep());
canvas->DrawImageInt(background_image, 0, 0);
- if (!GetThemeProvider()->HasCustomImage(tab_id) &&
- hover_controller_.ShouldDraw())
- hover_controller_.Draw(canvas, background_image);
+ if (draw_hover) {
+ gfx::Canvas hover_canvas(size(), canvas->image_scale(), false);
+ DrawHighlight(&hover_canvas, hover_location, radius, hover_alpha);
+ gfx::ImageSkia result = gfx::ImageSkiaOperations::CreateMaskedImage(
+ gfx::ImageSkia(hover_canvas.ExtractImageRep()), background_image);
+ canvas->DrawImageInt(result, 0, 0);
+ }
// Now draw the stroke, highlights, and shadows around the tab edge.
TabImages* stroke_images = &inactive_images_;
« no previous file with comments | « no previous file | ui/views/controls/glow_hover_controller.h » ('j') | ui/views/controls/glow_hover_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698