Remove hasRepresentation and just use 1x png result
This commit is contained in:
parent
c11cdf321b
commit
e4ead6d018
3 changed files with 5 additions and 19 deletions
|
@ -231,8 +231,8 @@ HICON NativeImage::GetHICON(int size) {
|
|||
#endif
|
||||
|
||||
v8::Local<v8::Value> NativeImage::ToPNG(v8::Isolate* isolate) {
|
||||
if (HasRepresentation(1.0)) {
|
||||
scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
|
||||
scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
|
||||
if (IsEmpty() || png->size() > 0) {
|
||||
const char* data = reinterpret_cast<const char*>(png->front());
|
||||
const size_t length = static_cast<size_t>(png->size());
|
||||
return node::Buffer::Copy(isolate, data, length).ToLocalChecked();
|
||||
|
@ -264,12 +264,11 @@ v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
|
|||
}
|
||||
|
||||
std::string NativeImage::ToDataURL() {
|
||||
if (HasRepresentation(1.0)) {
|
||||
scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
|
||||
scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
|
||||
if (IsEmpty() || png->size() > 0)
|
||||
return webui::GetPngDataUrl(png->front(), png->size());
|
||||
} else {
|
||||
else
|
||||
return webui::GetBitmapDataUrl(image_.AsBitmap());
|
||||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NativeImage::GetBitmap(v8::Isolate* isolate) {
|
||||
|
@ -304,10 +303,6 @@ bool NativeImage::IsEmpty() {
|
|||
return image_.IsEmpty();
|
||||
}
|
||||
|
||||
bool NativeImage::HasRepresentation(float scale_factor) {
|
||||
return image_.AsImageSkia().HasRepresentation(scale_factor);
|
||||
}
|
||||
|
||||
gfx::Size NativeImage::GetSize() {
|
||||
return image_.Size();
|
||||
}
|
||||
|
@ -479,7 +474,6 @@ void NativeImage::BuildPrototype(
|
|||
.SetMethod("resize", &NativeImage::Resize)
|
||||
.SetMethod("crop", &NativeImage::Crop)
|
||||
.SetMethod("getAspectRatio", &NativeImage::GetAspectRatio)
|
||||
.SetMethod("hasRepresentation", &NativeImage::HasRepresentation)
|
||||
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
|
||||
.SetMethod("toPng", &NativeImage::ToPNG)
|
||||
.SetMethod("toJpeg", &NativeImage::ToJPEG);
|
||||
|
|
|
@ -83,7 +83,6 @@ class NativeImage : public mate::Wrappable<NativeImage> {
|
|||
const gfx::Rect& rect);
|
||||
std::string ToDataURL();
|
||||
bool IsEmpty();
|
||||
bool HasRepresentation(float scale_factor);
|
||||
gfx::Size GetSize();
|
||||
float GetAspectRatio();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue