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 "ui/compositor/compositor.h" | 5 #include "ui/compositor/compositor.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 403 |
404 Compositor::Compositor(CompositorDelegate* delegate, | 404 Compositor::Compositor(CompositorDelegate* delegate, |
405 gfx::AcceleratedWidget widget) | 405 gfx::AcceleratedWidget widget) |
406 : delegate_(delegate), | 406 : delegate_(delegate), |
407 root_layer_(NULL), | 407 root_layer_(NULL), |
408 widget_(widget), | 408 widget_(widget), |
409 posted_swaps_(new PostedSwapQueue()), | 409 posted_swaps_(new PostedSwapQueue()), |
410 device_scale_factor_(0.0f), | 410 device_scale_factor_(0.0f), |
411 last_started_frame_(0), | 411 last_started_frame_(0), |
412 last_ended_frame_(0), | 412 last_ended_frame_(0), |
| 413 next_draw_is_resize_(false), |
413 disable_schedule_composite_(false), | 414 disable_schedule_composite_(false), |
414 compositor_lock_(NULL) { | 415 compositor_lock_(NULL) { |
415 root_web_layer_ = cc::Layer::Create(); | 416 root_web_layer_ = cc::Layer::Create(); |
416 root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); | 417 root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); |
417 | 418 |
418 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 419 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
419 | 420 |
420 cc::LayerTreeSettings settings; | 421 cc::LayerTreeSettings settings; |
421 settings.refresh_rate = | 422 settings.refresh_rate = |
422 g_test_compositor_enabled ? kTestRefreshRate : kDefaultRefreshRate; | 423 g_test_compositor_enabled ? kTestRefreshRate : kDefaultRefreshRate; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 if (!root_layer_) | 521 if (!root_layer_) |
521 return; | 522 return; |
522 | 523 |
523 last_started_frame_++; | 524 last_started_frame_++; |
524 PendingSwap pending_swap(DRAW_SWAP, posted_swaps_.get()); | 525 PendingSwap pending_swap(DRAW_SWAP, posted_swaps_.get()); |
525 if (!IsLocked()) { | 526 if (!IsLocked()) { |
526 // TODO(nduca): Temporary while compositor calls | 527 // TODO(nduca): Temporary while compositor calls |
527 // compositeImmediately() directly. | 528 // compositeImmediately() directly. |
528 Layout(); | 529 Layout(); |
529 host_->Composite(base::TimeTicks::Now()); | 530 host_->Composite(base::TimeTicks::Now()); |
| 531 |
| 532 #if defined(OS_WIN) |
| 533 // While we resize, we are usually a few frames behind. By blocking |
| 534 // the UI thread here we minize the area that is mis-painted, specially |
| 535 // in the non-client area. See RenderWidgetHostViewAura::SetBounds for |
| 536 // more details and bug 177115. |
| 537 if (next_draw_is_resize_ && (last_ended_frame_ > 1)) { |
| 538 next_draw_is_resize_ = false; |
| 539 host_->FinishAllRendering(); |
| 540 } |
| 541 #endif |
| 542 |
530 } | 543 } |
531 if (!pending_swap.posted()) | 544 if (!pending_swap.posted()) |
532 NotifyEnd(); | 545 NotifyEnd(); |
533 } | 546 } |
534 | 547 |
535 void Compositor::ScheduleFullDraw() { | 548 void Compositor::ScheduleFullDraw() { |
536 host_->SetNeedsRedraw(); | 549 host_->SetNeedsRedraw(); |
537 } | 550 } |
538 | 551 |
539 bool Compositor::ReadPixels(SkBitmap* bitmap, | 552 bool Compositor::ReadPixels(SkBitmap* bitmap, |
(...skipping 10 matching lines...) Expand all Loading... |
550 PendingSwap pending_swap(READPIXELS_SWAP, posted_swaps_.get()); | 563 PendingSwap pending_swap(READPIXELS_SWAP, posted_swaps_.get()); |
551 return host_->CompositeAndReadback(pixels, bounds_in_pixel); | 564 return host_->CompositeAndReadback(pixels, bounds_in_pixel); |
552 } | 565 } |
553 | 566 |
554 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { | 567 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { |
555 DCHECK_GT(scale, 0); | 568 DCHECK_GT(scale, 0); |
556 if (!size_in_pixel.IsEmpty()) { | 569 if (!size_in_pixel.IsEmpty()) { |
557 size_ = size_in_pixel; | 570 size_ = size_in_pixel; |
558 host_->SetViewportSize(size_in_pixel, size_in_pixel); | 571 host_->SetViewportSize(size_in_pixel, size_in_pixel); |
559 root_web_layer_->SetBounds(size_in_pixel); | 572 root_web_layer_->SetBounds(size_in_pixel); |
| 573 |
| 574 next_draw_is_resize_ = true; |
560 } | 575 } |
561 if (device_scale_factor_ != scale) { | 576 if (device_scale_factor_ != scale) { |
562 device_scale_factor_ = scale; | 577 device_scale_factor_ = scale; |
563 if (root_layer_) | 578 if (root_layer_) |
564 root_layer_->OnDeviceScaleFactorChanged(scale); | 579 root_layer_->OnDeviceScaleFactorChanged(scale); |
565 } | 580 } |
566 } | 581 } |
567 | 582 |
568 void Compositor::SetBackgroundColor(SkColor color) { | 583 void Compositor::SetBackgroundColor(SkColor color) { |
569 host_->set_background_color(color); | 584 host_->set_background_color(color); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 COMPOSITOR_EXPORT void DisableTestCompositor() { | 744 COMPOSITOR_EXPORT void DisableTestCompositor() { |
730 ResetImplicitFactory(); | 745 ResetImplicitFactory(); |
731 g_test_compositor_enabled = false; | 746 g_test_compositor_enabled = false; |
732 } | 747 } |
733 | 748 |
734 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { | 749 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { |
735 return g_test_compositor_enabled; | 750 return g_test_compositor_enabled; |
736 } | 751 } |
737 | 752 |
738 } // namespace ui | 753 } // namespace ui |
OLD | NEW |