summaryrefslogtreecommitdiffstats
path: root/patches/0001-Add-seams-to-setup-GL-contexts-sharing-with-QtQuick.patch
blob: 926f799f2472f5650ea20d1788a4381ad0654a21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
From 559c011aabd6fc9f064d2913e4fae06db2c8495b Mon Sep 17 00:00:00 2001
From: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Date: Thu, 24 Oct 2013 18:26:59 +0200
Subject: [PATCH] Add seams to setup GL contexts sharing with QtQuick.

This will allow us to know right before the first GL context is
instantiated by Chromium so that we can install those contexts to
be shared with QtQuick GL contexts as well.
---
 content/common/gpu/gpu_channel_manager.cc       | 8 +++++++-
 content/public/browser/content_browser_client.h | 5 +++++
 ui/gl/gl_share_group.cc                         | 3 +++
 ui/gl/gl_share_group.h                          | 7 +++++--
 4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc
index 8b466bd..fe3f7b3 100644
--- a/content/common/gpu/gpu_channel_manager.cc
+++ b/content/common/gpu/gpu_channel_manager.cc
@@ -11,6 +11,7 @@
 #include "content/common/gpu/gpu_memory_manager.h"
 #include "content/common/gpu/gpu_messages.h"
 #include "content/common/gpu/sync_point_manager.h"
+#include "content/public/browser/content_browser_client.h"
 #include "gpu/command_buffer/service/feature_info.h"
 #include "gpu/command_buffer/service/gpu_switches.h"
 #include "gpu/command_buffer/service/mailbox_manager.h"
@@ -124,7 +125,12 @@ void GpuChannelManager::OnEstablishChannel(int client_id, bool share_context) {
       DCHECK(!mailbox_manager_.get());
       mailbox_manager_ = new gpu::gles2::MailboxManager;
     }
-    share_group = share_group_.get();
+    // Qt: Ask the browser client at the top to manage the context sharing.
+    // This can only work with --in-process-gpu or --single-process.
+    if (GetContentClient()->browser() && GetContentClient()->browser()->GetInProcessGpuShareGroup())
+      share_group = GetContentClient()->browser()->GetInProcessGpuShareGroup();
+    else
+      share_group = share_group_.get();
     mailbox_manager = mailbox_manager_.get();
   }
 
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index cc664c6..f817cb2 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -48,6 +48,7 @@ class CryptoModuleBlockingPasswordDelegate;
 }
 
 namespace gfx {
+class GLShareGroup;
 class ImageSkia;
 }
 
@@ -570,6 +571,10 @@ class CONTENT_EXPORT ContentBrowserClient {
   // Return NULL to use the default one for the platform to be created.
   virtual LocationProvider* OverrideSystemLocationProvider();
 
+  // Allow an embedder to provide a share group reimplementation to connect renderer
+  // GL contexts with the root compositor.
+  virtual gfx::GLShareGroup* GetInProcessGpuShareGroup() { return 0; }
+
 #if defined(OS_POSIX) && !defined(OS_MACOSX)
   // Populates |mappings| with all files that need to be mapped before launching
   // a child process.
diff --git a/ui/gl/gl_share_group.cc b/ui/gl/gl_share_group.cc
index 8e8958b..347873d 100644
--- a/ui/gl/gl_share_group.cc
+++ b/ui/gl/gl_share_group.cc
@@ -18,6 +18,9 @@ GLShareGroup::GLShareGroup()
 }
 
 void GLShareGroup::AddContext(GLContext* context) {
+  if (contexts_.empty())
+    AboutToAddFirstContext();
+
   contexts_.insert(context);
 }
 
diff --git a/ui/gl/gl_share_group.h b/ui/gl/gl_share_group.h
index 1deed63..f1b0369 100644
--- a/ui/gl/gl_share_group.h
+++ b/ui/gl/gl_share_group.h
@@ -31,7 +31,7 @@ class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
 
   // Returns a pointer to any initialized context in the share group
   // or NULL if there are no initialized contexts in the share group.
-  GLContext* GetContext();
+  virtual GLContext* GetContext();
 
   // Sets and returns the unique shared GL context. Used for context
   // virtualization.
@@ -45,10 +45,13 @@ class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
   int GetRendererID();
 #endif
 
+ protected:
+  virtual ~GLShareGroup();
+  virtual void AboutToAddFirstContext() { }
+
  private:
   friend class base::RefCounted<GLShareGroup>;
 
-  ~GLShareGroup();
 
   // References to GLContext are by raw pointer to avoid a reference count
   // cycle.
-- 
1.8.4.2