From 843da553731628df2ccbbf63975eb9db687f3b25 Mon Sep 17 00:00:00 2001
From: "jamesr@chromium.org"
 <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Wed, 4 Dec 2013 23:22:26 +0000
Subject: Expose GLES2Interface to cc

This exposes a gpu::gles2::GLES2Interface pointer to cc through the ContextProvider.  This is a way for the compositor to talk to the client side of the command buffer more directly, bypassing the blink::WebGraphicsContext3D indirection.  See the bug for the plan for using this new interface and deprecating WGC3D.

BUG=181120

Review URL: https://codereview.chromium.org/54463007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238809 0039d316-1c4b-4281-b951-d872f2087c98
---
 cc/cc_tests.gyp                  | 1 +
 cc/output/context_provider.h     | 6 +++++-
 cc/output/gl_renderer.h          | 1 +
 cc/test/DEPS                     | 2 +-
 cc/test/test_context_provider.cc | 8 ++++++++
 cc/test/test_context_provider.h  | 3 +++
 6 files changed, 19 insertions(+), 2 deletions(-)

(limited to 'cc')

diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index 9d03b2c..c632e7f 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -320,6 +320,7 @@
       'dependencies': [
         '../base/base.gyp:base',
         '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+        '../gpu/gpu.gyp:gpu_unittest_utils',
         '../skia/skia.gyp:skia',
         '../testing/gmock.gyp:gmock',
         '../testing/gtest.gyp:gtest',
diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h
index 72a627cb..8649421 100644
--- a/cc/output/context_provider.h
+++ b/cc/output/context_provider.h
@@ -12,7 +12,10 @@
 
 class GrContext;
 namespace blink { class WebGraphicsContext3D; }
-namespace gpu { class ContextSupport; }
+namespace gpu {
+class ContextSupport;
+namespace gles2 { class GLES2Interface; }
+}
 
 namespace cc {
 struct ManagedMemoryPolicy;
@@ -26,6 +29,7 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> {
   virtual bool BindToCurrentThread() = 0;
 
   virtual blink::WebGraphicsContext3D* Context3d() = 0;
+  virtual gpu::gles2::GLES2Interface* ContextGL() = 0;
   virtual gpu::ContextSupport* ContextSupport() = 0;
   virtual class GrContext* GrContext() = 0;
 
diff --git a/cc/output/gl_renderer.h b/cc/output/gl_renderer.h
index b716ad5..8d95262 100644
--- a/cc/output/gl_renderer.h
+++ b/cc/output/gl_renderer.h
@@ -27,6 +27,7 @@ namespace blink { class WebGraphicsContext3D; }
 
 namespace cc {
 
+class ContextProvider;
 class GLRendererShaderTest;
 class OutputSurface;
 class PictureDrawQuad;
diff --git a/cc/test/DEPS b/cc/test/DEPS
index 8a37ff9e..8f04cc2 100644
--- a/cc/test/DEPS
+++ b/cc/test/DEPS
@@ -1,5 +1,5 @@
 include_rules = [
-  "+ui/gl/",
+  "+gpu/command_buffer/client/gles2_interface_stub.h",
   # TODO(jamesr): Remove once cc depends on GLES2Interface instead of WGC3D
   "+webkit/common/gpu",
 ]
diff --git a/cc/test/test_context_provider.cc b/cc/test/test_context_provider.cc
index af1e12d..8484b38 100644
--- a/cc/test/test_context_provider.cc
+++ b/cc/test/test_context_provider.cc
@@ -120,6 +120,14 @@ blink::WebGraphicsContext3D* TestContextProvider::Context3d() {
   return context3d_.get();
 }
 
+gpu::gles2::GLES2Interface* TestContextProvider::ContextGL() {
+  DCHECK(context3d_);
+  DCHECK(bound_);
+  DCHECK(context_thread_checker_.CalledOnValidThread());
+
+  return &context_gl_stub_;
+}
+
 gpu::ContextSupport* TestContextProvider::ContextSupport() {
   DCHECK(bound_);
   DCHECK(context_thread_checker_.CalledOnValidThread());
diff --git a/cc/test/test_context_provider.h b/cc/test/test_context_provider.h
index c708180..81167c6 100644
--- a/cc/test/test_context_provider.h
+++ b/cc/test/test_context_provider.h
@@ -11,6 +11,7 @@
 #include "base/threading/thread_checker.h"
 #include "cc/output/context_provider.h"
 #include "cc/test/test_context_support.h"
+#include "gpu/command_buffer/client/gles2_interface_stub.h"
 
 namespace blink { class WebGraphicsContext3D; }
 
@@ -29,6 +30,7 @@ class TestContextProvider : public cc::ContextProvider {
   virtual bool BindToCurrentThread() OVERRIDE;
   virtual Capabilities ContextCapabilities() OVERRIDE;
   virtual blink::WebGraphicsContext3D* Context3d() OVERRIDE;
+  virtual gpu::gles2::GLES2Interface* ContextGL() OVERRIDE;
   virtual gpu::ContextSupport* ContextSupport() OVERRIDE;
   virtual class GrContext* GrContext() OVERRIDE;
   virtual bool IsContextLost() OVERRIDE;
@@ -62,6 +64,7 @@ class TestContextProvider : public cc::ContextProvider {
   TestContextSupport support_;
 
   scoped_ptr<TestWebGraphicsContext3D> context3d_;
+  gpu::gles2::GLES2InterfaceStub context_gl_stub_;
   bool bound_;
 
   base::ThreadChecker main_thread_checker_;
-- 
cgit v1.1