don't store isolate_ in NativeImage and tune size hints
This commit is contained in:
parent
576b702e8b
commit
5c690ea46e
2 changed files with 13 additions and 13 deletions
|
@ -200,30 +200,34 @@ void Noop(char*, void*) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
|
NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
|
||||||
: image_(image), isolate_(isolate) {
|
: image_(image) {
|
||||||
Init(isolate_);
|
Init(isolate);
|
||||||
isolate_->AdjustAmountOfExternalAllocatedMemory(
|
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
|
||||||
image_.Width() * image_.Height() * 4);
|
isolate->AdjustAmountOfExternalAllocatedMemory(
|
||||||
|
image_.ToImageSkia()->bitmap()->getSize());
|
||||||
|
}
|
||||||
MarkHighMemoryUsage();
|
MarkHighMemoryUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
NativeImage::NativeImage(v8::Isolate* isolate, const base::FilePath& hicon_path)
|
NativeImage::NativeImage(v8::Isolate* isolate, const base::FilePath& hicon_path)
|
||||||
: hicon_path_(hicon_path), isolate_(isolate) {
|
: hicon_path_(hicon_path) {
|
||||||
// Use the 256x256 icon as fallback icon.
|
// Use the 256x256 icon as fallback icon.
|
||||||
gfx::ImageSkia image_skia;
|
gfx::ImageSkia image_skia;
|
||||||
ReadImageSkiaFromICO(&image_skia, GetHICON(256));
|
ReadImageSkiaFromICO(&image_skia, GetHICON(256));
|
||||||
image_ = gfx::Image(image_skia);
|
image_ = gfx::Image(image_skia);
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
isolate_->AdjustAmountOfExternalAllocatedMemory(
|
isolate->AdjustAmountOfExternalAllocatedMemory(
|
||||||
image_.Width() * image_.Height() * 4);
|
image_.ToImageSkia()->bitmap()->getSize());
|
||||||
MarkHighMemoryUsage();
|
MarkHighMemoryUsage();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NativeImage::~NativeImage() {
|
NativeImage::~NativeImage() {
|
||||||
isolate_->AdjustAmountOfExternalAllocatedMemory(
|
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
|
||||||
- image_.Width() * image_.Height() * 4);
|
isolate()->AdjustAmountOfExternalAllocatedMemory(
|
||||||
|
- static_cast<int64_t>(image_.ToImageSkia()->bitmap()->getSize()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
|
@ -362,9 +366,6 @@ mate::Handle<NativeImage> NativeImage::Resize(
|
||||||
bool height_set = options.GetInteger("height", &height);
|
bool height_set = options.GetInteger("height", &height);
|
||||||
size.SetSize(width, height);
|
size.SetSize(width, height);
|
||||||
|
|
||||||
isolate_->AdjustAmountOfExternalAllocatedMemory(
|
|
||||||
(width_set * height_set - width * height) * 4);
|
|
||||||
|
|
||||||
if (width_set && !height_set) {
|
if (width_set && !height_set) {
|
||||||
// Scale height to preserve original aspect ratio
|
// Scale height to preserve original aspect ratio
|
||||||
size.set_height(width);
|
size.set_height(width);
|
||||||
|
|
|
@ -99,7 +99,6 @@ class NativeImage : public mate::Wrappable<NativeImage> {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gfx::Image image_;
|
gfx::Image image_;
|
||||||
v8::Isolate* isolate_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(NativeImage);
|
DISALLOW_COPY_AND_ASSIGN(NativeImage);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue