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

Unified Diff: chrome/browser/themes/theme_service.cc

Issue 1869693002: Theme suppliers: Avoid all Image copying. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_aurax11.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/themes/theme_service.cc
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 11e8f1767a9b9aa2ed06f5019d260690fb9e900e..8f47278d09c158a334fdd99cacfe6d8db1b96336 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -672,7 +672,7 @@ SkColor ThemeService::GetSeparatorColor(SkColor tab_color,
}
gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id, bool incognito) const {
- gfx::Image image = GetImageNamed(id, incognito);
+ const gfx::Image& image = GetImageNamed(id, incognito);
if (image.IsEmpty())
return nullptr;
// TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns
@@ -744,7 +744,7 @@ base::RefCountedMemory* ThemeService::GetRawData(
return data;
}
-gfx::Image ThemeService::GetImageNamed(int id, bool incognito) const {
+const gfx::Image& ThemeService::GetImageNamed(int id, bool incognito) const {
DCHECK(CalledOnValidThread());
int adjusted_id = id;
@@ -755,14 +755,13 @@ gfx::Image ThemeService::GetImageNamed(int id, bool incognito) const {
adjusted_id = IDR_THEME_FRAME_INCOGNITO_INACTIVE;
}
- gfx::Image image;
- if (theme_supplier_)
- image = theme_supplier_->GetImageNamed(adjusted_id);
-
- if (image.IsEmpty())
- image = rb_.GetNativeImageNamed(adjusted_id);
+ if (theme_supplier_) {
+ const gfx::Image& image = theme_supplier_->GetImageNamed(adjusted_id);
+ if (!image.IsEmpty())
+ return image;
+ }
- return image;
+ return rb_.GetNativeImageNamed(adjusted_id);
}
void ThemeService::OnExtensionServiceReady() {
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698