| OLD | NEW |
| 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/libgtk2ui/gtk2_ui.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 fake_label_.Destroy(); | 302 fake_label_.Destroy(); |
| 303 fake_entry_.Destroy(); | 303 fake_entry_.Destroy(); |
| 304 | 304 |
| 305 ClearAllThemeData(); | 305 ClearAllThemeData(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 bool Gtk2UI::UseNativeTheme() const { | 308 bool Gtk2UI::UseNativeTheme() const { |
| 309 return true; | 309 return true; |
| 310 } | 310 } |
| 311 | 311 |
| 312 gfx::Image* Gtk2UI::GetThemeImageNamed(int id) const { | 312 gfx::Image Gtk2UI::GetThemeImageNamed(int id) const { |
| 313 // Try to get our cached version: | 313 // Try to get our cached version: |
| 314 ImageCache::const_iterator it = gtk_images_.find(id); | 314 ImageCache::const_iterator it = gtk_images_.find(id); |
| 315 if (it != gtk_images_.end()) | 315 if (it != gtk_images_.end()) |
| 316 return it->second; | 316 return it->second; |
| 317 | 317 |
| 318 if (/*use_gtk_ && */ IsOverridableImage(id)) { | 318 if (/*use_gtk_ && */ IsOverridableImage(id)) { |
| 319 gfx::Image* image = new gfx::Image( | 319 gfx::Image image = gfx::Image( |
| 320 gfx::ImageSkia::CreateFrom1xBitmap(GenerateGtkThemeBitmap(id))); | 320 gfx::ImageSkia::CreateFrom1xBitmap(GenerateGtkThemeBitmap(id))); |
| 321 gtk_images_[id] = image; | 321 gtk_images_[id] = image; |
| 322 return image; | 322 return image; |
| 323 } | 323 } |
| 324 | 324 |
| 325 return NULL; | 325 return gfx::Image(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 bool Gtk2UI::GetColor(int id, SkColor* color) const { | 328 bool Gtk2UI::GetColor(int id, SkColor* color) const { |
| 329 ColorMap::const_iterator it = colors_.find(id); | 329 ColorMap::const_iterator it = colors_.find(id); |
| 330 if (it != colors_.end()) { | 330 if (it != colors_.end()) { |
| 331 *color = it->second; | 331 *color = it->second; |
| 332 return true; | 332 return true; |
| 333 } | 333 } |
| 334 | 334 |
| 335 return false; | 335 return false; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 | 788 |
| 789 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint); | 789 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint); |
| 790 } | 790 } |
| 791 | 791 |
| 792 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth, | 792 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth, |
| 793 kToolbarImageHeight - gradient_size), base); | 793 kToolbarImageHeight - gradient_size), base); |
| 794 return canvas.ExtractImageRep().sk_bitmap(); | 794 return canvas.ExtractImageRep().sk_bitmap(); |
| 795 } | 795 } |
| 796 | 796 |
| 797 SkBitmap Gtk2UI::GenerateTabImage(int base_id) const { | 797 SkBitmap Gtk2UI::GenerateTabImage(int base_id) const { |
| 798 const SkBitmap* base_image = GetThemeImageNamed(base_id)->ToSkBitmap(); | 798 const SkBitmap* base_image = GetThemeImageNamed(base_id).ToSkBitmap(); |
| 799 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( | 799 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( |
| 800 *base_image, GetDefaultTint(ThemeProperties::TINT_BACKGROUND_TAB)); | 800 *base_image, GetDefaultTint(ThemeProperties::TINT_BACKGROUND_TAB)); |
| 801 return SkBitmapOperations::CreateTiledBitmap( | 801 return SkBitmapOperations::CreateTiledBitmap( |
| 802 bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); | 802 bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); |
| 803 } | 803 } |
| 804 | 804 |
| 805 SkBitmap Gtk2UI::GenerateTintedIcon( | 805 SkBitmap Gtk2UI::GenerateTintedIcon( |
| 806 int base_id, | 806 int base_id, |
| 807 const color_utils::HSL& tint) const { | 807 const color_utils::HSL& tint) const { |
| 808 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 808 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 // Finally, we convert our pixbuf into a type we can use. | 966 // Finally, we convert our pixbuf into a type we can use. |
| 967 SkBitmap border = GdkPixbufToImageSkia(pixbuf); | 967 SkBitmap border = GdkPixbufToImageSkia(pixbuf); |
| 968 g_object_unref(pixbuf); | 968 g_object_unref(pixbuf); |
| 969 g_object_unref(pixmap); | 969 g_object_unref(pixmap); |
| 970 gtk_widget_destroy(window); | 970 gtk_widget_destroy(window); |
| 971 | 971 |
| 972 return border; | 972 return border; |
| 973 } | 973 } |
| 974 | 974 |
| 975 void Gtk2UI::ClearAllThemeData() { | 975 void Gtk2UI::ClearAllThemeData() { |
| 976 STLDeleteValues(>k_images_); | 976 gtk_images_.clear(); |
| 977 } | 977 } |
| 978 | 978 |
| 979 } // namespace libgtk2ui | 979 } // namespace libgtk2ui |
| 980 | 980 |
| 981 ui::LinuxUI* BuildGtk2UI() { | 981 ui::LinuxUI* BuildGtk2UI() { |
| 982 return new libgtk2ui::Gtk2UI; | 982 return new libgtk2ui::Gtk2UI; |
| 983 } | 983 } |
| OLD | NEW |