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