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

Side by Side Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename methods and vars to make image_scale more clear Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
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/location_bar/icon_label_bubble_view.h" 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
9 #include "grit/theme_resources.h" 9 #include "grit/theme_resources.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 label_->SetEnabledColor(text_color); 48 label_->SetEnabledColor(text_color);
49 // Calculate the actual background color for the label. The background images 49 // Calculate the actual background color for the label. The background images
50 // are painted atop |parent_background_color|. We grab the color of the 50 // are painted atop |parent_background_color|. We grab the color of the
51 // middle pixel of the middle image of the background, which we treat as the 51 // middle pixel of the middle image of the background, which we treat as the
52 // representative color of the entire background (reasonable, given the 52 // representative color of the entire background (reasonable, given the
53 // current appearance of these images). Then we alpha-blend it over the 53 // current appearance of these images). Then we alpha-blend it over the
54 // parent background color to determine the actual color the label text will 54 // parent background color to determine the actual color the label text will
55 // sit atop. 55 // sit atop.
56 const SkBitmap& bitmap( 56 const SkBitmap& bitmap(
57 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 57 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
58 background_images[4])->GetRepresentation( 58 background_images[4])->GetRepresentation(1.0f).sk_bitmap());
59 ui::SCALE_FACTOR_100P).sk_bitmap());
60 SkAutoLockPixels pixel_lock(bitmap); 59 SkAutoLockPixels pixel_lock(bitmap);
61 SkColor background_image_color = 60 SkColor background_image_color =
62 bitmap.getColor(bitmap.width() / 2, bitmap.height() / 2); 61 bitmap.getColor(bitmap.width() / 2, bitmap.height() / 2);
63 // Tricky bit: We alpha blend an opaque version of |background_image_color| 62 // Tricky bit: We alpha blend an opaque version of |background_image_color|
64 // against |parent_background_color| using the original image grid color's 63 // against |parent_background_color| using the original image grid color's
65 // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged 64 // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged
66 // even if |a| is a color with non-255 alpha. 65 // even if |a| is a color with non-255 alpha.
67 label_->SetBackgroundColor( 66 label_->SetBackgroundColor(
68 color_utils::AlphaBlend(SkColorSetA(background_image_color, 255), 67 color_utils::AlphaBlend(SkColorSetA(background_image_color, 255),
69 parent_background_color, 68 parent_background_color,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 views::Painter* painter = (in_hover_ && hover_background_painter_) ? 125 views::Painter* painter = (in_hover_ && hover_background_painter_) ?
127 hover_background_painter_.get() : background_painter_.get(); 126 hover_background_painter_.get() : background_painter_.get();
128 painter->Paint(canvas, size()); 127 painter->Paint(canvas, size());
129 } 128 }
130 129
131 int IconLabelBubbleView::GetPreLabelWidth() const { 130 int IconLabelBubbleView::GetPreLabelWidth() const {
132 const int image_width = image_->GetPreferredSize().width(); 131 const int image_width = image_->GetPreferredSize().width();
133 return GetBubbleOuterPadding(true) + 132 return GetBubbleOuterPadding(true) +
134 (image_width ? (image_width + LocationBarView::GetItemPadding()) : 0); 133 (image_width ? (image_width + LocationBarView::GetItemPadding()) : 0);
135 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698