Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 2619573002: Use a raster SkImage in DragImageBuilder (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/LocalFrame.cpp
diff --git a/third_party/WebKit/Source/core/frame/LocalFrame.cpp b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
index 7f727395b15fa60c820522bad6242133aad68dfc..9e40e7b1b43733ee1bfa1e60cdb17b6cffa34d49 100644
--- a/third_party/WebKit/Source/core/frame/LocalFrame.cpp
+++ b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
@@ -94,6 +94,7 @@
#include "public/platform/WebScreenInfo.h"
#include "public/platform/WebViewScheduler.h"
#include "third_party/skia/include/core/SkImage.h"
+#include "third_party/skia/include/core/SkSurface.h"
#include "wtf/PtrUtil.h"
#include "wtf/StdLibExtras.h"
#include <memory>
@@ -143,10 +144,15 @@ class DragImageBuilder {
// TODO(fmalita): endRecording() should return a non-const SKP.
sk_sp<SkPicture> recording(
const_cast<SkPicture*>(m_pictureBuilder->endRecording().release()));
- sk_sp<SkImage> skImage = SkImage::MakeFromPicture(
- std::move(recording),
- SkISize::Make(m_bounds.width(), m_bounds.height()), nullptr, nullptr);
- RefPtr<Image> image = StaticBitmapImage::create(std::move(skImage));
+
+ // Rasterize upfront, since DragImage::create() is going to do it anyway
+ // (SkImage::asLegacyBitmap).
+ sk_sp<SkSurface> surface =
+ SkSurface::MakeRasterN32Premul(m_bounds.width(), m_bounds.height());
+ surface->getCanvas()->drawPicture(recording);
+ RefPtr<Image> image =
+ StaticBitmapImage::create(surface->makeImageSnapshot());
+
float screenDeviceScaleFactor =
m_localFrame->page()->chromeClient().screenInfo().deviceScaleFactor;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698