Synchronize commits at end of JS task

This CL defers the submission of frames to the end of a JS task, so that the
commits() for multiple OffscreenCanvases in the same execution context are
happening at the same time.

When a commit() comes in, there are three possible scenarios:
1. This is first commit since last resolved promise. In this case, we store the
   frame at m_currentFrame and register the context to task observer.
2. This is not the first commit for the same canvas in the same JS task. In
   this case, we overwrite the m_currentFrame but we do not duplicate
   registration to task observer.
3. This is the overdraw commit (the m_currentFrame has been dispatched but we
   are still waiting for the next OnBeginFrame to resolve the promise). In this
   case, we set the m_overdraw commit.

When JS task finishes, finalizeFrame() will get fired and submit the
current frame.

When OnBeginFrame is fired, we'll resolve the promise if there is no current
frame and no overdraw frame. If there is an overdraw frame, we doCommit for
the overdraw frame and wait for next animation frame to resolve the promise.

I've also modified the GPU pixel tests to test for all these situations.

BUG=697582
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2778483002
Cr-Commit-Position: refs/heads/master@{#459828}
11 files changed