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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/tabs/tab.h" 5 #include "chrome/browser/ui/views/tabs/tab.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 // should be at the top of the tab. Otherwise, we assume that the background 1218 // should be at the top of the tab. Otherwise, we assume that the background
1219 // image is a composited foreground + frame image. 1219 // image is a composited foreground + frame image.
1220 const int y_offset = GetThemeProvider()->HasCustomImage(tab_id) ? 1220 const int y_offset = GetThemeProvider()->HasCustomImage(tab_id) ?
1221 0 : background_offset_.y(); 1221 0 : background_offset_.y();
1222 1222
1223 const gfx::Insets tab_insets(GetLayoutInsets(TAB)); 1223 const gfx::Insets tab_insets(GetLayoutInsets(TAB));
1224 // Don't draw over the toolbar, but do include the 1 px divider stroke at the 1224 // Don't draw over the toolbar, but do include the 1 px divider stroke at the
1225 // bottom. 1225 // bottom.
1226 const int toolbar_overlap = tab_insets.bottom() - 1; 1226 const int toolbar_overlap = tab_insets.bottom() - 1;
1227 1227
1228 const SkScalar radius = SkFloatToScalar(width() / 3.f);
1229 const bool draw_hover = hover_controller_.ShouldDraw() && radius > 0;
1230 SkPoint hover_location(PointToSkPoint(hover_controller_.location()));
1231 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
1232
1228 // Draw everything to a temporary canvas so we can extract an image for use in 1233 // Draw everything to a temporary canvas so we can extract an image for use in
1229 // masking the hover glow. 1234 // masking the hover glow.
1230 gfx::Canvas background_canvas(size(), canvas->image_scale(), false); 1235 gfx::Canvas background_canvas(size(), canvas->image_scale(), false);
1231 1236
1232 // Draw left edge. 1237 // Draw left edge.
1233 gfx::ImageSkia tab_l = gfx::ImageSkiaOperations::CreateTiledImage( 1238 gfx::ImageSkia tab_l = gfx::ImageSkiaOperations::CreateTiledImage(
1234 *tab_background, x_offset, y_offset, mask_images_.l_width, height()); 1239 *tab_background, x_offset, y_offset, mask_images_.l_width, height());
1235 gfx::ImageSkia theme_l = 1240 gfx::ImageSkia theme_l =
1236 gfx::ImageSkiaOperations::CreateMaskedImage(tab_l, *mask_images_.image_l); 1241 gfx::ImageSkiaOperations::CreateMaskedImage(tab_l, *mask_images_.image_l);
1237 background_canvas.DrawImageInt( 1242 background_canvas.DrawImageInt(
(...skipping 15 matching lines...) Expand all
1253 // it by incrementing by the top padding, since it's a simple rectangle. 1258 // it by incrementing by the top padding, since it's a simple rectangle.
1254 background_canvas.TileImageInt( 1259 background_canvas.TileImageInt(
1255 *tab_background, x_offset + mask_images_.l_width, 1260 *tab_background, x_offset + mask_images_.l_width,
1256 y_offset + tab_insets.top(), mask_images_.l_width, tab_insets.top(), 1261 y_offset + tab_insets.top(), mask_images_.l_width, tab_insets.top(),
1257 width() - mask_images_.l_width - mask_images_.r_width, 1262 width() - mask_images_.l_width - mask_images_.r_width,
1258 height() - tab_insets.top() - toolbar_overlap); 1263 height() - tab_insets.top() - toolbar_overlap);
1259 1264
1260 gfx::ImageSkia background_image(background_canvas.ExtractImageRep()); 1265 gfx::ImageSkia background_image(background_canvas.ExtractImageRep());
1261 canvas->DrawImageInt(background_image, 0, 0); 1266 canvas->DrawImageInt(background_image, 0, 0);
1262 1267
1263 if (!GetThemeProvider()->HasCustomImage(tab_id) && 1268 if (draw_hover) {
1264 hover_controller_.ShouldDraw()) 1269 gfx::Canvas hover_canvas(size(), canvas->image_scale(), false);
1265 hover_controller_.Draw(canvas, background_image); 1270 DrawHighlight(&hover_canvas, hover_location, radius, hover_alpha);
1271 gfx::ImageSkia result = gfx::ImageSkiaOperations::CreateMaskedImage(
1272 gfx::ImageSkia(hover_canvas.ExtractImageRep()), background_image);
1273 canvas->DrawImageInt(result, 0, 0);
1274 }
1266 1275
1267 // Now draw the stroke, highlights, and shadows around the tab edge. 1276 // Now draw the stroke, highlights, and shadows around the tab edge.
1268 TabImages* stroke_images = &inactive_images_; 1277 TabImages* stroke_images = &inactive_images_;
1269 canvas->DrawImageInt(*stroke_images->image_l, 0, 0); 1278 canvas->DrawImageInt(*stroke_images->image_l, 0, 0);
1270 canvas->TileImageInt( 1279 canvas->TileImageInt(
1271 *stroke_images->image_c, stroke_images->l_width, 0, 1280 *stroke_images->image_c, stroke_images->l_width, 0,
1272 width() - stroke_images->l_width - stroke_images->r_width, height()); 1281 width() - stroke_images->l_width - stroke_images->r_width, height());
1273 canvas->DrawImageInt(*stroke_images->image_r, 1282 canvas->DrawImageInt(*stroke_images->image_r,
1274 width() - stroke_images->r_width, 0); 1283 width() - stroke_images->r_width, 0);
1275 } 1284 }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 const gfx::ImageSkia& image) { 1591 const gfx::ImageSkia& image) {
1583 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); 1592 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE);
1584 ImageCacheEntry entry; 1593 ImageCacheEntry entry;
1585 entry.resource_id = resource_id; 1594 entry.resource_id = resource_id;
1586 entry.scale_factor = scale_factor; 1595 entry.scale_factor = scale_factor;
1587 entry.image = image; 1596 entry.image = image;
1588 image_cache_->push_front(entry); 1597 image_cache_->push_front(entry);
1589 if (image_cache_->size() > kMaxImageCacheSize) 1598 if (image_cache_->size() > kMaxImageCacheSize)
1590 image_cache_->pop_back(); 1599 image_cache_->pop_back();
1591 } 1600 }
OLDNEW
« 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