diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index c59825c0b6..23da1b9f17 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -138,9 +138,7 @@ mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder( .SetMethod("toDataUrl", &NativeImage::ToDataURL) .SetMethod("isEmpty", &NativeImage::IsEmpty) .SetMethod("getSize", &NativeImage::GetSize) - #if defined(OS_MACOSX) .SetMethod("setTemplateImage", &NativeImage::SetTemplateImage) - #endif .Build()); return mate::ObjectTemplateBuilder( @@ -179,6 +177,11 @@ gfx::Size NativeImage::GetSize() { return image_.Size(); } +#if !defined(OS_MACOSX) +void NativeImage::SetTemplateImage(bool setAsTemplate) { +} +#endif + // static mate::Handle NativeImage::CreateEmpty(v8::Isolate* isolate) { return mate::CreateHandle(isolate, new NativeImage); @@ -212,11 +215,12 @@ mate::Handle NativeImage::CreateFromPath( gfx::ImageSkia image_skia; PopulateImageSkiaRepsFromPath(&image_skia, path); gfx::Image image(image_skia); + mate::Handle handle = Create(isolate, image); #if defined(OS_MACOSX) if (IsTemplateImage(path)) - MakeTemplateImage(&image); + handle->SetTemplateImage(true); #endif - return Create(isolate, image); + return handle; } // static diff --git a/atom/common/api/atom_api_native_image.h b/atom/common/api/atom_api_native_image.h index 627ca9afc2..0815013488 100644 --- a/atom/common/api/atom_api_native_image.h +++ b/atom/common/api/atom_api_native_image.h @@ -59,18 +59,15 @@ class NativeImage : public mate::Wrappable { v8::Isolate* isolate) override; private: -#if defined(OS_MACOSX) - // Mark the image as template image if possible. - static void MakeTemplateImage(gfx::Image* image); - void SetTemplateImage(bool setAsTemplate); -#endif - v8::Handle ToPNG(v8::Isolate* isolate); v8::Handle ToJPEG(v8::Isolate* isolate, int quality); std::string ToDataURL(); bool IsEmpty(); gfx::Size GetSize(); + // Mark the image as template image. + void SetTemplateImage(bool setAsTemplate); + gfx::Image image_; DISALLOW_COPY_AND_ASSIGN(NativeImage); diff --git a/atom/common/api/atom_api_native_image_mac.mm b/atom/common/api/atom_api_native_image_mac.mm index fb7c03cb93..a80462766b 100644 --- a/atom/common/api/atom_api_native_image_mac.mm +++ b/atom/common/api/atom_api_native_image_mac.mm @@ -10,11 +10,6 @@ namespace atom { namespace api { -// static -void NativeImage::MakeTemplateImage(gfx::Image* image) { - [image->AsNSImage() setTemplate:YES]; -} - void NativeImage::SetTemplateImage(bool setAsTemplate) { [image_.AsNSImage() setTemplate:setAsTemplate]; } diff --git a/docs/api/native-image.md b/docs/api/native-image.md index 9e7b35420c..60c5e886f7 100644 --- a/docs/api/native-image.md +++ b/docs/api/native-image.md @@ -136,4 +136,4 @@ Returns the size of the image. * `option` Boolean -To toggle a `NativeImage` as Template image on OSX +Marks the image as template image.