Commit 4cfe6ddf authored by Fernando Serboncini's avatar Fernando Serboncini Committed by Commit Bot

Only do PDF printing on cleared Canvases

Otherwise we may lose back information

Bug: 1011309
Change-Id: Idabededd27383bca54db237a23fbd245b8c83eae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845231
Commit-Queue: Fernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarJuanmi Huertas <juanmihd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703392}
parent ad42aabb
...@@ -583,6 +583,8 @@ void HTMLCanvasElement::Reset() { ...@@ -583,6 +583,8 @@ void HTMLCanvasElement::Reset() {
if (had_resource_provider && old_size == new_size && Is2d()) { if (had_resource_provider && old_size == new_size && Is2d()) {
if (!canvas_is_clear_) { if (!canvas_is_clear_) {
canvas_is_clear_ = true; canvas_is_clear_ = true;
if (canvas2d_bridge_)
canvas2d_bridge_->ClearFrame();
context_->ClearRect(0, 0, width(), height()); context_->ClearRect(0, 0, width(), height());
} }
return; return;
......
...@@ -575,9 +575,10 @@ void Canvas2DLayerBridge::FlushRecording() { ...@@ -575,9 +575,10 @@ void Canvas2DLayerBridge::FlushRecording() {
cc::PaintCanvas* canvas = ResourceProvider()->Canvas(); cc::PaintCanvas* canvas = ResourceProvider()->Canvas();
last_recording_ = recorder_->finishRecordingAsPicture(); last_recording_ = recorder_->finishRecordingAsPicture();
canvas->drawPicture(last_recording_); canvas->drawPicture(last_recording_);
if (!resource_host_ || !resource_host_->IsPrinting() || if (!clear_frame_ || !resource_host_ || !resource_host_->IsPrinting() ||
!is_deferral_enabled_) { !is_deferral_enabled_) {
last_recording_ = nullptr; last_recording_ = nullptr;
clear_frame_ = false;
} }
ResourceProvider()->FlushSkia(); ResourceProvider()->FlushSkia();
} }
......
...@@ -172,6 +172,10 @@ class PLATFORM_EXPORT Canvas2DLayerBridge : public cc::TextureLayerClient { ...@@ -172,6 +172,10 @@ class PLATFORM_EXPORT Canvas2DLayerBridge : public cc::TextureLayerClient {
sk_sp<cc::PaintRecord> getLastRecord() { return last_recording_; } sk_sp<cc::PaintRecord> getLastRecord() { return last_recording_; }
// This is called when the Canvas element has cleared the frame, so the 2D
// bridge knows that there's no previous content on the resource.
void ClearFrame() { clear_frame_ = true; }
private: private:
friend class Canvas2DLayerBridgeTest; friend class Canvas2DLayerBridgeTest;
friend class CanvasRenderingContext2DTest; friend class CanvasRenderingContext2DTest;
...@@ -199,6 +203,7 @@ class PLATFORM_EXPORT Canvas2DLayerBridge : public cc::TextureLayerClient { ...@@ -199,6 +203,7 @@ class PLATFORM_EXPORT Canvas2DLayerBridge : public cc::TextureLayerClient {
bool hibernation_scheduled_ = false; bool hibernation_scheduled_ = false;
bool dont_use_idle_scheduling_for_testing_ = false; bool dont_use_idle_scheduling_for_testing_ = false;
bool context_lost_ = false; bool context_lost_ = false;
bool clear_frame_ = true;
const AccelerationMode acceleration_mode_; const AccelerationMode acceleration_mode_;
const CanvasColorParams color_params_; const CanvasColorParams color_params_;
......
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