diff options
-rw-r--r-- | app/resource_bundle.h | 11 | ||||
-rw-r--r-- | app/resource_bundle_mac.mm | 12 | ||||
-rw-r--r-- | skia/skia.gyp | 3 |
3 files changed, 26 insertions, 0 deletions
diff --git a/app/resource_bundle.h b/app/resource_bundle.h index bba8560..85b4b65 100644 --- a/app/resource_bundle.h +++ b/app/resource_bundle.h @@ -35,6 +35,14 @@ class SkBitmap; typedef uint32 SkColor; class StringPiece; +#if defined(OS_MACOSX) +#ifdef __OBJC__ +@class NSImage; +#else +class NSImage; +#endif // __OBJC__ +#endif // defined(OS_MACOSX) + // ResourceBundle is a central facility to load images and other resources, // such as theme graphics. // Every resource is loaded only once. @@ -112,6 +120,9 @@ class ResourceBundle { // Loads and returns a cursor from the app module. HCURSOR LoadCursor(int cursor_id); +#elif defined(OS_MACOSX) + // Wrapper for GetBitmapNamed. Converts the bitmap to an autoreleased NSImage. + NSImage* GetNSImageNamed(int resource_id); #elif defined(OS_LINUX) // Gets the GdkPixbuf with the specified resource_id, first by looking into // the theme data, than in the current module data if applicable. Returns a diff --git a/app/resource_bundle_mac.mm b/app/resource_bundle_mac.mm index 22ab274..e96ed54 100644 --- a/app/resource_bundle_mac.mm +++ b/app/resource_bundle_mac.mm @@ -17,6 +17,7 @@ #include "base/path_service.h" #include "base/string_piece.h" #include "base/string_util.h" +#include "skia/ext/skia_utils_mac.h" ResourceBundle::~ResourceBundle() { FreeImages(); @@ -116,3 +117,14 @@ string16 ResourceBundle::GetLocalizedString(int message_id) { data.length() / 2); return msg; } + +NSImage* ResourceBundle::GetNSImageNamed(int resource_id) { + // Currently this doesn't make a cache holding these as NSImages because + // GetBitmapNamed has a cache, and we don't want to double cache. + SkBitmap* bitmap = GetBitmapNamed(resource_id); + if (!bitmap) + return nil; + + NSImage* nsimage = gfx::SkBitmapToNSImage(*bitmap); + return nsimage; +} diff --git a/skia/skia.gyp b/skia/skia.gyp index 6fd6d639..63cac887 100644 --- a/skia/skia.gyp +++ b/skia/skia.gyp @@ -644,6 +644,9 @@ '../third_party/skia/include/effects', 'ext', ], + 'mac_framework_dirs': [ + '$(SDKROOT)/System/Library/Frameworks/ApplicationServices.framework/Frameworks', + ], }, }, ], |