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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 | 89 |
90 namespace ui { | 90 namespace ui { |
91 | 91 |
92 Compositor::Compositor(gfx::AcceleratedWidget widget) | 92 Compositor::Compositor(gfx::AcceleratedWidget widget) |
93 : root_layer_(NULL), | 93 : root_layer_(NULL), |
94 widget_(widget), | 94 widget_(widget), |
95 vsync_manager_(new CompositorVSyncManager()), | 95 vsync_manager_(new CompositorVSyncManager()), |
96 device_scale_factor_(0.0f), | 96 device_scale_factor_(0.0f), |
97 last_started_frame_(0), | 97 last_started_frame_(0), |
98 last_ended_frame_(0), | 98 last_ended_frame_(0), |
99 next_draw_is_resize_(false), | |
100 disable_schedule_composite_(false), | 99 disable_schedule_composite_(false), |
101 compositor_lock_(NULL), | 100 compositor_lock_(NULL), |
102 defer_draw_scheduling_(false), | 101 defer_draw_scheduling_(false), |
103 waiting_on_compositing_end_(false), | 102 waiting_on_compositing_end_(false), |
104 draw_on_compositing_end_(false), | 103 draw_on_compositing_end_(false), |
105 swap_state_(SWAP_NONE), | 104 swap_state_(SWAP_NONE), |
106 schedule_draw_factory_(this) { | 105 schedule_draw_factory_(this) { |
107 DCHECK(g_compositor_initialized) | 106 DCHECK(g_compositor_initialized) |
108 << "Compositor::Initialize must be called before creating a Compositor."; | 107 << "Compositor::Initialize must be called before creating a Compositor."; |
109 | 108 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 | 278 |
280 DCHECK_NE(swap_state_, SWAP_POSTED); | 279 DCHECK_NE(swap_state_, SWAP_POSTED); |
281 swap_state_ = SWAP_NONE; | 280 swap_state_ = SWAP_NONE; |
282 | 281 |
283 last_started_frame_++; | 282 last_started_frame_++; |
284 if (!IsLocked()) { | 283 if (!IsLocked()) { |
285 // TODO(nduca): Temporary while compositor calls | 284 // TODO(nduca): Temporary while compositor calls |
286 // compositeImmediately() directly. | 285 // compositeImmediately() directly. |
287 Layout(); | 286 Layout(); |
288 host_->Composite(gfx::FrameTime::Now()); | 287 host_->Composite(gfx::FrameTime::Now()); |
289 | |
290 #if defined(OS_WIN) | |
291 // While we resize, we are usually a few frames behind. By blocking | |
292 // the UI thread here we minize the area that is mis-painted, specially | |
293 // in the non-client area. See RenderWidgetHostViewAura::SetBounds for | |
cpu_(ooo_6.6-7.5)
2014/05/10 02:36:23
I might have put this code here :(
Do you know wh
| |
294 // more details and bug 177115. | |
295 if (next_draw_is_resize_ && (last_ended_frame_ > 1)) { | |
296 next_draw_is_resize_ = false; | |
297 host_->FinishAllRendering(); | |
298 } | |
299 #endif | |
300 | |
301 } | 288 } |
302 if (swap_state_ == SWAP_NONE) | 289 if (swap_state_ == SWAP_NONE) |
303 NotifyEnd(); | 290 NotifyEnd(); |
304 } | 291 } |
305 | 292 |
306 void Compositor::ScheduleFullRedraw() { | 293 void Compositor::ScheduleFullRedraw() { |
307 host_->SetNeedsRedraw(); | 294 host_->SetNeedsRedraw(); |
308 } | 295 } |
309 | 296 |
310 void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) { | 297 void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) { |
311 host_->SetNeedsRedrawRect(damage_rect); | 298 host_->SetNeedsRedrawRect(damage_rect); |
312 } | 299 } |
313 | 300 |
301 void Compositor::FinishAllRendering() { | |
302 host_->FinishAllRendering(); | |
303 } | |
304 | |
314 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { | 305 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { |
315 scoped_ptr<cc::SwapPromise> swap_promise( | 306 scoped_ptr<cc::SwapPromise> swap_promise( |
316 new cc::LatencyInfoSwapPromise(latency_info)); | 307 new cc::LatencyInfoSwapPromise(latency_info)); |
317 host_->QueueSwapPromise(swap_promise.Pass()); | 308 host_->QueueSwapPromise(swap_promise.Pass()); |
318 } | 309 } |
319 | 310 |
320 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { | 311 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { |
321 DCHECK_GT(scale, 0); | 312 DCHECK_GT(scale, 0); |
322 if (!size_in_pixel.IsEmpty()) { | 313 if (!size_in_pixel.IsEmpty()) { |
323 size_ = size_in_pixel; | 314 size_ = size_in_pixel; |
324 host_->SetViewportSize(size_in_pixel); | 315 host_->SetViewportSize(size_in_pixel); |
325 root_web_layer_->SetBounds(size_in_pixel); | 316 root_web_layer_->SetBounds(size_in_pixel); |
326 | |
327 next_draw_is_resize_ = true; | |
328 } | 317 } |
329 if (device_scale_factor_ != scale) { | 318 if (device_scale_factor_ != scale) { |
330 device_scale_factor_ = scale; | 319 device_scale_factor_ = scale; |
331 if (root_layer_) | 320 if (root_layer_) |
332 root_layer_->OnDeviceScaleFactorChanged(scale); | 321 root_layer_->OnDeviceScaleFactorChanged(scale); |
333 } | 322 } |
334 } | 323 } |
335 | 324 |
336 void Compositor::SetBackgroundColor(SkColor color) { | 325 void Compositor::SetBackgroundColor(SkColor color) { |
337 host_->set_background_color(color); | 326 host_->set_background_color(color); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 // CompositorObservers to be notified before starting another | 455 // CompositorObservers to be notified before starting another |
467 // draw cycle. | 456 // draw cycle. |
468 ScheduleDraw(); | 457 ScheduleDraw(); |
469 } | 458 } |
470 FOR_EACH_OBSERVER(CompositorObserver, | 459 FOR_EACH_OBSERVER(CompositorObserver, |
471 observer_list_, | 460 observer_list_, |
472 OnCompositingEnded(this)); | 461 OnCompositingEnded(this)); |
473 } | 462 } |
474 | 463 |
475 } // namespace ui | 464 } // namespace ui |
OLD | NEW |