Commit afcb4156 authored by Khushal's avatar Khushal Committed by Commit Bot

Revert "canvas2d: Fix canvas resource thrashing with an intermediate canvas."

This reverts commit 16fc868a.

Reason for revert: crbug.com/1051940

Original change's description:
> canvas2d: Fix canvas resource thrashing with an intermediate canvas.
> 
> If a canvas is used as an intermediate for drawing to the displayed
> canvas multiple times in a frame, then a ref to its backing texture is
> retained in the displayed canvas' paint recording. This triggers a
> copy-on-write and a buffer allocation each time this intermediate canvas
> is updated for a new draw.
> 
> The above allocation can be avoided by ordering the GPU work
> to write to and read from the intermediate canvas' buffer correctly and
> reuse the buffer for each update to this intermediate canvas.
> CanvasResourceProviderSharedImage did this optimization earlier by
> flushing skia prior to triggering a copy-on-write. But after disabling
> deferral for texture backed images, the draw for that texture is never
> flushed to skia until the displayed canvas' paint recording is flushed.
> 
> This change brings back the optimization by flushing a canvas' recording
> each time a texture backed image is drawn to it.
> 
> R=​fserb@chromium.org, bsalomon@google.com
> 
> Bug: 1030108
> Change-Id: Id46fa8399f64a4c724c9f51e5cb4927b7e97d747
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040028
> Reviewed-by: Fernando Serboncini <fserb@chromium.org>
> Reviewed-by: Aaron Krajeski <aaronhk@chromium.org>
> Commit-Queue: Fernando Serboncini <fserb@chromium.org>
> Auto-Submit: Khushal <khushalsagar@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#740005}

TBR=bsalomon@google.com,fserb@chromium.org,khushalsagar@chromium.org,aaronhk@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1030108
Change-Id: I7931a623c4c16dada7dc56f1c78f88aee8da4d96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2054271Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarAaron Krajeski <aaronhk@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741151}
parent ad417088
......@@ -21,7 +21,7 @@ void MemoryManagedPaintCanvas::drawImage(const cc::PaintImage& image,
const cc::PaintFlags* flags) {
DCHECK(!image.IsPaintWorklet());
RecordPaintCanvas::drawImage(image, left, top, flags);
RequestFlushAfterDrawIfNeeded(image);
UpdateMemoryUsage(image);
}
void MemoryManagedPaintCanvas::drawImageRect(
......@@ -31,16 +31,10 @@ void MemoryManagedPaintCanvas::drawImageRect(
const cc::PaintFlags* flags,
PaintCanvas::SrcRectConstraint constraint) {
RecordPaintCanvas::drawImageRect(image, src, dst, flags, constraint);
RequestFlushAfterDrawIfNeeded(image);
UpdateMemoryUsage(image);
}
void MemoryManagedPaintCanvas::RequestFlushAfterDrawIfNeeded(
const cc::PaintImage& image) {
if (image.IsTextureBacked()) {
set_needs_flush_callback_.Run();
return;
}
void MemoryManagedPaintCanvas::UpdateMemoryUsage(const cc::PaintImage& image) {
if (cached_image_ids_.contains(image.content_id()))
return;
......
......@@ -36,7 +36,7 @@ class PLATFORM_EXPORT MemoryManagedPaintCanvas final
SrcRectConstraint constraint) override;
private:
void RequestFlushAfterDrawIfNeeded(const cc::PaintImage& image);
void UpdateMemoryUsage(const cc::PaintImage& image);
base::flat_set<int> cached_image_ids_;
uint64_t total_stored_image_memory_ = 0;
......
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