mirror of
https://github.com/electron/electron.git
synced 2026-02-04 04:05:36 -05:00
.deepCopyTo() => sk_tool_utils::copy_to()
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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',
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user