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

Side by Side Diff: cc/single_thread_proxy.cc

Issue 12804006: cc: Save correct frame begin time to FrameRateCounter (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to 188402 Created 7 years, 9 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
« no previous file with comments | « cc/single_thread_proxy.h ('k') | cc/test/layer_tree_test_common.h » ('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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/single_thread_proxy.h" 5 #include "cc/single_thread_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/context_provider.h" 9 #include "cc/context_provider.h"
10 #include "cc/draw_quad.h" 10 #include "cc/draw_quad.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); 48 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy");
49 DCHECK(Proxy::IsMainThread()); 49 DCHECK(Proxy::IsMainThread());
50 DCHECK(!layer_tree_host_impl_.get() && 50 DCHECK(!layer_tree_host_impl_.get() &&
51 !layer_tree_host_); // make sure Stop() got called. 51 !layer_tree_host_); // make sure Stop() got called.
52 } 52 }
53 53
54 bool SingleThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) { 54 bool SingleThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) {
55 TRACE_EVENT0("cc", "SingleThreadProxy::compositeAndReadback"); 55 TRACE_EVENT0("cc", "SingleThreadProxy::compositeAndReadback");
56 DCHECK(Proxy::IsMainThread()); 56 DCHECK(Proxy::IsMainThread());
57 57
58 if (!CommitAndComposite()) 58 if (!CommitAndComposite(base::TimeTicks::Now()))
59 return false; 59 return false;
60 60
61 { 61 {
62 DebugScopedSetImplThread impl(this); 62 DebugScopedSetImplThread impl(this);
63 layer_tree_host_impl_->Readback(pixels, rect); 63 layer_tree_host_impl_->Readback(pixels, rect);
64 64
65 if (layer_tree_host_impl_->IsContextLost()) 65 if (layer_tree_host_impl_->IsContextLost())
66 return false; 66 return false;
67 67
68 layer_tree_host_impl_->SwapBuffers(); 68 layer_tree_host_impl_->SwapBuffers();
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 330
331 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } 331 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; }
332 332
333 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { 333 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() {
334 // Cause a commit so we can notice the lost context. 334 // Cause a commit so we can notice the lost context.
335 SetNeedsCommitOnImplThread(); 335 SetNeedsCommitOnImplThread();
336 } 336 }
337 337
338 // Called by the legacy scheduling path (e.g. where render_widget does the 338 // Called by the legacy scheduling path (e.g. where render_widget does the
339 // scheduling) 339 // scheduling)
340 void SingleThreadProxy::CompositeImmediately() { 340 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
341 if (CommitAndComposite()) { 341 if (CommitAndComposite(frame_begin_time)) {
342 layer_tree_host_impl_->SwapBuffers(); 342 layer_tree_host_impl_->SwapBuffers();
343 DidSwapFrame(); 343 DidSwapFrame();
344 } 344 }
345 } 345 }
346 346
347 scoped_ptr<base::Value> SingleThreadProxy::AsValue() const { 347 scoped_ptr<base::Value> SingleThreadProxy::AsValue() const {
348 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 348 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
349 { 349 {
350 // The following line casts away const modifiers because it is just 350 // The following line casts away const modifiers because it is just
351 // setting debug state. We still want the AsValue() function and its 351 // setting debug state. We still want the AsValue() function and its
352 // call chain to be const throughout. 352 // call chain to be const throughout.
353 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); 353 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this));
354 354
355 state->Set("layer_tree_host_impl", 355 state->Set("layer_tree_host_impl",
356 layer_tree_host_impl_->AsValue().release()); 356 layer_tree_host_impl_->AsValue().release());
357 } 357 }
358 return state.PassAs<base::Value>(); 358 return state.PassAs<base::Value>();
359 } 359 }
360 360
361 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { 361 void SingleThreadProxy::ForceSerializeOnSwapBuffers() {
362 { 362 {
363 DebugScopedSetImplThread impl(this); 363 DebugScopedSetImplThread impl(this);
364 if (renderer_initialized_) 364 if (renderer_initialized_)
365 layer_tree_host_impl_->renderer()->DoNoOp(); 365 layer_tree_host_impl_->renderer()->DoNoOp();
366 } 366 }
367 } 367 }
368 368
369 void SingleThreadProxy::OnSwapBuffersCompleteOnImplThread() { NOTREACHED(); } 369 void SingleThreadProxy::OnSwapBuffersCompleteOnImplThread() { NOTREACHED(); }
370 370
371 bool SingleThreadProxy::CommitAndComposite() { 371 bool SingleThreadProxy::CommitAndComposite(base::TimeTicks frame_begin_time) {
372 DCHECK(Proxy::IsMainThread()); 372 DCHECK(Proxy::IsMainThread());
373 373
374 if (!layer_tree_host_->InitializeRendererIfNeeded()) 374 if (!layer_tree_host_->InitializeRendererIfNeeded())
375 return false; 375 return false;
376 376
377 scoped_refptr<cc::ContextProvider> offscreen_context_provider; 377 scoped_refptr<cc::ContextProvider> offscreen_context_provider;
378 if (renderer_capabilities_for_main_thread_.using_offscreen_context3d && 378 if (renderer_capabilities_for_main_thread_.using_offscreen_context3d &&
379 layer_tree_host_->needs_offscreen_context()) { 379 layer_tree_host_->needs_offscreen_context()) {
380 offscreen_context_provider = 380 offscreen_context_provider =
381 layer_tree_host_->client()->OffscreenContextProviderForMainThread(); 381 layer_tree_host_->client()->OffscreenContextProviderForMainThread();
382 if (offscreen_context_provider->InitializeOnMainThread()) 382 if (offscreen_context_provider->InitializeOnMainThread())
383 created_offscreen_context_provider = true; 383 created_offscreen_context_provider = true;
384 else 384 else
385 offscreen_context_provider = NULL; 385 offscreen_context_provider = NULL;
386 } 386 }
387 387
388 layer_tree_host_->contents_texture_manager()->unlinkAndClearEvictedBackings(); 388 layer_tree_host_->contents_texture_manager()->unlinkAndClearEvictedBackings();
389 389
390 scoped_ptr<ResourceUpdateQueue> queue = 390 scoped_ptr<ResourceUpdateQueue> queue =
391 make_scoped_ptr(new ResourceUpdateQueue); 391 make_scoped_ptr(new ResourceUpdateQueue);
392 layer_tree_host_->UpdateLayers( 392 layer_tree_host_->UpdateLayers(
393 queue.get(), layer_tree_host_impl_->memory_allocation_limit_bytes()); 393 queue.get(), layer_tree_host_impl_->memory_allocation_limit_bytes());
394 394
395 layer_tree_host_->WillCommit(); 395 layer_tree_host_->WillCommit();
396 DoCommit(queue.Pass()); 396 DoCommit(queue.Pass());
397 bool result = DoComposite(offscreen_context_provider); 397 bool result = DoComposite(offscreen_context_provider, frame_begin_time);
398 layer_tree_host_->DidBeginFrame(); 398 layer_tree_host_->DidBeginFrame();
399 return result; 399 return result;
400 } 400 }
401 401
402 bool SingleThreadProxy::DoComposite( 402 bool SingleThreadProxy::DoComposite(
403 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { 403 scoped_refptr<cc::ContextProvider> offscreen_context_provider,
404 base::TimeTicks frame_begin_time) {
404 DCHECK(!output_surface_lost_); 405 DCHECK(!output_surface_lost_);
405 { 406 {
406 DebugScopedSetImplThread impl(this); 407 DebugScopedSetImplThread impl(this);
407 base::AutoReset<bool> mark_inside(&inside_draw_, true); 408 base::AutoReset<bool> mark_inside(&inside_draw_, true);
408 409
409 layer_tree_host_impl_->resource_provider()-> 410 layer_tree_host_impl_->resource_provider()->
410 SetOffscreenContextProvider(offscreen_context_provider); 411 SetOffscreenContextProvider(offscreen_context_provider);
411 412
412 if (!layer_tree_host_impl_->visible()) 413 if (!layer_tree_host_impl_->visible())
413 return false; 414 return false;
414 415
415 layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now()); 416 layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now());
416 417
417 // We guard prepareToDraw() with canDraw() because it always returns a valid 418 // We guard prepareToDraw() with canDraw() because it always returns a valid
418 // frame, so can only be used when such a frame is possible. Since 419 // frame, so can only be used when such a frame is possible. Since
419 // drawLayers() depends on the result of prepareToDraw(), it is guarded on 420 // drawLayers() depends on the result of prepareToDraw(), it is guarded on
420 // canDraw() as well. 421 // canDraw() as well.
421 if (!layer_tree_host_impl_->CanDraw()) 422 if (!layer_tree_host_impl_->CanDraw())
422 return false; 423 return false;
423 424
424 LayerTreeHostImpl::FrameData frame; 425 LayerTreeHostImpl::FrameData frame;
425 layer_tree_host_impl_->PrepareToDraw(&frame); 426 layer_tree_host_impl_->PrepareToDraw(&frame);
426 layer_tree_host_impl_->DrawLayers(&frame); 427 layer_tree_host_impl_->DrawLayers(&frame, frame_begin_time);
427 layer_tree_host_impl_->DidDrawAllLayers(frame); 428 layer_tree_host_impl_->DidDrawAllLayers(frame);
428 output_surface_lost_ = layer_tree_host_impl_->IsContextLost(); 429 output_surface_lost_ = layer_tree_host_impl_->IsContextLost();
429 430
430 layer_tree_host_impl_->BeginNextFrame(); 431 layer_tree_host_impl_->BeginNextFrame();
431 } 432 }
432 433
433 if (output_surface_lost_) { 434 if (output_surface_lost_) {
434 cc::ContextProvider* offscreen_contexts = layer_tree_host_impl_-> 435 cc::ContextProvider* offscreen_contexts = layer_tree_host_impl_->
435 resource_provider()->offscreen_context_provider(); 436 resource_provider()->offscreen_context_provider();
436 if (offscreen_contexts) 437 if (offscreen_contexts)
(...skipping 14 matching lines...) Expand all
451 452
452 bool SingleThreadProxy::CommitPendingForTesting() { return false; } 453 bool SingleThreadProxy::CommitPendingForTesting() { return false; }
453 454
454 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() { 455 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() {
455 // Impl-side painting only. 456 // Impl-side painting only.
456 NOTREACHED(); 457 NOTREACHED();
457 return skia::RefPtr<SkPicture>(); 458 return skia::RefPtr<SkPicture>();
458 } 459 }
459 460
460 } // namespace cc 461 } // namespace cc
OLDNEW
« no previous file with comments | « cc/single_thread_proxy.h ('k') | cc/test/layer_tree_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698