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

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

Issue 311783002: Revert r274404 and r274409: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/sys_info.h" 16 #include "base/sys_info.h"
17 #include "cc/base/latency_info_swap_promise.h" 17 #include "cc/base/latency_info_swap_promise.h"
18 #include "cc/base/switches.h" 18 #include "cc/base/switches.h"
19 #include "cc/input/input_handler.h" 19 #include "cc/input/input_handler.h"
20 #include "cc/layers/layer.h" 20 #include "cc/layers/layer.h"
21 #include "cc/output/context_provider.h" 21 #include "cc/output/context_provider.h"
22 #include "cc/trees/layer_tree_host.h" 22 #include "cc/trees/layer_tree_host.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 23 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "ui/compositor/compositor_observer.h" 24 #include "ui/compositor/compositor_observer.h"
25 #include "ui/compositor/compositor_switches.h" 25 #include "ui/compositor/compositor_switches.h"
26 #include "ui/compositor/compositor_vsync_manager.h" 26 #include "ui/compositor/compositor_vsync_manager.h"
27 #include "ui/compositor/dip_util.h" 27 #include "ui/compositor/dip_util.h"
28 #include "ui/compositor/layer.h" 28 #include "ui/compositor/layer.h"
29 #include "ui/compositor/layer_animator_collection.h"
30 #include "ui/gfx/frame_time.h" 29 #include "ui/gfx/frame_time.h"
31 #include "ui/gl/gl_context.h" 30 #include "ui/gl/gl_context.h"
32 #include "ui/gl/gl_switches.h" 31 #include "ui/gl/gl_switches.h"
33 32
34 namespace { 33 namespace {
35 34
36 const double kDefaultRefreshRate = 60.0; 35 const double kDefaultRefreshRate = 60.0;
37 const double kTestRefreshRate = 200.0; 36 const double kTestRefreshRate = 200.0;
38 37
39 const int kCompositorLockTimeoutMs = 67; 38 const int kCompositorLockTimeoutMs = 67;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 vsync_manager_(new CompositorVSyncManager()), 77 vsync_manager_(new CompositorVSyncManager()),
79 device_scale_factor_(0.0f), 78 device_scale_factor_(0.0f),
80 last_started_frame_(0), 79 last_started_frame_(0),
81 last_ended_frame_(0), 80 last_ended_frame_(0),
82 disable_schedule_composite_(false), 81 disable_schedule_composite_(false),
83 compositor_lock_(NULL), 82 compositor_lock_(NULL),
84 defer_draw_scheduling_(false), 83 defer_draw_scheduling_(false),
85 waiting_on_compositing_end_(false), 84 waiting_on_compositing_end_(false),
86 draw_on_compositing_end_(false), 85 draw_on_compositing_end_(false),
87 swap_state_(SWAP_NONE), 86 swap_state_(SWAP_NONE),
88 layer_animator_collection_(this),
89 schedule_draw_factory_(this) { 87 schedule_draw_factory_(this) {
90 root_web_layer_ = cc::Layer::Create(); 88 root_web_layer_ = cc::Layer::Create();
91 root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); 89 root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f));
92 90
93 CommandLine* command_line = CommandLine::ForCurrentProcess(); 91 CommandLine* command_line = CommandLine::ForCurrentProcess();
94 92
95 cc::LayerTreeSettings settings; 93 cc::LayerTreeSettings settings;
96 settings.refresh_rate = 94 settings.refresh_rate =
97 context_factory_->DoesCreateTestContexts() 95 context_factory_->DoesCreateTestContexts()
98 ? kTestRefreshRate 96 ? kTestRefreshRate
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (!root_layer_) 210 if (!root_layer_)
213 return; 211 return;
214 212
215 DCHECK_NE(swap_state_, SWAP_POSTED); 213 DCHECK_NE(swap_state_, SWAP_POSTED);
216 swap_state_ = SWAP_NONE; 214 swap_state_ = SWAP_NONE;
217 215
218 last_started_frame_++; 216 last_started_frame_++;
219 if (!IsLocked()) { 217 if (!IsLocked()) {
220 // TODO(nduca): Temporary while compositor calls 218 // TODO(nduca): Temporary while compositor calls
221 // compositeImmediately() directly. 219 // compositeImmediately() directly.
222 base::TimeTicks now = gfx::FrameTime::Now();
223 Animate(now);
224 Layout(); 220 Layout();
225 host_->Composite(now); 221 host_->Composite(gfx::FrameTime::Now());
226 } 222 }
227 if (swap_state_ == SWAP_NONE) 223 if (swap_state_ == SWAP_NONE)
228 NotifyEnd(); 224 NotifyEnd();
229 } 225 }
230 226
231 void Compositor::ScheduleFullRedraw() { 227 void Compositor::ScheduleFullRedraw() {
232 host_->SetNeedsRedraw(); 228 host_->SetNeedsRedraw();
233 } 229 }
234 230
235 void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) { 231 void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 271 }
276 272
277 void Compositor::RemoveObserver(CompositorObserver* observer) { 273 void Compositor::RemoveObserver(CompositorObserver* observer) {
278 observer_list_.RemoveObserver(observer); 274 observer_list_.RemoveObserver(observer);
279 } 275 }
280 276
281 bool Compositor::HasObserver(CompositorObserver* observer) { 277 bool Compositor::HasObserver(CompositorObserver* observer) {
282 return observer_list_.HasObserver(observer); 278 return observer_list_.HasObserver(observer);
283 } 279 }
284 280
285 void Compositor::Animate(base::TimeTicks frame_begin_time) {
286 layer_animator_collection_.Progress(frame_begin_time);
287 if (layer_animator_collection_.HasActiveAnimators())
288 host_->SetNeedsAnimate();
289 }
290
291 void Compositor::Layout() { 281 void Compositor::Layout() {
292 // We're sending damage that will be addressed during this composite 282 // We're sending damage that will be addressed during this composite
293 // cycle, so we don't need to schedule another composite to address it. 283 // cycle, so we don't need to schedule another composite to address it.
294 disable_schedule_composite_ = true; 284 disable_schedule_composite_ = true;
295 if (root_layer_) 285 if (root_layer_)
296 root_layer_->SendDamagedRects(); 286 root_layer_->SendDamagedRects();
297 disable_schedule_composite_ = false; 287 disable_schedule_composite_ = false;
298 } 288 }
299 289
300 scoped_ptr<cc::OutputSurface> Compositor::CreateOutputSurface(bool fallback) { 290 scoped_ptr<cc::OutputSurface> Compositor::CreateOutputSurface(bool fallback) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 NotifyEnd(); 336 NotifyEnd();
347 swap_state_ = SWAP_COMPLETED; 337 swap_state_ = SWAP_COMPLETED;
348 } 338 }
349 } 339 }
350 340
351 FOR_EACH_OBSERVER(CompositorObserver, 341 FOR_EACH_OBSERVER(CompositorObserver,
352 observer_list_, 342 observer_list_,
353 OnCompositingAborted(this)); 343 OnCompositingAborted(this));
354 } 344 }
355 345
356 void Compositor::ScheduleAnimationForLayerCollection() {
357 host_->SetNeedsAnimate();
358 }
359
360 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { 346 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const {
361 return host_->debug_state(); 347 return host_->debug_state();
362 } 348 }
363 349
364 void Compositor::SetLayerTreeDebugState( 350 void Compositor::SetLayerTreeDebugState(
365 const cc::LayerTreeDebugState& debug_state) { 351 const cc::LayerTreeDebugState& debug_state) {
366 host_->SetDebugState(debug_state); 352 host_->SetDebugState(debug_state);
367 } 353 }
368 354
369 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { 355 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // CompositorObservers to be notified before starting another 390 // CompositorObservers to be notified before starting another
405 // draw cycle. 391 // draw cycle.
406 ScheduleDraw(); 392 ScheduleDraw();
407 } 393 }
408 FOR_EACH_OBSERVER(CompositorObserver, 394 FOR_EACH_OBSERVER(CompositorObserver,
409 observer_list_, 395 observer_list_,
410 OnCompositingEnded(this)); 396 OnCompositingEnded(this));
411 } 397 }
412 398
413 } // namespace ui 399 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698