Commit 97a781d9 authored by kainino's avatar kainino Committed by Commit bot

Migrate WebGL timers to TaskRunnerTimer

This migrates the WebGL task timers dispatchContextLostEventTimer and restoreTimer to TaskRunnerTimer and correctly puts them in the WebGL task source.

BUG=624694
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2668573002
Cr-Commit-Position: refs/heads/master@{#447951}
parent 928bd40b
......@@ -32,6 +32,7 @@ RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, LocalFrame* frame) {
case TaskType::Presentation:
case TaskType::Sensor:
case TaskType::PerformanceTimeline:
case TaskType::WebGL:
case TaskType::Timer:
case TaskType::UnspecedTimer:
case TaskType::MiscPlatformAPI:
......
......@@ -98,6 +98,10 @@ enum class TaskType : unsigned {
// https://w3c.github.io/performance-timeline/#performance-timeline
PerformanceTimeline,
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15
// This task source is used for all tasks in the WebGL spec.
WebGL,
// Use MiscPlatformAPI for a task that is defined in the spec but is not yet
// associated with any specific task runner in the spec. MiscPlatformAPI is
// not encouraged for stable and matured APIs. The spec should define the task
......
......@@ -34,6 +34,7 @@
#include "core/dom/DOMArrayBuffer.h"
#include "core/dom/DOMTypedArray.h"
#include "core/dom/FlexibleArrayBufferView.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/frame/ImageBitmap.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
......@@ -1039,26 +1040,32 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(
std::unique_ptr<WebGraphicsContext3DProvider> contextProvider,
const CanvasContextCreationAttributes& requestedAttributes,
unsigned version)
: WebGLRenderingContextBase(nullptr,
passedOffscreenCanvas,
std::move(contextProvider),
requestedAttributes,
version) {}
: WebGLRenderingContextBase(
nullptr,
passedOffscreenCanvas,
TaskRunnerHelper::get(TaskType::WebGL,
passedOffscreenCanvas->getExecutionContext()),
std::move(contextProvider),
requestedAttributes,
version) {}
WebGLRenderingContextBase::WebGLRenderingContextBase(
HTMLCanvasElement* passedCanvas,
std::unique_ptr<WebGraphicsContext3DProvider> contextProvider,
const CanvasContextCreationAttributes& requestedAttributes,
unsigned version)
: WebGLRenderingContextBase(passedCanvas,
nullptr,
std::move(contextProvider),
requestedAttributes,
version) {}
: WebGLRenderingContextBase(
passedCanvas,
nullptr,
TaskRunnerHelper::get(TaskType::WebGL, &passedCanvas->document()),
std::move(contextProvider),
requestedAttributes,
version) {}
WebGLRenderingContextBase::WebGLRenderingContextBase(
HTMLCanvasElement* passedCanvas,
OffscreenCanvas* passedOffscreenCanvas,
RefPtr<WebTaskRunner> taskRunner,
std::unique_ptr<WebGraphicsContext3DProvider> contextProvider,
const CanvasContextCreationAttributes& requestedAttributes,
unsigned version)
......@@ -1070,10 +1077,13 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(
m_contextLostMode(NotLostContext),
m_autoRecoveryMethod(Manual),
m_dispatchContextLostEventTimer(
taskRunner,
this,
&WebGLRenderingContextBase::dispatchContextLostEvent),
m_restoreAllowed(false),
m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext),
m_restoreTimer(taskRunner,
this,
&WebGLRenderingContextBase::maybeRestoreContext),
m_boundArrayBuffer(this, nullptr),
m_boundVertexArrayObject(this, nullptr),
m_currentProgram(this, nullptr),
......
......@@ -691,9 +691,9 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
// real ones, it's likely that there's no JavaScript on the stack, but that
// might be dependent on how exactly the platform discovers that the context
// was lost. For better portability we always defer the dispatch of the event.
Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer;
TaskRunnerTimer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer;
bool m_restoreAllowed;
Timer<WebGLRenderingContextBase> m_restoreTimer;
TaskRunnerTimer<WebGLRenderingContextBase> m_restoreTimer;
bool m_markedCanvasDirty;
......@@ -1636,6 +1636,7 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
private:
WebGLRenderingContextBase(HTMLCanvasElement*,
OffscreenCanvas*,
RefPtr<WebTaskRunner>,
std::unique_ptr<WebGraphicsContext3DProvider>,
const CanvasContextCreationAttributes&,
unsigned);
......
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