Commit 47a0f04e authored by Sunny Sachanandani's avatar Sunny Sachanandani Committed by Commit Bot

webgl: Swap chain FinalizeFrame() fixes

1) Present swap chain before exporting back buffer in FinalizeFrame().
2) Check that drawing buffer is actually using a swap chain instead of
   just checking the runtime feature flag.

Bug: 939657
Change-Id: I235fe95c257c1e9971667e0e41c8d27bc27ad133
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1745404
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: default avatarKai Ninomiya <kainino@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686601}
parent 2f26a235
......@@ -124,11 +124,13 @@ void CanvasRenderingContext::DidProcessTask(
const base::PendingTask& /* pending_task */) {
StopListeningForDidProcessTask();
// Call FinalizeFrame() on self first before informing host so that we can
// present swap chain before exporting it.
FinalizeFrame();
// The end of a script task that drew content to the canvas is the point
// at which the current frame may be considered complete.
if (Host())
Host()->FinalizeFrame();
FinalizeFrame();
}
CanvasRenderingContext::ContextType CanvasRenderingContext::ContextTypeFromId(
......
......@@ -451,7 +451,7 @@ void HTMLCanvasElement::FinalizeFrame() {
if (GetOrCreateCanvasResourceProvider(kPreferAcceleration)) {
const bool webgl_overlay_enabled =
RuntimeEnabledFeatures::WebGLImageChromiumEnabled() ||
RuntimeEnabledFeatures::WebGLSwapChainEnabled();
context_->UsingSwapChain();
// TryEnableSingleBuffering() the first time we FinalizeFrame().
if (!ResourceProvider()->IsSingleBuffered()) {
ResourceProvider()->TryEnableSingleBuffering();
......
......@@ -1437,6 +1437,9 @@ void DrawingBuffer::PresentSwapChain() {
DCHECK(UsingSwapChain());
DCHECK_EQ(texture_target_, static_cast<unsigned>(GL_TEXTURE_2D));
if (!contents_changed_)
return;
ScopedStateRestorer scoped_state_restorer(this);
ResolveIfNeeded();
......@@ -1472,6 +1475,7 @@ void DrawingBuffer::PresentSwapChain() {
GL_FALSE, GL_FALSE);
}
ResetBuffersToAutoClear();
contents_changed_ = false;
}
scoped_refptr<DrawingBuffer::ColorBuffer> DrawingBuffer::CreateColorBuffer(
......
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