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

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

Issue 1907783002: Delete //gpu/blink/ and WebGraphicsContext3DImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rm-webgraphicscontext3dimpl: . 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 #include <memory> 15 #include <memory>
16 16
17 #include "base/atomicops.h" 17 #include "base/atomicops.h"
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/lazy_instance.h" 20 #include "base/lazy_instance.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/metrics/field_trial.h" 23 #include "base/metrics/field_trial.h"
24 #include "base/metrics/histogram.h" 24 #include "base/metrics/histogram.h"
25 #include "base/profiler/scoped_tracker.h" 25 #include "base/profiler/scoped_tracker.h"
26 #include "base/trace_event/trace_event.h" 26 #include "base/trace_event/trace_event.h"
27 #include "gpu/GLES2/gl2extchromium.h" 27 #include "gpu/GLES2/gl2extchromium.h"
28 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 28 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
29 #include "gpu/command_buffer/client/gles2_implementation.h" 29 #include "gpu/command_buffer/client/gles2_implementation.h"
30 #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/shared_memory_limits.h" 31 #include "gpu/command_buffer/client/shared_memory_limits.h"
33 #include "gpu/command_buffer/client/transfer_buffer.h" 32 #include "gpu/command_buffer/client/transfer_buffer.h"
34 #include "gpu/command_buffer/common/constants.h" 33 #include "gpu/command_buffer/common/constants.h"
35 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 34 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
36 #include "gpu/command_buffer/common/mailbox.h" 35 #include "gpu/command_buffer/common/mailbox.h"
37 #include "gpu/ipc/client/gpu_channel_host.h" 36 #include "gpu/ipc/client/gpu_channel_host.h"
38 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" 37 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
39 #include "third_party/skia/include/core/SkTypes.h" 38 #include "third_party/skia/include/core/SkTypes.h"
40 39
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const bool bind_generates_resource = attributes_.bind_generates_resource; 233 const bool bind_generates_resource = attributes_.bind_generates_resource;
235 const bool lose_context_when_out_of_memory = 234 const bool lose_context_when_out_of_memory =
236 attributes_.lose_context_when_out_of_memory; 235 attributes_.lose_context_when_out_of_memory;
237 const bool support_client_side_arrays = false; 236 const bool support_client_side_arrays = false;
238 237
239 // Create the object exposing the OpenGL API. 238 // Create the object exposing the OpenGL API.
240 real_gl_.reset(new gpu::gles2::GLES2Implementation( 239 real_gl_.reset(new gpu::gles2::GLES2Implementation(
241 gles2_helper_.get(), gles2_share_group.get(), transfer_buffer_.get(), 240 gles2_helper_.get(), gles2_share_group.get(), transfer_buffer_.get(),
242 bind_generates_resource, lose_context_when_out_of_memory, 241 bind_generates_resource, lose_context_when_out_of_memory,
243 support_client_side_arrays, command_buffer_.get())); 242 support_client_side_arrays, command_buffer_.get()));
244 SetGLInterface(real_gl_.get());
245
246 if (!real_gl_->Initialize(memory_limits.start_transfer_buffer_size, 243 if (!real_gl_->Initialize(memory_limits.start_transfer_buffer_size,
247 memory_limits.min_transfer_buffer_size, 244 memory_limits.min_transfer_buffer_size,
248 memory_limits.max_transfer_buffer_size, 245 memory_limits.max_transfer_buffer_size,
249 memory_limits.mapped_memory_reclaim_limit)) { 246 memory_limits.mapped_memory_reclaim_limit)) {
250 LOG(ERROR) << "Failed to initialize GLES2Implementation."; 247 LOG(ERROR) << "Failed to initialize GLES2Implementation.";
251 return false; 248 return false;
252 } 249 }
253 250
254 if (add_to_share_group) 251 if (add_to_share_group)
255 share_group_->AddContextLocked(this); 252 share_group_->AddContextLocked(this);
256 253
257 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
258 switches::kEnableGpuClientTracing)) {
259 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(GetGLInterface()));
260 SetGLInterface(trace_gl_.get());
261 }
262 return true; 254 return true;
263 } 255 }
264 256
265 bool WebGraphicsContext3DCommandBufferImpl::InitializeOnCurrentThread( 257 bool WebGraphicsContext3DCommandBufferImpl::InitializeOnCurrentThread(
266 const gpu::SharedMemoryLimits& memory_limits) { 258 const gpu::SharedMemoryLimits& memory_limits) {
267 if (!MaybeInitializeGL(memory_limits)) { 259 if (!MaybeInitializeGL(memory_limits)) {
268 DLOG(ERROR) << "Failed to initialize context."; 260 DLOG(ERROR) << "Failed to initialize context.";
269 return false; 261 return false;
270 } 262 }
271 if (gpu::error::IsError(command_buffer_->GetLastError())) { 263 if (gpu::error::IsError(command_buffer_->GetLastError())) {
272 LOG(ERROR) << "Context dead on arrival. Last error: " 264 LOG(ERROR) << "Context dead on arrival. Last error: "
273 << command_buffer_->GetLastError(); 265 << command_buffer_->GetLastError();
274 return false; 266 return false;
275 } 267 }
276 268
277 return true; 269 return true;
278 } 270 }
279 271
280 void WebGraphicsContext3DCommandBufferImpl::Destroy() { 272 void WebGraphicsContext3DCommandBufferImpl::Destroy() {
281 share_group_->RemoveContext(this); 273 share_group_->RemoveContext(this);
282 274
283 gpu::gles2::GLES2Interface* gl = GetGLInterface();
danakj 2016/04/21 00:38:42 Since we no longer know the tracing interface only
284 if (gl) {
285 // First flush the context to ensure that any pending frees of resources
286 // are completed. Otherwise, if this context is part of a share group,
287 // those resources might leak. Also, any remaining side effects of commands
288 // issued on this context might not be visible to other contexts in the
289 // share group.
290 gl->Flush();
291 SetGLInterface(nullptr);
292 }
293
294 trace_gl_.reset(); 275 trace_gl_.reset();
295 real_gl_.reset(); 276 real_gl_.reset();
296 transfer_buffer_.reset(); 277 transfer_buffer_.reset();
297 gles2_helper_.reset(); 278 gles2_helper_.reset();
298 real_gl_.reset(); 279 real_gl_.reset();
299 command_buffer_.reset(); 280 command_buffer_.reset();
300 281
301 host_ = nullptr; 282 host_ = nullptr;
302 } 283 }
303 284
(...skipping 12 matching lines...) Expand all
316 { 297 {
317 base::AutoLock lock(g_default_share_groups_lock.Get()); 298 base::AutoLock lock(g_default_share_groups_lock.Get());
318 g_default_share_groups.Get().erase(host_.get()); 299 g_default_share_groups.Get().erase(host_.get());
319 } 300 }
320 301
321 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 302 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
322 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason); 303 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason);
323 } 304 }
324 305
325 } // namespace content 306 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698