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

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

Issue 2825018: 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.h" 11 #include "gfx/canvas_skia.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->drawRoundRect(border_rect, SkIntToScalar(kRoundRectRadius), 94 canvas->AsCanvasSkia()->drawRoundRect(border_rect,
95 SkIntToScalar(kRoundRectRadius), paint); 95 SkIntToScalar(kRoundRectRadius),
96 SkIntToScalar(kRoundRectRadius),
97 paint);
96 } 98 }
97 99
98 if (ShouldShowIcon()) { 100 if (ShouldShowIcon()) {
99 if (data().phantom) { 101 if (data().phantom) {
100 SkRect bounds; 102 SkRect bounds;
101 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height())); 103 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
102 canvas->saveLayerAlpha(&bounds, kPhantomTabIconAlpha, 104 canvas->AsCanvasSkia()->saveLayerAlpha(
103 SkCanvas::kARGB_ClipLayer_SaveFlag); 105 &bounds, kPhantomTabIconAlpha, SkCanvas::kARGB_ClipLayer_SaveFlag);
104 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y()); 106 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y());
105 canvas->restore(); 107 canvas->AsCanvasSkia()->restore();
106 } else { 108 } else {
107 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y()); 109 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y());
108 } 110 }
109 } 111 }
110 112
111 PaintTitle(canvas, data().phantom ? kPhantomTextColor : kTextColor); 113 PaintTitle(canvas, data().phantom ? kPhantomTextColor : kTextColor);
112 } 114 }
113 115
114 gfx::Size SideTab::GetPreferredSize() { 116 gfx::Size SideTab::GetPreferredSize() {
115 return gfx::Size(0, GetPreferredHeight()); 117 return gfx::Size(0, GetPreferredHeight());
116 } 118 }
117 119
118 bool SideTab::ShouldPaintHighlight() const { 120 bool SideTab::ShouldPaintHighlight() const {
119 return IsSelected() || !controller(); 121 return IsSelected() || !controller();
120 } 122 }
121 123
122 bool SideTab::ShouldShowIcon() const { 124 bool SideTab::ShouldShowIcon() const {
123 return data().mini || data().show_icon; 125 return data().mini || data().show_icon;
124 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698