| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 free_command_buffer_when_invisible_(false), | 224 free_command_buffer_when_invisible_(false), |
| 225 host_(NULL), | 225 host_(NULL), |
| 226 surface_id_(surface_id), | 226 surface_id_(surface_id), |
| 227 active_url_(active_url), | 227 active_url_(active_url), |
| 228 swap_client_(swap_client), | 228 swap_client_(swap_client), |
| 229 context_lost_callback_(0), | 229 context_lost_callback_(0), |
| 230 context_lost_reason_(GL_NO_ERROR), | 230 context_lost_reason_(GL_NO_ERROR), |
| 231 error_message_callback_(0), | 231 error_message_callback_(0), |
| 232 swapbuffers_complete_callback_(0), | 232 swapbuffers_complete_callback_(0), |
| 233 gpu_preference_(gfx::PreferIntegratedGpu), | 233 gpu_preference_(gfx::PreferIntegratedGpu), |
| 234 cached_width_(0), | |
| 235 cached_height_(0), | |
| 236 weak_ptr_factory_(this), | 234 weak_ptr_factory_(this), |
| 237 initialized_(false), | 235 initialized_(false), |
| 238 gl_(NULL), | 236 gl_(NULL), |
| 239 frame_number_(0), | 237 frame_number_(0), |
| 240 bind_generates_resources_(false), | 238 bind_generates_resources_(false), |
| 241 use_echo_for_swap_ack_(true), | 239 use_echo_for_swap_ack_(true), |
| 242 command_buffer_size_(0), | 240 command_buffer_size_(0), |
| 243 start_transfer_buffer_size_(0), | 241 start_transfer_buffer_size_(0), |
| 244 min_transfer_buffer_size_(0), | 242 min_transfer_buffer_size_(0), |
| 245 max_transfer_buffer_size_(0), | 243 max_transfer_buffer_size_(0), |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 if (command_buffer_->GetLastError() != gpu::error::kNoError) | 501 if (command_buffer_->GetLastError() != gpu::error::kNoError) |
| 504 return false; | 502 return false; |
| 505 | 503 |
| 506 return true; | 504 return true; |
| 507 } | 505 } |
| 508 | 506 |
| 509 uint32_t WebGraphicsContext3DCommandBufferImpl::lastFlushID() { | 507 uint32_t WebGraphicsContext3DCommandBufferImpl::lastFlushID() { |
| 510 return flush_id_; | 508 return flush_id_; |
| 511 } | 509 } |
| 512 | 510 |
| 513 int WebGraphicsContext3DCommandBufferImpl::width() { | |
| 514 return cached_width_; | |
| 515 } | |
| 516 | |
| 517 int WebGraphicsContext3DCommandBufferImpl::height() { | |
| 518 return cached_height_; | |
| 519 } | |
| 520 | |
| 521 DELEGATE_TO_GL_R(insertSyncPoint, InsertSyncPointCHROMIUM, unsigned int) | 511 DELEGATE_TO_GL_R(insertSyncPoint, InsertSyncPointCHROMIUM, unsigned int) |
| 522 | 512 |
| 523 void WebGraphicsContext3DCommandBufferImpl::Destroy() { | 513 void WebGraphicsContext3DCommandBufferImpl::Destroy() { |
| 524 if (gl_) { | 514 if (gl_) { |
| 525 // First flush the context to ensure that any pending frees of resources | 515 // First flush the context to ensure that any pending frees of resources |
| 526 // are completed. Otherwise, if this context is part of a share group, | 516 // are completed. Otherwise, if this context is part of a share group, |
| 527 // those resources might leak. Also, any remaining side effects of commands | 517 // those resources might leak. Also, any remaining side effects of commands |
| 528 // issued on this context might not be visible to other contexts in the | 518 // issued on this context might not be visible to other contexts in the |
| 529 // share group. | 519 // share group. |
| 530 gl_->Flush(); | 520 gl_->Flush(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 // Same flow control as WebGraphicsContext3DCommandBufferImpl::prepareTexture | 580 // Same flow control as WebGraphicsContext3DCommandBufferImpl::prepareTexture |
| 591 // (see above). | 581 // (see above). |
| 592 if (ShouldUseSwapClient()) | 582 if (ShouldUseSwapClient()) |
| 593 swap_client_->OnViewContextSwapBuffersPosted(); | 583 swap_client_->OnViewContextSwapBuffersPosted(); |
| 594 gl_->PostSubBufferCHROMIUM(x, y, width, height); | 584 gl_->PostSubBufferCHROMIUM(x, y, width, height); |
| 595 command_buffer_->Echo(base::Bind( | 585 command_buffer_->Echo(base::Bind( |
| 596 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, | 586 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, |
| 597 weak_ptr_factory_.GetWeakPtr())); | 587 weak_ptr_factory_.GetWeakPtr())); |
| 598 } | 588 } |
| 599 | 589 |
| 600 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) { | 590 DELEGATE_TO_GL_3(reshapeWithScaleFactor, ResizeCHROMIUM, int, int, float) |
| 601 reshapeWithScaleFactor(width, height, 1.f); | |
| 602 } | |
| 603 | |
| 604 void WebGraphicsContext3DCommandBufferImpl::reshapeWithScaleFactor( | |
| 605 int width, int height, float scale_factor) { | |
| 606 cached_width_ = width; | |
| 607 cached_height_ = height; | |
| 608 | |
| 609 gl_->ResizeCHROMIUM(width, height, scale_factor); | |
| 610 } | |
| 611 | 591 |
| 612 void WebGraphicsContext3DCommandBufferImpl::synthesizeGLError( | 592 void WebGraphicsContext3DCommandBufferImpl::synthesizeGLError( |
| 613 WGC3Denum error) { | 593 WGC3Denum error) { |
| 614 if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == | 594 if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == |
| 615 synthetic_errors_.end()) { | 595 synthetic_errors_.end()) { |
| 616 synthetic_errors_.push_back(error); | 596 synthetic_errors_.push_back(error); |
| 617 } | 597 } |
| 618 } | 598 } |
| 619 | 599 |
| 620 DELEGATE_TO_GL_4R(mapBufferSubDataCHROMIUM, MapBufferSubDataCHROMIUM, WGC3Denum, | 600 DELEGATE_TO_GL_4R(mapBufferSubDataCHROMIUM, MapBufferSubDataCHROMIUM, WGC3Denum, |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1594 | 1574 |
| 1595 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1575 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
| 1596 const std::string& message, int id) { | 1576 const std::string& message, int id) { |
| 1597 if (error_message_callback_) { | 1577 if (error_message_callback_) { |
| 1598 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); | 1578 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); |
| 1599 error_message_callback_->onErrorMessage(str, id); | 1579 error_message_callback_->onErrorMessage(str, id); |
| 1600 } | 1580 } |
| 1601 } | 1581 } |
| 1602 | 1582 |
| 1603 } // namespace content | 1583 } // namespace content |
| OLD | NEW |