Convert to mate::Handle<NativeImage> instead of gfx::Image
This commit is contained in:
parent
7c34d8333c
commit
adfd99f5f0
6 changed files with 80 additions and 31 deletions
|
@ -341,6 +341,35 @@ void NativeImage::BuildPrototype(
|
|||
|
||||
} // namespace atom
|
||||
|
||||
namespace mate {
|
||||
|
||||
v8::Local<v8::Value> Converter<mate::Handle<atom::api::NativeImage>>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const mate::Handle<atom::api::NativeImage>& val) {
|
||||
return val.ToV8();
|
||||
}
|
||||
|
||||
bool Converter<mate::Handle<atom::api::NativeImage>>::FromV8(
|
||||
v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||
mate::Handle<atom::api::NativeImage>* out) {
|
||||
// Try converting from file path.
|
||||
base::FilePath path;
|
||||
if (ConvertFromV8(isolate, val, &path)) {
|
||||
*out = atom::api::NativeImage::CreateFromPath(isolate, path);
|
||||
// Should throw when failed to initialize from path.
|
||||
return !(*out)->image().IsEmpty();
|
||||
}
|
||||
|
||||
WrappableBase* wrapper = static_cast<WrappableBase*>(internal::FromV8Impl(
|
||||
isolate, val));
|
||||
if (!wrapper)
|
||||
return false;
|
||||
|
||||
*out = CreateHandle(isolate, static_cast<atom::api::NativeImage*>(wrapper));
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue