Remove the NativeImage::MakeTemplateImage method

Is duplicate with SetTemplateImage.
This commit is contained in:
Cheng Zhao 2015-04-13 11:53:24 +08:00
Родитель f11988a354
Коммит 91c9f590dd
4 изменённых файлов: 12 добавлений и 16 удалений

Просмотреть файл

@ -138,9 +138,7 @@ mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder(
.SetMethod("toDataUrl", &NativeImage::ToDataURL) .SetMethod("toDataUrl", &NativeImage::ToDataURL)
.SetMethod("isEmpty", &NativeImage::IsEmpty) .SetMethod("isEmpty", &NativeImage::IsEmpty)
.SetMethod("getSize", &NativeImage::GetSize) .SetMethod("getSize", &NativeImage::GetSize)
#if defined(OS_MACOSX)
.SetMethod("setTemplateImage", &NativeImage::SetTemplateImage) .SetMethod("setTemplateImage", &NativeImage::SetTemplateImage)
#endif
.Build()); .Build());
return mate::ObjectTemplateBuilder( return mate::ObjectTemplateBuilder(
@ -179,6 +177,11 @@ gfx::Size NativeImage::GetSize() {
return image_.Size(); return image_.Size();
} }
#if !defined(OS_MACOSX)
void NativeImage::SetTemplateImage(bool setAsTemplate) {
}
#endif
// static // static
mate::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) { mate::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) {
return mate::CreateHandle(isolate, new NativeImage); return mate::CreateHandle(isolate, new NativeImage);
@ -212,11 +215,12 @@ mate::Handle<NativeImage> NativeImage::CreateFromPath(
gfx::ImageSkia image_skia; gfx::ImageSkia image_skia;
PopulateImageSkiaRepsFromPath(&image_skia, path); PopulateImageSkiaRepsFromPath(&image_skia, path);
gfx::Image image(image_skia); gfx::Image image(image_skia);
mate::Handle<NativeImage> handle = Create(isolate, image);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
if (IsTemplateImage(path)) if (IsTemplateImage(path))
MakeTemplateImage(&image); handle->SetTemplateImage(true);
#endif #endif
return Create(isolate, image); return handle;
} }
// static // static

Просмотреть файл

@ -59,18 +59,15 @@ class NativeImage : public mate::Wrappable {
v8::Isolate* isolate) override; v8::Isolate* isolate) override;
private: 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<v8::Value> ToPNG(v8::Isolate* isolate); v8::Handle<v8::Value> ToPNG(v8::Isolate* isolate);
v8::Handle<v8::Value> ToJPEG(v8::Isolate* isolate, int quality); v8::Handle<v8::Value> ToJPEG(v8::Isolate* isolate, int quality);
std::string ToDataURL(); std::string ToDataURL();
bool IsEmpty(); bool IsEmpty();
gfx::Size GetSize(); gfx::Size GetSize();
// Mark the image as template image.
void SetTemplateImage(bool setAsTemplate);
gfx::Image image_; gfx::Image image_;
DISALLOW_COPY_AND_ASSIGN(NativeImage); DISALLOW_COPY_AND_ASSIGN(NativeImage);

Просмотреть файл

@ -10,11 +10,6 @@ namespace atom {
namespace api { namespace api {
// static
void NativeImage::MakeTemplateImage(gfx::Image* image) {
[image->AsNSImage() setTemplate:YES];
}
void NativeImage::SetTemplateImage(bool setAsTemplate) { void NativeImage::SetTemplateImage(bool setAsTemplate) {
[image_.AsNSImage() setTemplate:setAsTemplate]; [image_.AsNSImage() setTemplate:setAsTemplate];
} }

Просмотреть файл

@ -136,4 +136,4 @@ Returns the size of the image.
* `option` Boolean * `option` Boolean
To toggle a `NativeImage` as Template image on OSX Marks the image as template image.