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/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1147 if (animation->current_part_index() == 2) { | 1147 if (animation->current_part_index() == 2) { |
1148 uint8 alpha = animation->CurrentValueBetween(255, 0); | 1148 uint8 alpha = animation->CurrentValueBetween(255, 0); |
1149 canvas->DrawImageInt(hover_image, 0, 0, alpha); | 1149 canvas->DrawImageInt(hover_image, 0, 0, alpha); |
1150 } else { | 1150 } else { |
1151 canvas->DrawImageInt(hover_image, 0, 0); | 1151 canvas->DrawImageInt(hover_image, 0, 0); |
1152 } | 1152 } |
1153 } | 1153 } |
1154 | 1154 |
1155 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { | 1155 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { |
1156 int tab_id; | 1156 int tab_id; |
1157 int tab_base_id; | |
1157 views::Widget* widget = GetWidget(); | 1158 views::Widget* widget = GetWidget(); |
1158 if (widget && widget->GetTopLevelWidget()->ShouldUseNativeFrame()) { | 1159 if (widget && widget->GetTopLevelWidget()->ShouldUseNativeFrame()) { |
1159 tab_id = IDR_THEME_TAB_BACKGROUND_V; | 1160 tab_id = IDR_THEME_TAB_BACKGROUND_V; |
1161 tab_base_id = 0; | |
sky
2013/02/11 21:21:55
Is 0 known to be ignored? I think I would rather h
| |
1160 } else if (data().incognito) { | 1162 } else if (data().incognito) { |
1161 tab_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO; | 1163 tab_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO; |
1164 tab_base_id = IDR_THEME_FRAME_INCOGNITO; | |
1162 #if defined(OS_WIN) | 1165 #if defined(OS_WIN) |
1163 } else if (win8::IsSingleWindowMetroMode()) { | 1166 } else if (win8::IsSingleWindowMetroMode()) { |
1164 tab_id = IDR_THEME_TAB_BACKGROUND_V; | 1167 tab_id = IDR_THEME_TAB_BACKGROUND_V; |
1168 tab_base_id = 0; | |
1165 #endif | 1169 #endif |
1166 } else { | 1170 } else { |
1167 tab_id = IDR_THEME_TAB_BACKGROUND; | 1171 tab_id = IDR_THEME_TAB_BACKGROUND; |
1172 tab_base_id = IDR_THEME_FRAME; | |
1168 } | 1173 } |
1169 // Explicitly map the id so we cache correctly. | 1174 // Explicitly map the id so we cache correctly. |
1170 const chrome::HostDesktopType host_desktop_type = GetHostDesktopType(this); | 1175 const chrome::HostDesktopType host_desktop_type = GetHostDesktopType(this); |
1171 tab_id = chrome::MapThemeImage(host_desktop_type, tab_id); | 1176 tab_id = chrome::MapThemeImage(host_desktop_type, tab_id); |
1172 | 1177 |
1173 const bool can_cache = !GetThemeProvider()->HasCustomImage(tab_id) && | 1178 // Do not cache the tab background if the theme provides a custom tab |
1179 // background or if a tab background was autogenerated by the theme | |
1180 // machinery. | |
1181 ui::ThemeProvider* theme_provider = GetThemeProvider(); | |
1182 const bool can_cache = !theme_provider->HasCustomImage(tab_id) && | |
1183 !theme_provider->HasCustomImage(tab_base_id) && | |
1174 !hover_controller_.ShouldDraw(); | 1184 !hover_controller_.ShouldDraw(); |
1175 | 1185 |
1176 if (can_cache) { | 1186 if (can_cache) { |
1177 gfx::ImageSkia cached_image( | 1187 gfx::ImageSkia cached_image( |
1178 GetCachedImage(tab_id, size(), canvas->scale_factor())); | 1188 GetCachedImage(tab_id, size(), canvas->scale_factor())); |
1179 if (cached_image.width() == 0) { | 1189 if (cached_image.width() == 0) { |
1180 gfx::Canvas tmp_canvas(size(), canvas->scale_factor(), false); | 1190 gfx::Canvas tmp_canvas(size(), canvas->scale_factor(), false); |
1181 PaintInactiveTabBackgroundUsingResourceId(&tmp_canvas, tab_id); | 1191 PaintInactiveTabBackgroundUsingResourceId(&tmp_canvas, tab_id); |
1182 cached_image = gfx::ImageSkia(tmp_canvas.ExtractImageRep()); | 1192 cached_image = gfx::ImageSkia(tmp_canvas.ExtractImageRep()); |
1183 SetCachedImage(tab_id, canvas->scale_factor(), cached_image); | 1193 SetCachedImage(tab_id, canvas->scale_factor(), cached_image); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1642 const gfx::ImageSkia& image) { | 1652 const gfx::ImageSkia& image) { |
1643 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1653 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
1644 ImageCacheEntry entry; | 1654 ImageCacheEntry entry; |
1645 entry.resource_id = resource_id; | 1655 entry.resource_id = resource_id; |
1646 entry.scale_factor = scale_factor; | 1656 entry.scale_factor = scale_factor; |
1647 entry.image = image; | 1657 entry.image = image; |
1648 image_cache_->push_front(entry); | 1658 image_cache_->push_front(entry); |
1649 if (image_cache_->size() > kMaxImageCacheSize) | 1659 if (image_cache_->size() > kMaxImageCacheSize) |
1650 image_cache_->pop_back(); | 1660 image_cache_->pop_back(); |
1651 } | 1661 } |
OLD | NEW |