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

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

Issue 1827123002: Move content/common/gpu/client to gpu/ipc/client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 8 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
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 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
6 6
7 #include "third_party/khronos/GLES2/gl2.h" 7 #include "third_party/khronos/GLES2/gl2.h"
8 #ifndef GL_GLEXT_PROTOTYPES 8 #ifndef GL_GLEXT_PROTOTYPES
9 #define GL_GLEXT_PROTOTYPES 1 9 #define GL_GLEXT_PROTOTYPES 1
10 #endif 10 #endif
11 #include "third_party/khronos/GLES2/gl2ext.h" 11 #include "third_party/khronos/GLES2/gl2ext.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <map> 14 #include <map>
15 15
16 #include "base/atomicops.h" 16 #include "base/atomicops.h"
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/lazy_instance.h" 19 #include "base/lazy_instance.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/message_loop/message_loop.h" 21 #include "base/message_loop/message_loop.h"
22 #include "base/metrics/field_trial.h" 22 #include "base/metrics/field_trial.h"
23 #include "base/metrics/histogram.h" 23 #include "base/metrics/histogram.h"
24 #include "base/profiler/scoped_tracker.h" 24 #include "base/profiler/scoped_tracker.h"
25 #include "base/trace_event/trace_event.h" 25 #include "base/trace_event/trace_event.h"
26 #include "content/common/gpu/client/gpu_channel_host.h"
27 #include "gpu/GLES2/gl2extchromium.h" 26 #include "gpu/GLES2/gl2extchromium.h"
28 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 27 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
29 #include "gpu/command_buffer/client/gles2_implementation.h" 28 #include "gpu/command_buffer/client/gles2_implementation.h"
30 #include "gpu/command_buffer/client/gles2_trace_implementation.h" 29 #include "gpu/command_buffer/client/gles2_trace_implementation.h"
31 #include "gpu/command_buffer/client/gpu_switches.h" 30 #include "gpu/command_buffer/client/gpu_switches.h"
32 #include "gpu/command_buffer/client/transfer_buffer.h" 31 #include "gpu/command_buffer/client/transfer_buffer.h"
33 #include "gpu/command_buffer/common/constants.h" 32 #include "gpu/command_buffer/common/constants.h"
34 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 33 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
35 #include "gpu/command_buffer/common/mailbox.h" 34 #include "gpu/command_buffer/common/mailbox.h"
35 #include "gpu/ipc/client/gpu_channel_host.h"
36 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" 36 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
37 #include "third_party/skia/include/core/SkTypes.h" 37 #include "third_party/skia/include/core/SkTypes.h"
38 38
39 namespace content { 39 namespace content {
40 40
41 namespace { 41 namespace {
42 42
43 static base::LazyInstance<base::Lock>::Leaky 43 static base::LazyInstance<base::Lock>::Leaky
44 g_default_share_groups_lock = LAZY_INSTANCE_INITIALIZER; 44 g_default_share_groups_lock = LAZY_INSTANCE_INITIALIZER;
45 45
46 typedef std::map<GpuChannelHost*, 46 typedef std::map<
47 scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup> > 47 gpu::GpuChannelHost*,
48 scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup>>
48 ShareGroupMap; 49 ShareGroupMap;
49 static base::LazyInstance<ShareGroupMap> g_default_share_groups = 50 static base::LazyInstance<ShareGroupMap> g_default_share_groups =
50 LAZY_INSTANCE_INITIALIZER; 51 LAZY_INSTANCE_INITIALIZER;
51 52
52 scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup> 53 scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup>
53 GetDefaultShareGroupForHost(GpuChannelHost* host) { 54 GetDefaultShareGroupForHost(gpu::GpuChannelHost* host) {
54 base::AutoLock lock(g_default_share_groups_lock.Get()); 55 base::AutoLock lock(g_default_share_groups_lock.Get());
55 56
56 ShareGroupMap& share_groups = g_default_share_groups.Get(); 57 ShareGroupMap& share_groups = g_default_share_groups.Get();
57 ShareGroupMap::iterator it = share_groups.find(host); 58 ShareGroupMap::iterator it = share_groups.find(host);
58 if (it == share_groups.end()) { 59 if (it == share_groups.end()) {
59 scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup> group = 60 scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup> group =
60 new WebGraphicsContext3DCommandBufferImpl::ShareGroup(); 61 new WebGraphicsContext3DCommandBufferImpl::ShareGroup();
61 share_groups[host] = group; 62 share_groups[host] = group;
62 return group; 63 return group;
63 } 64 }
(...skipping 12 matching lines...) Expand all
76 WebGraphicsContext3DCommandBufferImpl::ShareGroup::ShareGroup() { 77 WebGraphicsContext3DCommandBufferImpl::ShareGroup::ShareGroup() {
77 } 78 }
78 79
79 WebGraphicsContext3DCommandBufferImpl::ShareGroup::~ShareGroup() { 80 WebGraphicsContext3DCommandBufferImpl::ShareGroup::~ShareGroup() {
80 DCHECK(contexts_.empty()); 81 DCHECK(contexts_.empty());
81 } 82 }
82 83
83 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( 84 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
84 gpu::SurfaceHandle surface_handle, 85 gpu::SurfaceHandle surface_handle,
85 const GURL& active_url, 86 const GURL& active_url,
86 GpuChannelHost* host, 87 gpu::GpuChannelHost* host,
87 const gpu::gles2::ContextCreationAttribHelper& attributes, 88 const gpu::gles2::ContextCreationAttribHelper& attributes,
88 gfx::GpuPreference gpu_preference, 89 gfx::GpuPreference gpu_preference,
89 bool share_resources, 90 bool share_resources,
90 bool automatic_flushes, 91 bool automatic_flushes,
91 const SharedMemoryLimits& limits, 92 const SharedMemoryLimits& limits,
92 WebGraphicsContext3DCommandBufferImpl* share_context) 93 WebGraphicsContext3DCommandBufferImpl* share_context)
93 : automatic_flushes_(automatic_flushes), 94 : automatic_flushes_(automatic_flushes),
94 attributes_(attributes), 95 attributes_(attributes),
95 host_(host), 96 host_(host),
96 surface_handle_(surface_handle), 97 surface_handle_(surface_handle),
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 161
161 initialized_ = true; 162 initialized_ = true;
162 return true; 163 return true;
163 } 164 }
164 165
165 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( 166 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer(
166 WebGraphicsContext3DCommandBufferImpl* share_context) { 167 WebGraphicsContext3DCommandBufferImpl* share_context) {
167 if (!host_.get()) 168 if (!host_.get())
168 return false; 169 return false;
169 170
170 CommandBufferProxyImpl* share_group_command_buffer = NULL; 171 gpu::CommandBufferProxyImpl* share_group_command_buffer = NULL;
171 172
172 if (share_context) { 173 if (share_context) {
173 share_group_command_buffer = share_context->GetCommandBufferProxy(); 174 share_group_command_buffer = share_context->GetCommandBufferProxy();
174 } 175 }
175 176
176 DCHECK(attributes_.buffer_preserved); 177 DCHECK(attributes_.buffer_preserved);
177 std::vector<int32_t> serialized_attributes; 178 std::vector<int32_t> serialized_attributes;
178 attributes_.Serialize(&serialized_attributes); 179 attributes_.Serialize(&serialized_attributes);
179 180
180 // Create a proxy to a command buffer in the GPU process. 181 // Create a proxy to a command buffer in the GPU process.
181 command_buffer_ = host_->CreateCommandBuffer( 182 command_buffer_ = host_->CreateCommandBuffer(
182 surface_handle_, gfx::Size(), share_group_command_buffer, 183 surface_handle_, gfx::Size(), share_group_command_buffer,
183 GpuChannelHost::kDefaultStreamId, GpuChannelHost::kDefaultStreamPriority, 184 gpu::GpuChannelHost::kDefaultStreamId,
184 serialized_attributes, active_url_, gpu_preference_); 185 gpu::GpuChannelHost::kDefaultStreamPriority, serialized_attributes,
186 active_url_, gpu_preference_);
185 187
186 if (!command_buffer_) { 188 if (!command_buffer_) {
187 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; 189 DLOG(ERROR) << "GpuChannelHost failed to create command buffer.";
188 UmaRecordContextInitFailed(context_type_); 190 UmaRecordContextInitFailed(context_type_);
189 return false; 191 return false;
190 } 192 }
191 193
192 DVLOG_IF(1, gpu::error::IsError(command_buffer_->GetLastError())) 194 DVLOG_IF(1, gpu::error::IsError(command_buffer_->GetLastError()))
193 << "Context dead on arrival. Last error: " 195 << "Context dead on arrival. Last error: "
194 << command_buffer_->GetLastError(); 196 << command_buffer_->GetLastError();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // command buffer's state. 320 // command buffer's state.
319 if (host_.get() && host_->IsLost()) 321 if (host_.get() && host_->IsLost())
320 return true; 322 return true;
321 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 323 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
322 return gpu::error::IsError(state.error); 324 return gpu::error::IsError(state.error);
323 } 325 }
324 326
325 // static 327 // static
326 WebGraphicsContext3DCommandBufferImpl* 328 WebGraphicsContext3DCommandBufferImpl*
327 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 329 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
328 GpuChannelHost* host, 330 gpu::GpuChannelHost* host,
329 const gpu::gles2::ContextCreationAttribHelper& attributes, 331 const gpu::gles2::ContextCreationAttribHelper& attributes,
330 gfx::GpuPreference gpu_preference, 332 gfx::GpuPreference gpu_preference,
331 bool share_resources, 333 bool share_resources,
332 bool automatic_flushes, 334 bool automatic_flushes,
333 const GURL& active_url, 335 const GURL& active_url,
334 const SharedMemoryLimits& limits, 336 const SharedMemoryLimits& limits,
335 WebGraphicsContext3DCommandBufferImpl* share_context) { 337 WebGraphicsContext3DCommandBufferImpl* share_context) {
336 if (!host) 338 if (!host)
337 return NULL; 339 return NULL;
338 340
(...skipping 15 matching lines...) Expand all
354 { 356 {
355 base::AutoLock lock(g_default_share_groups_lock.Get()); 357 base::AutoLock lock(g_default_share_groups_lock.Get());
356 g_default_share_groups.Get().erase(host_.get()); 358 g_default_share_groups.Get().erase(host_.get());
357 } 359 }
358 360
359 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 361 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
360 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason); 362 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason);
361 } 363 }
362 364
363 } // namespace content 365 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698