Commit 87d63940 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Ensure compositing update when a canvas is connected to an offscreen canvas

Bug: 1005868
Change-Id: Ice99c87d4eff6306baa14fbfe91e859295169786
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1819563
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699143}
parent 219b97ee
......@@ -1222,6 +1222,7 @@ jumbo_source_set("unit_tests") {
"html/anchor_element_metrics_test.cc",
"html/canvas/canvas_async_blob_creator_test.cc",
"html/canvas/canvas_font_cache_test.cc",
"html/canvas/html_canvas_element_test.cc",
"html/canvas/image_data_test.cc",
"html/custom/custom_element_definition_test.cc",
"html/custom/custom_element_descriptor_test.cc",
......
......@@ -1393,6 +1393,8 @@ void HTMLCanvasElement::CreateLayer() {
base::DoNothing());
// Creates a placeholder layer first before Surface is created.
surface_layer_bridge_->CreateSolidColorLayer();
// This may cause the canvas to be composited.
SetNeedsCompositingUpdate();
}
}
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
namespace blink {
using HTMLCanvasElementTest = RenderingTest;
TEST_F(HTMLCanvasElementTest, CreateLayerUpdatesCompositing) {
// Enable script so that the canvas will create a LayoutHTMLCanvas.
GetDocument().GetSettings()->SetScriptEnabled(true);
SetBodyInnerHTML("<canvas id='canvas'></canvas>");
auto* canvas = ToHTMLCanvasElement(GetDocument().getElementById("canvas"));
auto* layer = ToLayoutBoxModelObject(canvas->GetLayoutObject())->Layer();
ASSERT_TRUE(layer);
EXPECT_EQ(CompositingReason::kNone, layer->DirectCompositingReasons());
EXPECT_FALSE(layer->NeedsCompositingInputsUpdate());
canvas->CreateLayer();
EXPECT_TRUE(layer->NeedsCompositingInputsUpdate());
UpdateAllLifecyclePhasesForTest();
ASSERT_EQ(layer, ToLayoutBoxModelObject(canvas->GetLayoutObject())->Layer());
EXPECT_EQ(CompositingReason::kCanvas, layer->DirectCompositingReasons());
}
} // namespace blink
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