Commit d4ecf8ef authored by Adrienne Walker's avatar Adrienne Walker Committed by Commit Bot

cc: Hoist RasterSource's discard logic up a level

In order to more easily refactor RasterSource's preamble generation
(see https://chromium-review.googlesource.com/c/592237/) this moves
out code that isn't supported by PaintCanvas up to where there's
an SkCanvas.

The SkCanvas::discard logic only applies to gpu raster and so is
only replicated in the gpu raster buffer provider and not elsewhere.

Bug: 671433
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I0e006b78bb619b56e5db0a1d30c74e8de63547e1
Reviewed-on: https://chromium-review.googlesource.com/594661
Commit-Queue: enne <enne@chromium.org>
Reviewed-by: default avatarVladimir Levin <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491202}
parent b6d659cd
......@@ -76,9 +76,15 @@ static void RasterizeSource(
100.0f * fraction_saved);
}
SkCanvas* canvas = sk_surface->getCanvas();
// As an optimization, inform Skia to discard when not doing partial raster.
if (raster_full_rect == playback_rect)
canvas->discard();
raster_source->PlaybackToCanvas(
sk_surface->getCanvas(), resource_lock->color_space_for_raster(),
raster_full_rect, playback_rect, transform, playback_settings);
canvas, resource_lock->color_space_for_raster(), raster_full_rect,
playback_rect, transform, playback_settings);
}
} // namespace
......
......@@ -76,28 +76,9 @@ void RasterSource::PlaybackToCanvas(SkCanvas* input_canvas,
RasterCommon(raster_canvas, settings.image_provider);
}
namespace {
bool CanvasIsUnclipped(const SkCanvas* canvas) {
if (!canvas->isClipRect())
return false;
SkIRect bounds;
if (!canvas->getDeviceClipBounds(&bounds))
return false;
SkISize size = canvas->getBaseLayerSize();
return bounds.contains(0, 0, size.width(), size.height());
}
} // namespace
void RasterSource::PrepareForPlaybackToCanvas(SkCanvas* canvas) const {
// TODO(hendrikw): See if we can split this up into separate functions.
if (CanvasIsUnclipped(canvas))
canvas->discard();
// If this raster source has opaque contents, it is guaranteeing that it will
// draw an opaque rect the size of the layer. If it is not, then we must
// clear this canvas ourselves.
......
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