зеркало из https://github.com/electron/electron.git
refactor: avoid minor code repetition in native_image.cc (#43703)
chore: delegate handle creation in NativeImage::Resize() chore: delegate handle creation in NativeImage::Crop() chore: delegate handle creation in NativeImage::CreateEmpty() Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
Родитель
763d3983a1
Коммит
6c670c3f1f
|
@ -374,18 +374,15 @@ gin::Handle<NativeImage> NativeImage::Resize(gin::Arguments* args,
|
|||
else if (quality && *quality == "better")
|
||||
method = skia::ImageOperations::ResizeMethod::RESIZE_BETTER;
|
||||
|
||||
gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage(
|
||||
image_.AsImageSkia(), method, size);
|
||||
return gin::CreateHandle(
|
||||
args->isolate(), new NativeImage(args->isolate(), gfx::Image(resized)));
|
||||
return Create(args->isolate(),
|
||||
gfx::Image{gfx::ImageSkiaOperations::CreateResizedImage(
|
||||
image_.AsImageSkia(), method, size)});
|
||||
}
|
||||
|
||||
gin::Handle<NativeImage> NativeImage::Crop(v8::Isolate* isolate,
|
||||
const gfx::Rect& rect) {
|
||||
gfx::ImageSkia cropped =
|
||||
gfx::ImageSkiaOperations::ExtractSubset(image_.AsImageSkia(), rect);
|
||||
return gin::CreateHandle(isolate,
|
||||
new NativeImage(isolate, gfx::Image(cropped)));
|
||||
return Create(isolate, gfx::Image{gfx::ImageSkiaOperations::ExtractSubset(
|
||||
image_.AsImageSkia(), rect)});
|
||||
}
|
||||
|
||||
void NativeImage::AddRepresentation(const gin_helper::Dictionary& options) {
|
||||
|
@ -437,7 +434,7 @@ bool NativeImage::IsTemplateImage() {
|
|||
|
||||
// static
|
||||
gin::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) {
|
||||
return gin::CreateHandle(isolate, new NativeImage(isolate, gfx::Image()));
|
||||
return Create(isolate, gfx::Image{});
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
Загрузка…
Ссылка в новой задаче