diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-19 17:04:46 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-19 17:04:46 +0000 |
commit | 6de2799a47cbc201d943b32e0ac62555dc45f662 (patch) | |
tree | 6c64342df90783c5f334d370d6f8cb08472fcd7f /chrome/browser/browser_theme_provider.h | |
parent | 5f1b13bc6952eb89149716930e654c9d989b9e13 (diff) | |
download | chromium_src-6de2799a47cbc201d943b32e0ac62555dc45f662.zip chromium_src-6de2799a47cbc201d943b32e0ac62555dc45f662.tar.gz chromium_src-6de2799a47cbc201d943b32e0ac62555dc45f662.tar.bz2 |
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
Diffstat (limited to 'chrome/browser/browser_theme_provider.h')
-rw-r--r-- | chrome/browser/browser_theme_provider.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/chrome/browser/browser_theme_provider.h b/chrome/browser/browser_theme_provider.h index 02fec9b..f54c3ca 100644 --- a/chrome/browser/browser_theme_provider.h +++ b/chrome/browser/browser_theme_provider.h @@ -162,7 +162,7 @@ class BrowserThemeProvider : public NonThreadSafe, virtual bool GetDisplayProperty(int id, int* result) const; virtual bool ShouldUseNativeFrame() const; virtual bool HasCustomImage(int id) const; - virtual bool GetRawData(int id, std::vector<unsigned char>* raw_data) const; + virtual RefCountedMemory* GetRawData(int id) const; #if defined(OS_LINUX) virtual GdkPixbuf* GetPixbufNamed(int id) const; virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const; @@ -188,7 +188,7 @@ class BrowserThemeProvider : public NonThreadSafe, // Reads the image data from the theme file into the specified vector. Returns // true on success. - bool ReadThemeFileData(int id, std::vector<unsigned char>* raw_data) const; + RefCountedMemory* ReadThemeFileData(int id) const; // Convert a bitfield alignment into a string like "top left". Public so that // it can be used to generate CSS values. Takes a bitfield of AlignmentMasks. @@ -277,7 +277,7 @@ class BrowserThemeProvider : public NonThreadSafe, typedef std::map<const std::string, SkColor> ColorMap; typedef std::map<const std::string, color_utils::HSL> TintMap; typedef std::map<const std::string, int> DisplayPropertyMap; - typedef std::map<const int, std::vector<unsigned char> > RawDataMap; + typedef std::map<const int, scoped_refptr<RefCountedMemory> > RawDataMap; typedef std::map<const int, std::string> ResourceNameMap; // Returns the string key for the given tint |id| TINT_* enum value. |