Remove type parameter
This commit is contained in:
parent
63d9174822
commit
e3e6cd6fd8
1 changed files with 4 additions and 46 deletions
|
@ -58,20 +58,6 @@ ScaleFactorPair kScaleFactorPairs[] = {
|
||||||
{ "@2.5x" , 2.5f },
|
{ "@2.5x" , 2.5f },
|
||||||
};
|
};
|
||||||
|
|
||||||
enum NativeRepresentation {
|
|
||||||
INVALID = 0,
|
|
||||||
AS_NSIMAGE,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct NativeRepresentationPair {
|
|
||||||
const char* name;
|
|
||||||
NativeRepresentation rep;
|
|
||||||
};
|
|
||||||
|
|
||||||
NativeRepresentationPair kNativeRepresentations[] {
|
|
||||||
{ "nsimage", NativeRepresentation::AS_NSIMAGE },
|
|
||||||
};
|
|
||||||
|
|
||||||
float GetScaleFactorFromPath(const base::FilePath& path) {
|
float GetScaleFactorFromPath(const base::FilePath& path) {
|
||||||
std::string filename(path.BaseName().RemoveExtension().AsUTF8Unsafe());
|
std::string filename(path.BaseName().RemoveExtension().AsUTF8Unsafe());
|
||||||
|
|
||||||
|
@ -240,40 +226,12 @@ std::string NativeImage::ToDataURL() {
|
||||||
v8::Local<v8::Value> NativeImage::AsNativeRepresentation(
|
v8::Local<v8::Value> NativeImage::AsNativeRepresentation(
|
||||||
v8::Isolate* isolate,
|
v8::Isolate* isolate,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
NativeRepresentation desiredRep = NativeRepresentation::INVALID;
|
|
||||||
void* ptr = nullptr;
|
|
||||||
std::string type;
|
|
||||||
|
|
||||||
if (!args->GetNext(&type)) {
|
|
||||||
args->ThrowError();
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const NativeRepresentationPair& item : kNativeRepresentations) {
|
|
||||||
if (type.compare(item.name) == 0) {
|
|
||||||
desiredRep = item.rep;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (desiredRep == NativeRepresentation::INVALID) {
|
|
||||||
args->ThrowError();
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (desiredRep) {
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
case NativeRepresentation::AS_NSIMAGE:
|
void* ptr = reinterpret_cast<void*>(image_.AsNSImage());
|
||||||
ptr = reinterpret_cast<void*>(image_.AsNSImage());
|
#else
|
||||||
break;
|
args.ThrowError();
|
||||||
|
return v8::Undefined(isolate);
|
||||||
#endif
|
#endif
|
||||||
case NativeRepresentation::INVALID:
|
|
||||||
default:
|
|
||||||
args->ThrowError();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
|
|
||||||
return node::Buffer::Copy(
|
return node::Buffer::Copy(
|
||||||
isolate,
|
isolate,
|
||||||
|
|
Loading…
Add table
Reference in a new issue