Commit bef18d10 authored by fmalita's avatar fmalita Committed by Commit bot

Use a raster SkImage in DragImageBuilder

DragImageBuilder is currently instantiating a picture-backed SkImage.
But there is no advantage to that, because DragImage::create() is
immediately rasterizing it (via SkImage::asLegacyBitmap).

Since we're trying to reduce the use of picture-backed images in Blink,
refactor to rasterize upfront.

R=reed@google.com
BUG=skia:6100

Review-Url: https://codereview.chromium.org/2619573002
Cr-Commit-Position: refs/heads/master@{#442039}
parent 4aa74f38
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment