| 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 <math.h> | 7 #include <math.h> |
| 8 #include <pango/pango.h> | 8 #include <pango/pango.h> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 } | 517 } |
| 518 | 518 |
| 519 void Gtk2UI::MaterialDesignControllerReady() { | 519 void Gtk2UI::MaterialDesignControllerReady() { |
| 520 UpdateMaterialDesignColors(); | 520 UpdateMaterialDesignColors(); |
| 521 } | 521 } |
| 522 | 522 |
| 523 Gtk2UI::~Gtk2UI() { | 523 Gtk2UI::~Gtk2UI() { |
| 524 ClearAllThemeData(); | 524 ClearAllThemeData(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 gfx::Image Gtk2UI::GetThemeImageNamed(int id) const { | 527 const gfx::Image& Gtk2UI::GetThemeImageNamed(int id) const { |
| 528 // Try to get our cached version: | 528 // Try to get our cached version: |
| 529 ImageCache::const_iterator it = gtk_images_.find(id); | 529 ImageCache::const_iterator it = gtk_images_.find(id); |
| 530 if (it != gtk_images_.end()) | 530 if (it != gtk_images_.end()) |
| 531 return it->second; | 531 return it->second; |
| 532 | 532 |
| 533 gfx::Image image = GenerateGtkThemeImage(id); | 533 gfx::Image image = GenerateGtkThemeImage(id); |
| 534 | 534 |
| 535 if (image.IsEmpty()) { | 535 if (image.IsEmpty()) { |
| 536 SkBitmap bitmap = GenerateGtkThemeBitmap(id); | 536 SkBitmap bitmap = GenerateGtkThemeBitmap(id); |
| 537 if (!bitmap.empty()) | 537 if (!bitmap.empty()) |
| 538 image = gfx::Image::CreateFrom1xBitmap(bitmap); | 538 image = gfx::Image::CreateFrom1xBitmap(bitmap); |
| 539 } | 539 } |
| 540 | 540 |
| 541 gtk_images_[id] = image; | 541 auto result = gtk_images_.insert(std::make_pair(id, image)); |
| 542 return image; | 542 return result.first->second; |
| 543 } | 543 } |
| 544 | 544 |
| 545 bool Gtk2UI::GetTint(int id, color_utils::HSL* tint) const { | 545 bool Gtk2UI::GetTint(int id, color_utils::HSL* tint) const { |
| 546 switch (id) { | 546 switch (id) { |
| 547 case ThemeProperties::TINT_BACKGROUND_TAB: | 547 case ThemeProperties::TINT_BACKGROUND_TAB: |
| 548 // Tints for which the cross-platform default is fine. Before adding new | 548 // Tints for which the cross-platform default is fine. Before adding new |
| 549 // values here, specifically verify they work well on Linux. | 549 // values here, specifically verify they work well on Linux. |
| 550 break; | 550 break; |
| 551 default: | 551 default: |
| 552 // Assume any tints not specifically verified on Linux aren't usable. | 552 // Assume any tints not specifically verified on Linux aren't usable. |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 // Blacklist scaling factors <130% (crbug.com/484400) and round | 1390 // Blacklist scaling factors <130% (crbug.com/484400) and round |
| 1391 // to 1 decimal to prevent rendering problems (crbug.com/485183). | 1391 // to 1 decimal to prevent rendering problems (crbug.com/485183). |
| 1392 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10; | 1392 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10; |
| 1393 } | 1393 } |
| 1394 | 1394 |
| 1395 } // namespace libgtk2ui | 1395 } // namespace libgtk2ui |
| 1396 | 1396 |
| 1397 views::LinuxUI* BuildGtk2UI() { | 1397 views::LinuxUI* BuildGtk2UI() { |
| 1398 return new libgtk2ui::Gtk2UI; | 1398 return new libgtk2ui::Gtk2UI; |
| 1399 } | 1399 } |
| OLD | NEW |