From 6de2799a47cbc201d943b32e0ac62555dc45f662 Mon Sep 17 00:00:00 2001 From: "erg@google.com" Date: Mon, 19 Oct 2009 17:04:46 +0000 Subject: First fix to minimize copying of image data. This is the first of multiple patches that clean up handling of memory regarding images. Previously, the code did several memcpy()s or equivalents. This change: - Creates an abstract interface RefCountedMemory which provides access to the front() of a memory range and the size() of it. It is a RefCountedThreadSafe. - Adds a RefCountedStaticMemory class which isa RefCountedMemory. - Pushes RefCountedBytes up into base/ from chrome/ and make it conform to RefCountedMemory. - Have ResourceBundle return RefCountedStaticMemory to the mmaped() or DLL loaded resources instead of memcpy()ing them. - General cleanups to minimize copies in constructing RefCountedBytes. - Use the above consistent interface in the BrowserThemeProvider, along with special casing the loading of the new tab page background. This patch is mostly cleanups and there should only be a slight performance gain if any. Most of the real speedups should come in subsequent patches. BUG=http://crbug.com/24493 TEST=Slightly faster on Perf bot; does not introduce crashes. Review URL: http://codereview.chromium.org/288005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29412 0039d316-1c4b-4281-b951-d872f2087c98 --- app/theme_provider.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/theme_provider.h') diff --git a/app/theme_provider.h b/app/theme_provider.h index c3b8a9c..410e699 100644 --- a/app/theme_provider.h +++ b/app/theme_provider.h @@ -23,6 +23,7 @@ class NSImage; #endif // OS_* class Profile; +class RefCountedMemory; class SkBitmap; //////////////////////////////////////////////////////////////////////////////// @@ -60,10 +61,9 @@ class ThemeProvider { // doesn't provide a certain image, but custom themes might (badges, etc). virtual bool HasCustomImage(int id) const = 0; - // Reads the image data from the theme file into the specified vector. Returns - // true on success. - virtual bool GetRawData(int id, - std::vector* raw_data) const = 0; + // Reads the image data from the theme file into the specified + // vector. Returns NULL on error. + virtual RefCountedMemory* GetRawData(int id) const = 0; #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) // Gets the GdkPixbuf with the specified |id|. Returns a pointer to a shared -- cgit v1.1