.deepCopyTo() => sk_tool_utils::copy_to()
This commit is contained in:
parent
ad2baccefa
commit
8b4a89c445
2 changed files with 4 additions and 36 deletions
|
@ -10,45 +10,11 @@
|
||||||
#include "third_party/skia/include/core/SkBitmap.h"
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
#include "third_party/skia/include/core/SkImageInfo.h"
|
#include "third_party/skia/include/core/SkImageInfo.h"
|
||||||
#include "third_party/skia/include/core/SkPixmap.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 "ui/base/clipboard/scoped_clipboard_writer.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.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 atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
@ -207,7 +173,7 @@ void Clipboard::WriteImage(const gfx::Image& image, mate::Arguments* args) {
|
||||||
SkBitmap orig = image.AsBitmap();
|
SkBitmap orig = image.AsBitmap();
|
||||||
SkBitmap bmp;
|
SkBitmap bmp;
|
||||||
|
|
||||||
if (copy_to(&bmp, orig.colorType(), orig)) {
|
if (sk_tool_utils::copy_to(&bmp, orig.colorType(), &orig)) {
|
||||||
writer.WriteImage(bmp);
|
writer.WriteImage(bmp);
|
||||||
} else {
|
} else {
|
||||||
writer.WriteImage(orig);
|
writer.WriteImage(orig);
|
||||||
|
|
|
@ -146,6 +146,8 @@
|
||||||
'<(libchromiumcontent_src_dir)',
|
'<(libchromiumcontent_src_dir)',
|
||||||
'<(libchromiumcontent_src_dir)/third_party/icu/source/common',
|
'<(libchromiumcontent_src_dir)/third_party/icu/source/common',
|
||||||
'<(libchromiumcontent_src_dir)/third_party/icu/source/i18n',
|
'<(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',
|
||||||
'<(libchromiumcontent_src_dir)/v8/include',
|
'<(libchromiumcontent_src_dir)/v8/include',
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue