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

Side by Side Diff: chrome/browser/ui/libgtkui/native_theme_gtk.cc

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/libgtkui/native_theme_gtk.h" 5 #include "chrome/browser/ui/libgtkui/native_theme_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h" 9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h"
10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h" 10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h"
11 #include "chrome/browser/ui/libgtkui/gtk_ui.h" 11 #include "chrome/browser/ui/libgtkui/gtk_ui.h"
12 #include "chrome/browser/ui/libgtkui/gtk_util.h" 12 #include "chrome/browser/ui/libgtkui/gtk_util.h"
13 #include "chrome/browser/ui/libgtkui/skia_utils_gtk.h" 13 #include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
14 #include "skia/ext/cdl_paint.h"
14 #include "third_party/skia/include/core/SkColor.h" 15 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/gfx/color_palette.h" 16 #include "ui/gfx/color_palette.h"
16 #include "ui/gfx/color_utils.h" 17 #include "ui/gfx/color_utils.h"
17 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/geometry/size.h" 19 #include "ui/gfx/geometry/size.h"
19 #include "ui/gfx/path.h" 20 #include "ui/gfx/path.h"
20 #include "ui/gfx/skia_util.h" 21 #include "ui/gfx/skia_util.h"
21 #include "ui/native_theme/common_theme.h" 22 #include "ui/native_theme/common_theme.h"
22 #include "ui/native_theme/native_theme_aura.h" 23 #include "ui/native_theme/native_theme_aura.h"
23 #include "ui/native_theme/native_theme_dark_aura.h" 24 #include "ui/native_theme/native_theme_dark_aura.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk2, s_native_theme, ()); 165 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk2, s_native_theme, ());
165 return &s_native_theme; 166 return &s_native_theme;
166 } 167 }
167 168
168 // Constructors automatically called 169 // Constructors automatically called
169 NativeThemeGtk2::NativeThemeGtk2() {} 170 NativeThemeGtk2::NativeThemeGtk2() {}
170 // This doesn't actually get called 171 // This doesn't actually get called
171 NativeThemeGtk2::~NativeThemeGtk2() {} 172 NativeThemeGtk2::~NativeThemeGtk2() {}
172 173
173 void NativeThemeGtk2::PaintMenuPopupBackground( 174 void NativeThemeGtk2::PaintMenuPopupBackground(
174 SkCanvas* canvas, 175 CdlCanvas* canvas,
175 const gfx::Size& size, 176 const gfx::Size& size,
176 const MenuBackgroundExtraParams& menu_background) const { 177 const MenuBackgroundExtraParams& menu_background) const {
177 if (menu_background.corner_radius > 0) { 178 if (menu_background.corner_radius > 0) {
178 SkPaint paint; 179 CdlPaint paint;
179 paint.setStyle(SkPaint::kFill_Style); 180 paint.setStyle(CdlPaint::kFill_Style);
180 paint.setFlags(SkPaint::kAntiAlias_Flag); 181 paint.setAntiAlias(true);
181 paint.setColor(GetSystemColor(kColorId_MenuBackgroundColor)); 182 paint.setColor(GetSystemColor(kColorId_MenuBackgroundColor));
182 183
183 gfx::Path path; 184 gfx::Path path;
184 SkRect rect = SkRect::MakeWH(SkIntToScalar(size.width()), 185 SkRect rect = SkRect::MakeWH(SkIntToScalar(size.width()),
185 SkIntToScalar(size.height())); 186 SkIntToScalar(size.height()));
186 SkScalar radius = SkIntToScalar(menu_background.corner_radius); 187 SkScalar radius = SkIntToScalar(menu_background.corner_radius);
187 SkScalar radii[8] = {radius, radius, radius, radius, 188 SkScalar radii[8] = {radius, radius, radius, radius,
188 radius, radius, radius, radius}; 189 radius, radius, radius, radius};
189 path.addRoundRect(rect, radii); 190 path.addRoundRect(rect, radii);
190 191
191 canvas->drawPath(path, paint); 192 canvas->drawPath(path, paint);
192 } else { 193 } else {
193 canvas->drawColor(GetSystemColor(kColorId_MenuBackgroundColor), 194 canvas->drawColor(GetSystemColor(kColorId_MenuBackgroundColor),
194 SkBlendMode::kSrc); 195 SkBlendMode::kSrc);
195 } 196 }
196 } 197 }
197 198
198 void NativeThemeGtk2::PaintMenuItemBackground( 199 void NativeThemeGtk2::PaintMenuItemBackground(
199 SkCanvas* canvas, 200 CdlCanvas* canvas,
200 State state, 201 State state,
201 const gfx::Rect& rect, 202 const gfx::Rect& rect,
202 const MenuItemExtraParams& menu_item) const { 203 const MenuItemExtraParams& menu_item) const {
203 SkColor color; 204 SkColor color;
204 SkPaint paint; 205 CdlPaint paint;
205 switch (state) { 206 switch (state) {
206 case NativeTheme::kNormal: 207 case NativeTheme::kNormal:
207 case NativeTheme::kDisabled: 208 case NativeTheme::kDisabled:
208 color = GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor); 209 color = GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor);
209 paint.setColor(color); 210 paint.setColor(color);
210 break; 211 break;
211 case NativeTheme::kHovered: 212 case NativeTheme::kHovered:
212 color = 213 color =
213 GetSystemColor(NativeTheme::kColorId_FocusedMenuItemBackgroundColor); 214 GetSystemColor(NativeTheme::kColorId_FocusedMenuItemBackgroundColor);
214 paint.setColor(color); 215 paint.setColor(color);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 563
563 if (!fake_menu_item) { 564 if (!fake_menu_item) {
564 fake_menu_item = gtk_custom_menu_item_new(); 565 fake_menu_item = gtk_custom_menu_item_new();
565 gtk_menu_shell_append(GTK_MENU_SHELL(GetMenu()), fake_menu_item); 566 gtk_menu_shell_append(GTK_MENU_SHELL(GetMenu()), fake_menu_item);
566 } 567 }
567 568
568 return fake_menu_item; 569 return fake_menu_item;
569 } 570 }
570 571
571 } // namespace libgtkui 572 } // namespace libgtkui
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtkui/native_theme_gtk.h ('k') | chrome/browser/ui/views/create_application_shortcut_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698