Fixes for VRDisplay
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
index b23d05a..c826420 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -51,9 +51,8 @@
       m_fullscreenCheckTimer(this, &VRDisplay::onFullscreenCheck) {}
 
 VRDisplay::~VRDisplay() {
-  gpu::gles2::GLES2Interface* sharedContext = getCompositingContext();
-  if (sharedContext && m_compositorHandle) {
-    sharedContext->DeleteVRCompositorCHROMIUM(m_compositorHandle);
+  if (m_contextGL && m_compositorHandle) {
+    m_contextGL->DeleteVRCompositorCHROMIUM(m_compositorHandle);
   }
 }
 
@@ -126,11 +125,8 @@
 void VRDisplay::resetPose() {
   controller()->resetPose(m_displayId);
 
-  if (m_compositorHandle) {
-    gpu::gles2::GLES2Interface* sharedContext = getCompositingContext();
-    if (sharedContext)
-      sharedContext->ResetVRCompositorPoseCHROMIUM(m_compositorHandle);
-  }
+  if (m_contextGL && m_compositorHandle)
+      m_contextGL->ResetVRCompositorPoseCHROMIUM(m_compositorHandle);
 }
 
 VREyeParameters* VRDisplay::getEyeParameters(const String& whichEye) {
@@ -157,22 +153,6 @@
     document->cancelAnimationFrame(id);
 }
 
-gpu::gles2::GLES2Interface* VRDisplay::getCompositingContext() {
-  if (!m_contextProvider)
-    m_contextProvider = wrapUnique(
-        Platform::current()->createSharedOffscreenGraphicsContext3DProvider());
-
-  gpu::gles2::GLES2Interface* sharedContext = nullptr;
-  if (m_contextProvider) {
-    sharedContext = m_contextProvider->contextGL();
-
-    if (!sharedContext)
-      return nullptr;
-  }
-
-  return sharedContext;
-}
-
 ScriptPromise VRDisplay::requestPresent(ScriptState* scriptState,
                                         const HeapVector<VRLayer>& layers) {
   ExecutionContext* executionContext = scriptState->getExecutionContext();
@@ -208,8 +188,6 @@
     return promise;
   }
 
-  m_context = nullptr;
-
   // A valid number of layers must be provided in order to present.
   if (layers.size() == 0 || layers.size() > m_capabilities->maxLayers()) {
     forceExitPresent();
@@ -255,8 +233,6 @@
     return promise;
   }
 
-  m_context = toWebGLRenderingContextBase(renderingContext);
-
   if (!m_capabilities->hasExternalDisplay()) {
     // TODO: Need a proper VR compositor, but for the moment on mobile
     // we'll just make the canvas fullscreen so that VrShell can pick it
@@ -303,30 +279,21 @@
 
 void VRDisplay::beginPresent(ScriptPromiseResolver* resolver) {
   if (m_capabilities->hasExternalDisplay()) {
-    gpu::gles2::GLES2Interface* sharedContext = getCompositingContext();
-    if (!sharedContext) {
+    m_compositorHandle = m_contextGL->CreateVRCompositorCHROMIUM(
+        static_cast<GLenum>(m_compositorType));
+
+    if (!m_compositorHandle) {
+      forceExitPresent();
       DOMException* exception = DOMException::create(
-          InvalidStateError, "Unable to acquire shared context");
-      if (m_isPresenting)
-        forceExitPresent();
+          InvalidStateError, "Unable to create VR compositor");
       resolver->reject(exception);
-    } else {
-      m_compositorHandle = sharedContext->CreateVRCompositorCHROMIUM(
-          static_cast<GLenum>(m_compositorType));
+      return;
+    }
 
-      if (!m_compositorHandle) {
-        forceExitPresent();
-        DOMException* exception = DOMException::create(
-            InvalidStateError, "Unable to create VR compositor");
-        resolver->reject(exception);
-        return;
-      }
-
-      if (m_compositorType ==
-          device::blink::VRDisplay::CompositorType::OCULUS) {
-        // FIXME: This is terrible. :(
-        resetPose();
-      }
+    if (m_compositorType ==
+        device::blink::VRDisplay::CompositorType::OCULUS) {
+      // FIXME: This is terrible. :(
+      resetPose();
     }
   }
 
@@ -347,18 +314,13 @@
     if (!m_capabilities->hasExternalDisplay()) {
       Fullscreen::fullyExitFullscreen(m_layer.source()->document());
       m_fullscreenCheckTimer.stop();
-    } else {
-      gpu::gles2::GLES2Interface* sharedContext = getCompositingContext();
-      if (sharedContext && m_compositorHandle) {
-        sharedContext->DeleteVRCompositorCHROMIUM(m_compositorHandle);
-        sharedContext->Finish();
-      }
+    } else if (m_contextGL && m_compositorHandle) {
+      m_contextGL->DeleteVRCompositorCHROMIUM(m_compositorHandle);
+      m_contextGL->Finish();
     }
     m_navigatorVR->fireVRDisplayPresentChange(this);
   }
 
-  m_context = nullptr;
-  m_contextProvider = nullptr;
   m_compositorHandle = 0;
   m_isPresenting = false;
   m_renderingContext = nullptr;
@@ -369,28 +331,25 @@
   if (!m_isPresenting)
     return;
 
-  if (m_compositorHandle) {
-    gpu::gles2::GLES2Interface* sharedContext = getCompositingContext();
-    if (sharedContext) {
-      if (m_layer.leftBounds().size() == 4) {
-        sharedContext->VRCompositorTextureBoundsCHROMIUM(
-            m_compositorHandle, 0,  // Left Eye
-            m_layer.leftBounds()[0], m_layer.leftBounds()[1],
-            m_layer.leftBounds()[2], m_layer.leftBounds()[3]);
-      } else {
-        sharedContext->VRCompositorTextureBoundsCHROMIUM(
-            m_compositorHandle, 0, 0.0f, 0.0f, 0.5f, 1.0f);
-      }
+  if (m_contextGL && m_compositorHandle) {
+    if (m_layer.leftBounds().size() == 4) {
+      m_contextGL->VRCompositorTextureBoundsCHROMIUM(
+          m_compositorHandle, 0,  // Left Eye
+          m_layer.leftBounds()[0], m_layer.leftBounds()[1],
+          m_layer.leftBounds()[2], m_layer.leftBounds()[3]);
+    } else {
+      m_contextGL->VRCompositorTextureBoundsCHROMIUM(
+          m_compositorHandle, 0, 0.0f, 0.0f, 0.5f, 1.0f);
+    }
 
-      if (m_layer.rightBounds().size() == 4) {
-        sharedContext->VRCompositorTextureBoundsCHROMIUM(
-            m_compositorHandle, 1,  // Right Eye
-            m_layer.rightBounds()[0], m_layer.rightBounds()[1],
-            m_layer.rightBounds()[2], m_layer.rightBounds()[3]);
-      } else {
-        sharedContext->VRCompositorTextureBoundsCHROMIUM(
-            m_compositorHandle, 1, 0.5f, 0.0f, 0.5f, 1.0f);
-      }
+    if (m_layer.rightBounds().size() == 4) {
+      m_contextGL->VRCompositorTextureBoundsCHROMIUM(
+          m_compositorHandle, 1,  // Right Eye
+          m_layer.rightBounds()[0], m_layer.rightBounds()[1],
+          m_layer.rightBounds()[2], m_layer.rightBounds()[3]);
+    } else {
+      m_contextGL->VRCompositorTextureBoundsCHROMIUM(
+          m_compositorHandle, 1, 0.5f, 0.0f, 0.5f, 1.0f);
     }
   }
 
@@ -475,10 +434,6 @@
   m_renderingContext->restoreColorMask();
   m_renderingContext->restoreClearColor();
 #else
-  gpu::gles2::GLES2Interface* sharedContext = getCompositingContext();
-  if (!sharedContext)
-    return;
-
   // TODO: Should be able to more directly submit from here if we can
   // figure out how to do so without blocking the compositor.
   DrawingBuffer* drawingBuffer = m_renderingContext->drawingBuffer();
@@ -489,8 +444,8 @@
   drawingBuffer->markContentsChanged();
 
   if (mailbox.HasSyncToken())
-    sharedContext->WaitSyncTokenCHROMIUM(mailbox.GetSyncTokenData());
-  GLuint vrSourceTexture = sharedContext->CreateAndConsumeTextureCHROMIUM(
+    gl->WaitSyncTokenCHROMIUM(mailbox.GetSyncTokenData());
+  GLuint vrSourceTexture = gl->CreateAndConsumeTextureCHROMIUM(
       mailbox.target(), mailbox.name());
 
   // Get last orientation
@@ -502,10 +457,10 @@
     w = m_framePose->orientation[3];
   }
 
-  sharedContext->SubmitVRCompositorFrameCHROMIUM(m_compositorHandle,
-                                                 vrSourceTexture, x, y, z, w);
+  gl->SubmitVRCompositorFrameCHROMIUM(m_compositorHandle,
+                                      vrSourceTexture, x, y, z, w);
 
-  sharedContext->Flush();
+  gl->Flush();
 
   release_callback->Run(mailbox.sync_token(), false);
 #endif
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.h b/third_party/WebKit/Source/modules/vr/VRDisplay.h
index 1f72755..9ebd8764 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.h
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.h
@@ -93,8 +93,6 @@
   void updateLayerBounds();
   void disconnected();
 
-  gpu::gles2::GLES2Interface* getCompositingContext();
-
   VRController* controller();
 
  private: