Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: ui/compositor/compositor.cc

Issue 13604007: Fix large mis-paint when resizing windows aura chrome (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/synchronization/waitable_event.h"
15 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
16 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
17 #include "cc/base/switches.h" 18 #include "cc/base/switches.h"
18 #include "cc/base/thread_impl.h" 19 #include "cc/base/thread_impl.h"
19 #include "cc/input/input_handler.h" 20 #include "cc/input/input_handler.h"
20 #include "cc/layers/layer.h" 21 #include "cc/layers/layer.h"
21 #include "cc/output/context_provider.h" 22 #include "cc/output/context_provider.h"
22 #include "cc/output/output_surface.h" 23 #include "cc/output/output_surface.h"
23 #include "cc/trees/layer_tree_host.h" 24 #include "cc/trees/layer_tree_host.h"
24 #include "third_party/skia/include/core/SkBitmap.h" 25 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 Compositor::Compositor(CompositorDelegate* delegate, 405 Compositor::Compositor(CompositorDelegate* delegate,
405 gfx::AcceleratedWidget widget) 406 gfx::AcceleratedWidget widget)
406 : delegate_(delegate), 407 : delegate_(delegate),
407 root_layer_(NULL), 408 root_layer_(NULL),
408 widget_(widget), 409 widget_(widget),
409 posted_swaps_(new PostedSwapQueue()), 410 posted_swaps_(new PostedSwapQueue()),
410 device_scale_factor_(0.0f), 411 device_scale_factor_(0.0f),
411 last_started_frame_(0), 412 last_started_frame_(0),
412 last_ended_frame_(0), 413 last_ended_frame_(0),
413 disable_schedule_composite_(false), 414 disable_schedule_composite_(false),
415 is_resizing_ (false),
414 compositor_lock_(NULL) { 416 compositor_lock_(NULL) {
415 root_web_layer_ = cc::Layer::Create(); 417 root_web_layer_ = cc::Layer::Create();
416 root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); 418 root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f));
417 419
418 CommandLine* command_line = CommandLine::ForCurrentProcess(); 420 CommandLine* command_line = CommandLine::ForCurrentProcess();
419 421
420 cc::LayerTreeSettings settings; 422 cc::LayerTreeSettings settings;
421 settings.refresh_rate = 423 settings.refresh_rate =
422 g_test_compositor_enabled ? kTestRefreshRate : kDefaultRefreshRate; 424 g_test_compositor_enabled ? kTestRefreshRate : kDefaultRefreshRate;
423 settings.partial_swap_enabled = 425 settings.partial_swap_enabled =
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 if (!root_layer_) 522 if (!root_layer_)
521 return; 523 return;
522 524
523 last_started_frame_++; 525 last_started_frame_++;
524 PendingSwap pending_swap(DRAW_SWAP, posted_swaps_.get()); 526 PendingSwap pending_swap(DRAW_SWAP, posted_swaps_.get());
525 if (!IsLocked()) { 527 if (!IsLocked()) {
526 // TODO(nduca): Temporary while compositor calls 528 // TODO(nduca): Temporary while compositor calls
527 // compositeImmediately() directly. 529 // compositeImmediately() directly.
528 Layout(); 530 Layout();
529 host_->Composite(base::TimeTicks::Now()); 531 host_->Composite(base::TimeTicks::Now());
532
533 #if defined(OS_WIN)
534 // While we resize, we are usually a few frames behind. By blocking
535 // the UI thread here we minize the area that is mis-painted, specially
536 // in the non-client area. See RenderWidgetHostViewAura::SetBounds for
537 // more details and bug 177115.
538 if (is_resizing_ && (last_ended_frame_ > 1)) {
539 is_resizing_ = false;
540 host_->FinishAllRendering();
541 }
542 #endif
543
530 } 544 }
531 if (!pending_swap.posted()) 545 if (!pending_swap.posted())
532 NotifyEnd(); 546 NotifyEnd();
533 } 547 }
534 548
535 void Compositor::ScheduleFullDraw() { 549 void Compositor::ScheduleFullDraw() {
536 host_->SetNeedsRedraw(); 550 host_->SetNeedsRedraw();
537 } 551 }
538 552
539 bool Compositor::ReadPixels(SkBitmap* bitmap, 553 bool Compositor::ReadPixels(SkBitmap* bitmap,
(...skipping 10 matching lines...) Expand all
550 PendingSwap pending_swap(READPIXELS_SWAP, posted_swaps_.get()); 564 PendingSwap pending_swap(READPIXELS_SWAP, posted_swaps_.get());
551 return host_->CompositeAndReadback(pixels, bounds_in_pixel); 565 return host_->CompositeAndReadback(pixels, bounds_in_pixel);
552 } 566 }
553 567
554 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { 568 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) {
555 DCHECK_GT(scale, 0); 569 DCHECK_GT(scale, 0);
556 if (!size_in_pixel.IsEmpty()) { 570 if (!size_in_pixel.IsEmpty()) {
557 size_ = size_in_pixel; 571 size_ = size_in_pixel;
558 host_->SetViewportSize(size_in_pixel, size_in_pixel); 572 host_->SetViewportSize(size_in_pixel, size_in_pixel);
559 root_web_layer_->SetBounds(size_in_pixel); 573 root_web_layer_->SetBounds(size_in_pixel);
574
575 is_resizing_ = true;
560 } 576 }
561 if (device_scale_factor_ != scale) { 577 if (device_scale_factor_ != scale) {
562 device_scale_factor_ = scale; 578 device_scale_factor_ = scale;
563 if (root_layer_) 579 if (root_layer_)
564 root_layer_->OnDeviceScaleFactorChanged(scale); 580 root_layer_->OnDeviceScaleFactorChanged(scale);
565 } 581 }
566 } 582 }
567 583
568 void Compositor::SetBackgroundColor(SkColor color) { 584 void Compositor::SetBackgroundColor(SkColor color) {
569 host_->set_background_color(color); 585 host_->set_background_color(color);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 COMPOSITOR_EXPORT void DisableTestCompositor() { 745 COMPOSITOR_EXPORT void DisableTestCompositor() {
730 ResetImplicitFactory(); 746 ResetImplicitFactory();
731 g_test_compositor_enabled = false; 747 g_test_compositor_enabled = false;
732 } 748 }
733 749
734 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { 750 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() {
735 return g_test_compositor_enabled; 751 return g_test_compositor_enabled;
736 } 752 }
737 753
738 } // namespace ui 754 } // namespace ui
OLDNEW
« gpu/command_buffer/build_gles2_cmd_buffer.py ('K') | « ui/compositor/compositor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698