| OLD | NEW |
| 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 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" | 37 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" |
| 38 #include "third_party/skia/include/core/SkTypes.h" | 38 #include "third_party/skia/include/core/SkTypes.h" |
| 39 | 39 |
| 40 namespace content { | 40 namespace content { |
| 41 | 41 |
| 42 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( | 42 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( |
| 43 gpu::SurfaceHandle surface_handle, | 43 gpu::SurfaceHandle surface_handle, |
| 44 const GURL& active_url, | 44 const GURL& active_url, |
| 45 scoped_refptr<gpu::GpuChannelHost> host, | 45 scoped_refptr<gpu::GpuChannelHost> host, |
| 46 gfx::GpuPreference gpu_preference, | 46 gfx::GpuPreference gpu_preference, |
| 47 bool automatic_flushes) | 47 bool automatic_flushes, |
| 48 : automatic_flushes_(automatic_flushes), | 48 int32_t stream_id, |
| 49 host_(std::move(host)), | 49 gpu::GpuStreamPriority stream_priority) |
| 50 : host_(std::move(host)), |
| 50 surface_handle_(surface_handle), | 51 surface_handle_(surface_handle), |
| 51 active_url_(active_url), | 52 active_url_(active_url), |
| 52 gpu_preference_(gpu_preference), | 53 gpu_preference_(gpu_preference), |
| 54 automatic_flushes_(automatic_flushes), |
| 55 stream_id_(stream_id), |
| 56 stream_priority_(stream_priority), |
| 53 weak_ptr_factory_(this) { | 57 weak_ptr_factory_(this) { |
| 54 DCHECK(host_); | 58 DCHECK(host_); |
| 55 } | 59 } |
| 56 | 60 |
| 57 WebGraphicsContext3DCommandBufferImpl:: | 61 WebGraphicsContext3DCommandBufferImpl:: |
| 58 ~WebGraphicsContext3DCommandBufferImpl() { | 62 ~WebGraphicsContext3DCommandBufferImpl() { |
| 59 if (real_gl_) | 63 if (real_gl_) |
| 60 real_gl_->SetLostContextCallback(base::Closure()); | 64 real_gl_->SetLostContextCallback(base::Closure()); |
| 61 | 65 |
| 62 Destroy(); | 66 Destroy(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 command_buffer_metrics::ContextType context_type) { | 111 command_buffer_metrics::ContextType context_type) { |
| 108 if (!host_.get()) | 112 if (!host_.get()) |
| 109 return false; | 113 return false; |
| 110 | 114 |
| 111 DCHECK(attributes.buffer_preserved); | 115 DCHECK(attributes.buffer_preserved); |
| 112 std::vector<int32_t> serialized_attributes; | 116 std::vector<int32_t> serialized_attributes; |
| 113 attributes.Serialize(&serialized_attributes); | 117 attributes.Serialize(&serialized_attributes); |
| 114 | 118 |
| 115 // Create a proxy to a command buffer in the GPU process. | 119 // Create a proxy to a command buffer in the GPU process. |
| 116 command_buffer_ = host_->CreateCommandBuffer( | 120 command_buffer_ = host_->CreateCommandBuffer( |
| 117 surface_handle_, gfx::Size(), shared_command_buffer, | 121 surface_handle_, gfx::Size(), shared_command_buffer, stream_id_, |
| 118 gpu::GpuChannelHost::kDefaultStreamId, | 122 stream_priority_, serialized_attributes, active_url_, gpu_preference_); |
| 119 gpu::GpuChannelHost::kDefaultStreamPriority, serialized_attributes, | |
| 120 active_url_, gpu_preference_); | |
| 121 | 123 |
| 122 if (!command_buffer_) { | 124 if (!command_buffer_) { |
| 123 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; | 125 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; |
| 124 command_buffer_metrics::UmaRecordContextInitFailed(context_type); | 126 command_buffer_metrics::UmaRecordContextInitFailed(context_type); |
| 125 return false; | 127 return false; |
| 126 } | 128 } |
| 127 | 129 |
| 128 DVLOG_IF(1, gpu::error::IsError(command_buffer_->GetLastError())) | 130 DVLOG_IF(1, gpu::error::IsError(command_buffer_->GetLastError())) |
| 129 << "Context dead on arrival. Last error: " | 131 << "Context dead on arrival. Last error: " |
| 130 << command_buffer_->GetLastError(); | 132 << command_buffer_->GetLastError(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 WebGraphicsContext3DCommandBufferImpl::GetContextSupport() { | 219 WebGraphicsContext3DCommandBufferImpl::GetContextSupport() { |
| 218 return real_gl_.get(); | 220 return real_gl_.get(); |
| 219 } | 221 } |
| 220 | 222 |
| 221 void WebGraphicsContext3DCommandBufferImpl::OnContextLost() { | 223 void WebGraphicsContext3DCommandBufferImpl::OnContextLost() { |
| 222 if (context_lost_callback_) | 224 if (context_lost_callback_) |
| 223 context_lost_callback_->onContextLost(); | 225 context_lost_callback_->onContextLost(); |
| 224 } | 226 } |
| 225 | 227 |
| 226 } // namespace content | 228 } // namespace content |
| OLD | NEW |