Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h

Issue 101223005: Plumbing explicit share groups through context creation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Large rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ 5 #ifndef CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_
6 #define CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ 6 #define CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/synchronization/lock.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "content/common/gpu/client/command_buffer_proxy_impl.h" 16 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
16 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 17 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
17 #include "third_party/WebKit/public/platform/WebString.h" 18 #include "third_party/WebKit/public/platform/WebString.h"
18 #include "ui/gfx/native_widget_types.h" 19 #include "ui/gfx/native_widget_types.h"
19 #include "ui/gl/gpu_preference.h" 20 #include "ui/gl/gpu_preference.h"
20 #include "url/gurl.h" 21 #include "url/gurl.h"
21 22
22 namespace gpu { 23 namespace gpu {
23 24
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 struct CONTENT_EXPORT SharedMemoryLimits { 67 struct CONTENT_EXPORT SharedMemoryLimits {
67 SharedMemoryLimits(); 68 SharedMemoryLimits();
68 69
69 size_t command_buffer_size; 70 size_t command_buffer_size;
70 size_t start_transfer_buffer_size; 71 size_t start_transfer_buffer_size;
71 size_t min_transfer_buffer_size; 72 size_t min_transfer_buffer_size;
72 size_t max_transfer_buffer_size; 73 size_t max_transfer_buffer_size;
73 size_t mapped_memory_reclaim_limit; 74 size_t mapped_memory_reclaim_limit;
74 }; 75 };
75 76
77 class ShareGroup : public base::RefCountedThreadSafe<ShareGroup> {
78 public:
79 ShareGroup();
80
81 WebGraphicsContext3DCommandBufferImpl* GetAnyContextLocked() {
82 // In order to ensure that the context returned is not removed while
83 // in use the share group's lock should be aquired before calling this
Ken Russell (switch to Gerrit) 2014/02/19 22:38:26 "in use" -> "in use," for clarity
84 // function.
85 lock_.AssertAcquired();
86 if (contexts_.empty())
87 return NULL;
88 return contexts_.front();
89 }
90
91 void AddContextLocked(WebGraphicsContext3DCommandBufferImpl* context) {
92 lock_.AssertAcquired();
93 contexts_.push_back(context);
94 }
95
96 void RemoveContext(WebGraphicsContext3DCommandBufferImpl* context) {
97 base::AutoLock auto_lock(lock_);
98 contexts_.erase(std::remove(contexts_.begin(), contexts_.end(), context),
99 contexts_.end());
100 }
101
102 void RemoveAllContexts() {
103 base::AutoLock auto_lock(lock_);
104 contexts_.clear();
105 }
106
107 base::Lock& lock() {
108 return lock_;
109 }
110
111 private:
112 friend class base::RefCountedThreadSafe<ShareGroup>;
113 ~ShareGroup();
114
115 std::vector<WebGraphicsContext3DCommandBufferImpl*> contexts_;
116 base::Lock lock_;
117
118 DISALLOW_COPY_AND_ASSIGN(ShareGroup);
119 };
120
76 WebGraphicsContext3DCommandBufferImpl( 121 WebGraphicsContext3DCommandBufferImpl(
77 int surface_id, 122 int surface_id,
78 const GURL& active_url, 123 const GURL& active_url,
79 GpuChannelHost* host, 124 GpuChannelHost* host,
80 const Attributes& attributes, 125 const Attributes& attributes,
81 bool bind_generates_resources, 126 bool bind_generates_resources,
82 const SharedMemoryLimits& limits); 127 const SharedMemoryLimits& limits,
128 WebGraphicsContext3DCommandBufferImpl* share_context);
83 129
84 virtual ~WebGraphicsContext3DCommandBufferImpl(); 130 virtual ~WebGraphicsContext3DCommandBufferImpl();
85 131
86 CommandBufferProxyImpl* GetCommandBufferProxy() { 132 CommandBufferProxyImpl* GetCommandBufferProxy() {
87 return command_buffer_.get(); 133 return command_buffer_.get();
88 } 134 }
89 135
90 CONTENT_EXPORT gpu::ContextSupport* GetContextSupport(); 136 CONTENT_EXPORT gpu::ContextSupport* GetContextSupport();
91 137
92 gpu::gles2::GLES2Implementation* GetImplementation() { 138 gpu::gles2::GLES2Implementation* GetImplementation() {
93 return real_gl_.get(); 139 return real_gl_.get();
94 } 140 }
95 141
96 // Return true if GPU process reported context lost or there was a 142 // Return true if GPU process reported context lost or there was a
97 // problem communicating with the GPU process. 143 // problem communicating with the GPU process.
98 bool IsCommandBufferContextLost(); 144 bool IsCommandBufferContextLost();
99 145
100 // Create & initialize a WebGraphicsContext3DCommandBufferImpl. Return NULL 146 // Create & initialize a WebGraphicsContext3DCommandBufferImpl. Return NULL
101 // on any failure. 147 // on any failure.
102 static CONTENT_EXPORT WebGraphicsContext3DCommandBufferImpl* 148 static CONTENT_EXPORT WebGraphicsContext3DCommandBufferImpl*
103 CreateOffscreenContext( 149 CreateOffscreenContext(
104 GpuChannelHost* host, 150 GpuChannelHost* host,
105 const WebGraphicsContext3D::Attributes& attributes, 151 const WebGraphicsContext3D::Attributes& attributes,
106 const GURL& active_url, 152 const GURL& active_url,
107 const SharedMemoryLimits& limits); 153 const SharedMemoryLimits& limits,
154 WebGraphicsContext3DCommandBufferImpl* share_context);
108 155
109 size_t GetMappedMemoryLimit() { 156 size_t GetMappedMemoryLimit() {
110 return mem_limits_.mapped_memory_reclaim_limit; 157 return mem_limits_.mapped_memory_reclaim_limit;
111 } 158 }
112 159
113 //---------------------------------------------------------------------- 160 //----------------------------------------------------------------------
114 // WebGraphicsContext3D methods 161 // WebGraphicsContext3D methods
115 162
116 // Must be called after initialize() and before any of the following methods. 163 // Must be called after initialize() and before any of the following methods.
117 // Permanently binds to the first calling thread. Returns false if the 164 // Permanently binds to the first calling thread. Returns false if the
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 FAIL_IF_MAJOR_PERF_CAVEAT = 0x10002 703 FAIL_IF_MAJOR_PERF_CAVEAT = 0x10002
657 }; 704 };
658 friend class WebGraphicsContext3DErrorMessageCallback; 705 friend class WebGraphicsContext3DErrorMessageCallback;
659 706
660 // Initialize the underlying GL context. May be called multiple times; second 707 // Initialize the underlying GL context. May be called multiple times; second
661 // and subsequent calls are ignored. Must be called from the thread that is 708 // and subsequent calls are ignored. Must be called from the thread that is
662 // going to use this object to issue GL commands (which might not be the main 709 // going to use this object to issue GL commands (which might not be the main
663 // thread). 710 // thread).
664 bool MaybeInitializeGL(); 711 bool MaybeInitializeGL();
665 712
666 bool InitializeCommandBuffer(bool onscreen); 713 bool InitializeCommandBuffer(bool onscreen,
714 WebGraphicsContext3DCommandBufferImpl* share_context);
667 715
668 void Destroy(); 716 void Destroy();
669 717
670 // Create a CommandBufferProxy that renders directly to a view. The view and 718 // Create a CommandBufferProxy that renders directly to a view. The view and
671 // the associated window must not be destroyed until the returned 719 // the associated window must not be destroyed until the returned
672 // CommandBufferProxy has been destroyed, otherwise the GPU process might 720 // CommandBufferProxy has been destroyed, otherwise the GPU process might
673 // attempt to render to an invalid window handle. 721 // attempt to render to an invalid window handle.
674 // 722 //
675 // NOTE: on Mac OS X, this entry point is only used to set up the 723 // NOTE: on Mac OS X, this entry point is only used to set up the
676 // accelerated compositor's output. On this platform, we actually pass 724 // accelerated compositor's output. On this platform, we actually pass
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; 763 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_;
716 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; 764 scoped_ptr<gpu::TransferBuffer> transfer_buffer_;
717 gpu::gles2::GLES2Interface* gl_; 765 gpu::gles2::GLES2Interface* gl_;
718 scoped_ptr<gpu::gles2::GLES2Implementation> real_gl_; 766 scoped_ptr<gpu::gles2::GLES2Implementation> real_gl_;
719 scoped_ptr<gpu::gles2::GLES2Interface> trace_gl_; 767 scoped_ptr<gpu::gles2::GLES2Interface> trace_gl_;
720 Error last_error_; 768 Error last_error_;
721 bool bind_generates_resources_; 769 bool bind_generates_resources_;
722 SharedMemoryLimits mem_limits_; 770 SharedMemoryLimits mem_limits_;
723 771
724 uint32_t flush_id_; 772 uint32_t flush_id_;
773 scoped_refptr<ShareGroup> share_group_;
725 }; 774 };
726 775
727 } // namespace content 776 } // namespace content
728 777
729 #endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ 778 #endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698