From 8b4a89c44551c229fe4d7dc44b3a21676c01b06c Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sat, 14 Apr 2018 12:50:55 -0400 Subject: [PATCH] .deepCopyTo() => sk_tool_utils::copy_to() --- atom/common/api/atom_api_clipboard.cc | 38 ++------------------------- common.gypi | 2 ++ 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/atom/common/api/atom_api_clipboard.cc b/atom/common/api/atom_api_clipboard.cc index 47c85650a84e..6b0c97078ce2 100644 --- a/atom/common/api/atom_api_clipboard.cc +++ b/atom/common/api/atom_api_clipboard.cc @@ -10,45 +10,11 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkPixmap.h" +#include "third_party/skia/tools/sk_tool_utils.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" #include "atom/common/node_includes.h" -namespace { - -// TODO(alexeykuzmin): It is a copy of `sk_tool_utils::copy_to()`, -// use the original function if possible, skia doesn't export it. -bool copy_to(SkBitmap* dst, SkColorType dstColorType, const SkBitmap& src) { - SkPixmap srcPM; - if (!src.peekPixels(&srcPM)) { - return false; - } - - SkBitmap tmpDst; - SkImageInfo dstInfo = srcPM.info().makeColorType(dstColorType); - if (!tmpDst.setInfo(dstInfo)) { - return false; - } - - if (!tmpDst.tryAllocPixels()) { - return false; - } - - SkPixmap dstPM; - if (!tmpDst.peekPixels(&dstPM)) { - return false; - } - - if (!srcPM.readPixels(dstPM)) { - return false; - } - - dst->swap(tmpDst); - return true; -} - -} // namespace - namespace atom { namespace api { @@ -207,7 +173,7 @@ void Clipboard::WriteImage(const gfx::Image& image, mate::Arguments* args) { SkBitmap orig = image.AsBitmap(); SkBitmap bmp; - if (copy_to(&bmp, orig.colorType(), orig)) { + if (sk_tool_utils::copy_to(&bmp, orig.colorType(), &orig)) { writer.WriteImage(bmp); } else { writer.WriteImage(orig); diff --git a/common.gypi b/common.gypi index 5c6677b333ef..d65a44308e0d 100644 --- a/common.gypi +++ b/common.gypi @@ -146,6 +146,8 @@ '<(libchromiumcontent_src_dir)', '<(libchromiumcontent_src_dir)/third_party/icu/source/common', '<(libchromiumcontent_src_dir)/third_party/icu/source/i18n', + '<(libchromiumcontent_src_dir)/third_party/skia/include/utils', + '<(libchromiumcontent_src_dir)/third_party/skia/include/private', '<(libchromiumcontent_src_dir)/v8', '<(libchromiumcontent_src_dir)/v8/include', ],