| 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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 366 |
| 367 return RenderThread::Get()->Send(message); | 367 return RenderThread::Get()->Send(message); |
| 368 } | 368 } |
| 369 | 369 |
| 370 void RenderWidget::Resize(const gfx::Size& new_size, | 370 void RenderWidget::Resize(const gfx::Size& new_size, |
| 371 const gfx::Size& physical_backing_size, | 371 const gfx::Size& physical_backing_size, |
| 372 float overdraw_bottom_height, | 372 float overdraw_bottom_height, |
| 373 const gfx::Rect& resizer_rect, | 373 const gfx::Rect& resizer_rect, |
| 374 bool is_fullscreen, | 374 bool is_fullscreen, |
| 375 ResizeAck resize_ack) { | 375 ResizeAck resize_ack) { |
| 376 if (!RenderThreadImpl::current() || // Will be NULL during unit tests. | 376 // A resize ack shouldn't be requested if we have not ACK'd the previous one. |
| 377 !RenderThreadImpl::current()->layout_test_mode()) { | 377 DCHECK(resize_ack != SEND_RESIZE_ACK || !next_paint_is_resize_ack()); |
| 378 // A resize ack shouldn't be requested if we have not ACK'd the previous | 378 DCHECK(resize_ack == SEND_RESIZE_ACK || resize_ack == NO_RESIZE_ACK); |
| 379 // one. | |
| 380 DCHECK(resize_ack != SEND_RESIZE_ACK || !next_paint_is_resize_ack()); | |
| 381 DCHECK(resize_ack == SEND_RESIZE_ACK || resize_ack == NO_RESIZE_ACK); | |
| 382 } | |
| 383 | 379 |
| 384 // Ignore this during shutdown. | 380 // Ignore this during shutdown. |
| 385 if (!webwidget_) | 381 if (!webwidget_) |
| 386 return; | 382 return; |
| 387 | 383 |
| 388 if (compositor_) { | 384 if (compositor_) { |
| 389 compositor_->setViewportSize(new_size, physical_backing_size); | 385 compositor_->setViewportSize(new_size, physical_backing_size); |
| 390 compositor_->SetOverdrawBottomHeight(overdraw_bottom_height); | 386 compositor_->SetOverdrawBottomHeight(overdraw_bottom_height); |
| 391 } | 387 } |
| 392 | 388 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 409 paint_aggregator_.ClearPendingUpdate(); | 405 paint_aggregator_.ClearPendingUpdate(); |
| 410 | 406 |
| 411 // When resizing, we want to wait to paint before ACK'ing the resize. This | 407 // When resizing, we want to wait to paint before ACK'ing the resize. This |
| 412 // ensures that we only resize as fast as we can paint. We only need to | 408 // ensures that we only resize as fast as we can paint. We only need to |
| 413 // send an ACK if we are resized to a non-empty rect. | 409 // send an ACK if we are resized to a non-empty rect. |
| 414 webwidget_->resize(new_size); | 410 webwidget_->resize(new_size); |
| 415 | 411 |
| 416 // Resize should have caused an invalidation of the entire view. | 412 // Resize should have caused an invalidation of the entire view. |
| 417 DCHECK(new_size.IsEmpty() || is_accelerated_compositing_active_ || | 413 DCHECK(new_size.IsEmpty() || is_accelerated_compositing_active_ || |
| 418 paint_aggregator_.HasPendingUpdate()); | 414 paint_aggregator_.HasPendingUpdate()); |
| 419 } else if (!RenderThreadImpl::current() || // Will be NULL during unit tests. | 415 } else if (size_browser_expects_ == new_size) { |
| 420 !RenderThreadImpl::current()->layout_test_mode()) { | |
| 421 resize_ack = NO_RESIZE_ACK; | 416 resize_ack = NO_RESIZE_ACK; |
| 422 } | 417 } |
| 423 | 418 |
| 424 if (new_size.IsEmpty() || physical_backing_size.IsEmpty()) { | 419 if (new_size.IsEmpty() || physical_backing_size.IsEmpty()) { |
| 425 // For empty size or empty physical_backing_size, there is no next paint | 420 // For empty size or empty physical_backing_size, there is no next paint |
| 426 // (along with which to send the ack) until they are set to non-empty. | 421 // (along with which to send the ack) until they are set to non-empty. |
| 427 resize_ack = NO_RESIZE_ACK; | 422 resize_ack = NO_RESIZE_ACK; |
| 428 } | 423 } |
| 429 | 424 |
| 430 // Send the Resize_ACK flag once we paint again if requested. | 425 // Send the Resize_ACK flag once we paint again if requested. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 462 |
| 468 CompleteInit(); | 463 CompleteInit(); |
| 469 } | 464 } |
| 470 | 465 |
| 471 void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) { | 466 void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) { |
| 472 screen_info_ = params.screen_info; | 467 screen_info_ = params.screen_info; |
| 473 SetDeviceScaleFactor(screen_info_.deviceScaleFactor); | 468 SetDeviceScaleFactor(screen_info_.deviceScaleFactor); |
| 474 Resize(params.new_size, params.physical_backing_size, | 469 Resize(params.new_size, params.physical_backing_size, |
| 475 params.overdraw_bottom_height, params.resizer_rect, | 470 params.overdraw_bottom_height, params.resizer_rect, |
| 476 params.is_fullscreen, SEND_RESIZE_ACK); | 471 params.is_fullscreen, SEND_RESIZE_ACK); |
| 472 size_browser_expects_ = params.new_size; |
| 477 } | 473 } |
| 478 | 474 |
| 479 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { | 475 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { |
| 480 if (resizer_rect_ != resizer_rect) { | 476 if (resizer_rect_ != resizer_rect) { |
| 481 gfx::Rect view_rect(size_); | 477 gfx::Rect view_rect(size_); |
| 482 | 478 |
| 483 gfx::Rect old_damage_rect = gfx::IntersectRects(view_rect, resizer_rect_); | 479 gfx::Rect old_damage_rect = gfx::IntersectRects(view_rect, resizer_rect_); |
| 484 if (!old_damage_rect.IsEmpty()) | 480 if (!old_damage_rect.IsEmpty()) |
| 485 paint_aggregator_.InvalidateRect(old_damage_rect); | 481 paint_aggregator_.InvalidateRect(old_damage_rect); |
| 486 | 482 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 | 532 |
| 537 void RenderWidget::OnRequestMoveAck() { | 533 void RenderWidget::OnRequestMoveAck() { |
| 538 DCHECK(pending_window_rect_count_); | 534 DCHECK(pending_window_rect_count_); |
| 539 pending_window_rect_count_--; | 535 pending_window_rect_count_--; |
| 540 } | 536 } |
| 541 | 537 |
| 542 void RenderWidget::OnUpdateRectAck() { | 538 void RenderWidget::OnUpdateRectAck() { |
| 543 TRACE_EVENT0("renderer", "RenderWidget::OnUpdateRectAck"); | 539 TRACE_EVENT0("renderer", "RenderWidget::OnUpdateRectAck"); |
| 544 DCHECK(update_reply_pending_); | 540 DCHECK(update_reply_pending_); |
| 545 update_reply_pending_ = false; | 541 update_reply_pending_ = false; |
| 542 size_browser_expects_ = size_; |
| 546 | 543 |
| 547 // If we sent an UpdateRect message with a zero-sized bitmap, then we should | 544 // If we sent an UpdateRect message with a zero-sized bitmap, then we should |
| 548 // have no current paint buffer. | 545 // have no current paint buffer. |
| 549 if (current_paint_buf_) { | 546 if (current_paint_buf_) { |
| 550 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 547 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
| 551 current_paint_buf_ = NULL; | 548 current_paint_buf_ = NULL; |
| 552 } | 549 } |
| 553 | 550 |
| 554 // If swapbuffers is still pending, then defer the update until the | 551 // If swapbuffers is still pending, then defer the update until the |
| 555 // swapbuffers occurs. | 552 // swapbuffers occurs. |
| (...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2393 | 2390 |
| 2394 if (!context->Initialize( | 2391 if (!context->Initialize( |
| 2395 attributes, | 2392 attributes, |
| 2396 false /* bind generates resources */, | 2393 false /* bind generates resources */, |
| 2397 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2394 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) |
| 2398 return NULL; | 2395 return NULL; |
| 2399 return context.release(); | 2396 return context.release(); |
| 2400 } | 2397 } |
| 2401 | 2398 |
| 2402 } // namespace content | 2399 } // namespace content |
| OLD | NEW |