Avoid using deprecated skia size methods

This commit is contained in:
Cheng Zhao 2018-03-13 15:23:19 +09:00 committed by Aleksei Kuzmin
parent 42938de973
commit 624e09533c

View file

@ -221,7 +221,7 @@ NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
Init(isolate); Init(isolate);
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) { if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
isolate->AdjustAmountOfExternalAllocatedMemory( isolate->AdjustAmountOfExternalAllocatedMemory(
image_.ToImageSkia()->bitmap()->computeSize64()); image_.ToImageSkia()->bitmap()->computeByteSize());
} }
MarkHighMemoryUsage(); MarkHighMemoryUsage();
} }
@ -236,7 +236,7 @@ NativeImage::NativeImage(v8::Isolate* isolate, const base::FilePath& hicon_path)
Init(isolate); Init(isolate);
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) { if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
isolate->AdjustAmountOfExternalAllocatedMemory( isolate->AdjustAmountOfExternalAllocatedMemory(
image_.ToImageSkia()->bitmap()->computeSize64()); image_.ToImageSkia()->bitmap()->computeByteSize());
} }
MarkHighMemoryUsage(); MarkHighMemoryUsage();
} }
@ -245,7 +245,7 @@ NativeImage::NativeImage(v8::Isolate* isolate, const base::FilePath& hicon_path)
NativeImage::~NativeImage() { NativeImage::~NativeImage() {
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) { if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
isolate()->AdjustAmountOfExternalAllocatedMemory( isolate()->AdjustAmountOfExternalAllocatedMemory(
- image_.ToImageSkia()->bitmap()->computeSize64()); -static_cast<int64_t>(image_.ToImageSkia()->bitmap()->computeByteSize()));
} }
} }
@ -302,7 +302,7 @@ v8::Local<v8::Value> NativeImage::ToBitmap(mate::Arguments* args) {
return node::Buffer::New(args->isolate(), 0).ToLocalChecked(); return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
return node::Buffer::Copy(args->isolate(), return node::Buffer::Copy(args->isolate(),
reinterpret_cast<const char*>(ref->pixels()), reinterpret_cast<const char*>(ref->pixels()),
bitmap.getSafeSize()).ToLocalChecked(); bitmap.computeByteSize()).ToLocalChecked();
} }
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) { v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
@ -340,7 +340,7 @@ v8::Local<v8::Value> NativeImage::GetBitmap(mate::Arguments* args) {
return node::Buffer::New(args->isolate(), 0).ToLocalChecked(); return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
return node::Buffer::New(args->isolate(), return node::Buffer::New(args->isolate(),
reinterpret_cast<char*>(ref->pixels()), reinterpret_cast<char*>(ref->pixels()),
bitmap.getSafeSize(), bitmap.computeByteSize(),
&Noop, &Noop,
nullptr).ToLocalChecked(); nullptr).ToLocalChecked();
} }