forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG=none TEST=none Review URL: http://codereview.chromium.org/140007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18925 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
avi@chromium.org
committed
Jun 22, 2009
1 parent
3e3f0eb
commit 1279d5f
Showing
8 changed files
with
147 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) 2009 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "app/theme_provider.h" | ||
|
||
// We have the destructor here because GCC puts the vtable in the first file | ||
// that includes a virtual function of the class. Leaving it just in the .h file | ||
// means that GCC will fail to link. | ||
|
||
ThemeProvider::~ThemeProvider() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2009 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/browser_theme_provider.h" | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
#include "base/logging.h" | ||
|
||
NSImage* BrowserThemeProvider::GetNSImageNamed(int id) { | ||
DCHECK(CalledOnValidThread()); | ||
|
||
// Check to see if we already have the image in the cache. | ||
NSImageMap::const_iterator found = nsimage_cache_.find(id); | ||
if (found != nsimage_cache_.end()) | ||
return found->second; | ||
|
||
// Why do we load the file directly into the image rather than doing the whole | ||
// SkBitmap > native conversion that others do? Going direct means: | ||
// - we use the color profiles and other embedded info in the image file | ||
// - we don't fall back to the default resources which we don't use on the Mac | ||
std::vector<unsigned char> raw_data; | ||
if (ReadThemeFileData(id, &raw_data)) { | ||
NSData* ns_data = [NSData dataWithBytes:&raw_data.front() | ||
length:raw_data.size()]; | ||
if (ns_data) { | ||
NSImage* nsimage = [[NSImage alloc] initWithData:ns_data]; | ||
|
||
// We loaded successfully. Cache the image. | ||
if (nsimage) { | ||
nsimage_cache_[id] = nsimage; | ||
return nsimage; | ||
} | ||
} | ||
} | ||
|
||
return nil; | ||
} | ||
|
||
void BrowserThemeProvider::FreePlatformImages() { | ||
DCHECK(CalledOnValidThread()); | ||
|
||
// Free images. | ||
for (NSImageMap::iterator i = nsimage_cache_.begin(); | ||
i != nsimage_cache_.end(); i++) { | ||
[i->second release]; | ||
} | ||
nsimage_cache_.clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters