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

Side by Side Diff: chrome/browser/views/tabs/side_tab.cc

Issue 2811032: Revert 50784 - Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/tabs/side_tab.h" 5 #include "chrome/browser/views/tabs/side_tab.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "app/theme_provider.h" 8 #include "app/theme_provider.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "gfx/canvas_skia.h" 11 #include "gfx/canvas.h"
12 #include "gfx/favicon_size.h" 12 #include "gfx/favicon_size.h"
13 #include "gfx/path.h" 13 #include "gfx/path.h"
14 #include "gfx/skia_util.h" 14 #include "gfx/skia_util.h"
15 #include "grit/app_resources.h" 15 #include "grit/app_resources.h"
16 #include "views/controls/button/image_button.h" 16 #include "views/controls/button/image_button.h"
17 17
18 namespace { 18 namespace {
19 const int kVerticalTabHeight = 27; 19 const int kVerticalTabHeight = 27;
20 const int kTitleCloseSpacing = 4; 20 const int kTitleCloseSpacing = 4;
21 const SkScalar kRoundRectRadius = 4; 21 const SkScalar kRoundRectRadius = 4;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 font_height()); 84 font_height());
85 } 85 }
86 86
87 void SideTab::Paint(gfx::Canvas* canvas) { 87 void SideTab::Paint(gfx::Canvas* canvas) {
88 if (ShouldPaintHighlight()) { 88 if (ShouldPaintHighlight()) {
89 SkPaint paint; 89 SkPaint paint;
90 paint.setColor(kTabBackgroundColor); 90 paint.setColor(kTabBackgroundColor);
91 paint.setAntiAlias(true); 91 paint.setAntiAlias(true);
92 SkRect border_rect = { SkIntToScalar(0), SkIntToScalar(0), 92 SkRect border_rect = { SkIntToScalar(0), SkIntToScalar(0),
93 SkIntToScalar(width()), SkIntToScalar(height()) }; 93 SkIntToScalar(width()), SkIntToScalar(height()) };
94 canvas->AsCanvasSkia()->drawRoundRect(border_rect, 94 canvas->drawRoundRect(border_rect, SkIntToScalar(kRoundRectRadius),
95 SkIntToScalar(kRoundRectRadius), 95 SkIntToScalar(kRoundRectRadius), paint);
96 SkIntToScalar(kRoundRectRadius),
97 paint);
98 } 96 }
99 97
100 if (ShouldShowIcon()) { 98 if (ShouldShowIcon()) {
101 if (data().phantom) { 99 if (data().phantom) {
102 SkRect bounds; 100 SkRect bounds;
103 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height())); 101 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
104 canvas->AsCanvasSkia()->saveLayerAlpha( 102 canvas->saveLayerAlpha(&bounds, kPhantomTabIconAlpha,
105 &bounds, kPhantomTabIconAlpha, SkCanvas::kARGB_ClipLayer_SaveFlag); 103 SkCanvas::kARGB_ClipLayer_SaveFlag);
106 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y()); 104 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y());
107 canvas->AsCanvasSkia()->restore(); 105 canvas->restore();
108 } else { 106 } else {
109 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y()); 107 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y());
110 } 108 }
111 } 109 }
112 110
113 PaintTitle(canvas, data().phantom ? kPhantomTextColor : kTextColor); 111 PaintTitle(canvas, data().phantom ? kPhantomTextColor : kTextColor);
114 } 112 }
115 113
116 gfx::Size SideTab::GetPreferredSize() { 114 gfx::Size SideTab::GetPreferredSize() {
117 return gfx::Size(0, GetPreferredHeight()); 115 return gfx::Size(0, GetPreferredHeight());
118 } 116 }
119 117
120 bool SideTab::ShouldPaintHighlight() const { 118 bool SideTab::ShouldPaintHighlight() const {
121 return IsSelected() || !controller(); 119 return IsSelected() || !controller();
122 } 120 }
123 121
124 bool SideTab::ShouldShowIcon() const { 122 bool SideTab::ShouldShowIcon() const {
125 return data().mini || data().show_icon; 123 return data().mini || data().show_icon;
126 } 124 }
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/native_view_photobooth_win.cc ('k') | chrome/browser/views/tabs/tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698