| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 start_transfer_buffer_size(kDefaultStartTransferBufferSize), | 222 start_transfer_buffer_size(kDefaultStartTransferBufferSize), |
| 223 min_transfer_buffer_size(kDefaultMinTransferBufferSize), | 223 min_transfer_buffer_size(kDefaultMinTransferBufferSize), |
| 224 max_transfer_buffer_size(kDefaultMaxTransferBufferSize), | 224 max_transfer_buffer_size(kDefaultMaxTransferBufferSize), |
| 225 mapped_memory_reclaim_limit(gpu::gles2::GLES2Implementation::kNoLimit) {} | 225 mapped_memory_reclaim_limit(gpu::gles2::GLES2Implementation::kNoLimit) {} |
| 226 | 226 |
| 227 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( | 227 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( |
| 228 int surface_id, | 228 int surface_id, |
| 229 const GURL& active_url, | 229 const GURL& active_url, |
| 230 GpuChannelHost* host, | 230 GpuChannelHost* host, |
| 231 const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client, | 231 const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client, |
| 232 bool use_echo_for_swap_ack, |
| 232 const Attributes& attributes, | 233 const Attributes& attributes, |
| 233 bool bind_generates_resources, | 234 bool bind_generates_resources, |
| 234 const SharedMemoryLimits& limits) | 235 const SharedMemoryLimits& limits) |
| 235 : initialize_failed_(false), | 236 : initialize_failed_(false), |
| 236 visible_(false), | 237 visible_(false), |
| 237 free_command_buffer_when_invisible_(false), | 238 free_command_buffer_when_invisible_(false), |
| 238 host_(host), | 239 host_(host), |
| 239 surface_id_(surface_id), | 240 surface_id_(surface_id), |
| 240 active_url_(active_url), | 241 active_url_(active_url), |
| 241 swap_client_(swap_client), | 242 swap_client_(swap_client), |
| 242 context_lost_callback_(0), | 243 context_lost_callback_(0), |
| 243 context_lost_reason_(GL_NO_ERROR), | 244 context_lost_reason_(GL_NO_ERROR), |
| 244 error_message_callback_(0), | 245 error_message_callback_(0), |
| 245 swapbuffers_complete_callback_(0), | 246 swapbuffers_complete_callback_(0), |
| 246 attributes_(attributes), | 247 attributes_(attributes), |
| 247 gpu_preference_(attributes.preferDiscreteGPU ? gfx::PreferDiscreteGpu | 248 gpu_preference_(attributes.preferDiscreteGPU ? gfx::PreferDiscreteGpu |
| 248 : gfx::PreferIntegratedGpu), | 249 : gfx::PreferIntegratedGpu), |
| 249 weak_ptr_factory_(this), | 250 weak_ptr_factory_(this), |
| 250 initialized_(false), | 251 initialized_(false), |
| 251 gl_(NULL), | 252 gl_(NULL), |
| 252 frame_number_(0), | 253 frame_number_(0), |
| 253 bind_generates_resources_(bind_generates_resources), | 254 bind_generates_resources_(bind_generates_resources), |
| 254 use_echo_for_swap_ack_(true), | 255 use_echo_for_swap_ack_(use_echo_for_swap_ack), |
| 255 mem_limits_(limits), | 256 mem_limits_(limits), |
| 256 flush_id_(0) { | 257 flush_id_(0) { |
| 257 #if (defined(OS_MACOSX) || defined(OS_WIN)) && !defined(USE_AURA) | |
| 258 // Get ViewMsg_SwapBuffers_ACK from browser for single-threaded path. | |
| 259 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 260 use_echo_for_swap_ack_ = | |
| 261 command_line.HasSwitch(switches::kEnableThreadedCompositing); | |
| 262 #endif | |
| 263 } | 258 } |
| 264 | 259 |
| 265 WebGraphicsContext3DCommandBufferImpl:: | 260 WebGraphicsContext3DCommandBufferImpl:: |
| 266 ~WebGraphicsContext3DCommandBufferImpl() { | 261 ~WebGraphicsContext3DCommandBufferImpl() { |
| 267 if (real_gl_) { | 262 if (real_gl_) { |
| 268 real_gl_->SetErrorMessageCallback(NULL); | 263 real_gl_->SetErrorMessageCallback(NULL); |
| 269 } | 264 } |
| 270 | 265 |
| 271 { | 266 { |
| 272 base::AutoLock lock(g_all_shared_contexts_lock.Get()); | 267 base::AutoLock lock(g_all_shared_contexts_lock.Get()); |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 | 1268 |
| 1274 // static | 1269 // static |
| 1275 WebGraphicsContext3DCommandBufferImpl* | 1270 WebGraphicsContext3DCommandBufferImpl* |
| 1276 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 1271 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
| 1277 GpuChannelHost* host, | 1272 GpuChannelHost* host, |
| 1278 const WebGraphicsContext3D::Attributes& attributes, | 1273 const WebGraphicsContext3D::Attributes& attributes, |
| 1279 const GURL& active_url) { | 1274 const GURL& active_url) { |
| 1280 if (!host) | 1275 if (!host) |
| 1281 return NULL; | 1276 return NULL; |
| 1282 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> null_client; | 1277 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> null_client; |
| 1278 bool use_echo_for_swap_ack = true; |
| 1283 return new WebGraphicsContext3DCommandBufferImpl(0, | 1279 return new WebGraphicsContext3DCommandBufferImpl(0, |
| 1284 active_url, | 1280 active_url, |
| 1285 host, | 1281 host, |
| 1286 null_client, | 1282 null_client, |
| 1283 use_echo_for_swap_ack, |
| 1287 attributes, | 1284 attributes, |
| 1288 false, | 1285 false, |
| 1289 SharedMemoryLimits()); | 1286 SharedMemoryLimits()); |
| 1290 } | 1287 } |
| 1291 | 1288 |
| 1292 void WebGraphicsContext3DCommandBufferImpl:: | 1289 void WebGraphicsContext3DCommandBufferImpl:: |
| 1293 setSwapBuffersCompleteCallbackCHROMIUM( | 1290 setSwapBuffersCompleteCallbackCHROMIUM( |
| 1294 WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* cb) { | 1291 WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* cb) { |
| 1295 swapbuffers_complete_callback_ = cb; | 1292 swapbuffers_complete_callback_ = cb; |
| 1296 } | 1293 } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 | 1461 |
| 1465 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1462 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
| 1466 const std::string& message, int id) { | 1463 const std::string& message, int id) { |
| 1467 if (error_message_callback_) { | 1464 if (error_message_callback_) { |
| 1468 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); | 1465 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); |
| 1469 error_message_callback_->onErrorMessage(str, id); | 1466 error_message_callback_->onErrorMessage(str, id); |
| 1470 } | 1467 } |
| 1471 } | 1468 } |
| 1472 | 1469 |
| 1473 } // namespace content | 1470 } // namespace content |
| OLD | NEW |