Commit 7243aeea authored by Justin Novosad's avatar Justin Novosad Committed by Commit Bot

Fix performance regression in putImageData

This CL returns to the simple direct blit code path we had before.
In CL https://chromium-review.googlesource.com/c/chromium/src/+/758562
the implementation of Canvas2DLayerBridge::WritePixels was changed to
go through the PaintCanvas interface, which required making an extra
copy and force the pixels through an alternate color correction code
path that handles alpha blending correctly.  It turns out that this
detour is unnecessary since alpha blending does not come into play in
putImageData since it is a straight blit.

BUG=802081

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I3af99cc56745f6db52921282d905f73981675926
Reviewed-on: https://chromium-review.googlesource.com/883770Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Commit-Queue: Justin Novosad <junov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531723}
parent 0a5dd14a
...@@ -486,37 +486,9 @@ bool Canvas2DLayerBridge::WritePixels(const SkImageInfo& orig_info, ...@@ -486,37 +486,9 @@ bool Canvas2DLayerBridge::WritePixels(const SkImageInfo& orig_info,
FlushRecording(); FlushRecording();
} }
SkImageInfo tmp_info = SkImageInfo::Make( GetOrCreateResourceProvider()->WritePixels(orig_info, pixels, row_bytes, x,
orig_info.width(), orig_info.height(), ColorParams().GetSkColorType(), y);
kPremul_SkAlphaType, ColorParams().GetSkColorSpaceForSkSurfaces());
sk_sp<SkSurface> tmp_surface = SkSurface::MakeRaster(tmp_info, nullptr);
tmp_surface->getCanvas()->writePixels(orig_info, pixels, row_bytes, 0, 0);
PaintImageBuilder builder = PaintImageBuilder::WithDefault();
builder.set_image(tmp_surface->makeImageSnapshot());
builder.set_id(PaintImage::GetNextId());
PaintCanvas* canvas = GetOrCreateResourceProvider()->Canvas();
if (!canvas)
return false;
// Ignore clip and matrix
canvas->restoreToCount(0);
PaintFlags copy_paint;
copy_paint.setBlendMode(SkBlendMode::kSrc);
canvas->drawImage(builder.TakePaintImage(), x, y, &copy_paint);
canvas->save(); // intial save
if (resource_host_ && !is_deferral_enabled_) {
resource_host_->RestoreCanvasMatrixClipStack(canvas);
}
// We did not make a copy of the pixel data, so it needs to be consumed
// immediately
DidDraw(FloatRect(x, y, orig_info.width(), orig_info.height())); DidDraw(FloatRect(x, y, orig_info.width(), orig_info.height()));
GetOrCreateResourceProvider()->FlushSkia();
return true; return true;
} }
......
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