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

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 134623005: Make SingleThreadProxy a SchedulerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix cc_perftests; disable Windows DND tests Created 6 years, 4 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 "content/browser/renderer_host/compositor_impl_android.h" 5 #include "content/browser/renderer_host/compositor_impl_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 needs_composite_ = false; 307 needs_composite_ = false;
308 308
309 // Only allow compositing once per vsync. 309 // Only allow compositing once per vsync.
310 current_composite_task_->Cancel(); 310 current_composite_task_->Cancel();
311 DCHECK(DidCompositeThisFrame() && !WillComposite()); 311 DCHECK(DidCompositeThisFrame() && !WillComposite());
312 312
313 // Ignore ScheduleComposite() from layer tree changes during layout and 313 // Ignore ScheduleComposite() from layer tree changes during layout and
314 // animation updates that will already be reflected in the current frame 314 // animation updates that will already be reflected in the current frame
315 // we are about to draw. 315 // we are about to draw.
316 ignore_schedule_composite_ = true; 316 ignore_schedule_composite_ = true;
317 client_->Layout();
318 317
319 const base::TimeTicks frame_time = gfx::FrameTime::Now(); 318 const base::TimeTicks frame_time = gfx::FrameTime::Now();
320 if (needs_animate_) { 319 if (needs_animate_) {
321 needs_animate_ = false; 320 needs_animate_ = false;
322 root_window_->Animate(frame_time); 321 root_window_->Animate(frame_time);
323 } 322 }
324 ignore_schedule_composite_ = false; 323 ignore_schedule_composite_ = false;
325 324
326 did_post_swapbuffers_ = false; 325 did_post_swapbuffers_ = false;
327 host_->Composite(frame_time); 326 host_->Composite(frame_time);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 host_->Composite(base::TimeTicks::Now()); 414 host_->Composite(base::TimeTicks::Now());
416 ignore_schedule_composite_ = false; 415 ignore_schedule_composite_ = false;
417 } 416 }
418 if (WillComposite()) 417 if (WillComposite())
419 CancelComposite(); 418 CancelComposite();
420 ui_resource_provider_.SetLayerTreeHost(NULL); 419 ui_resource_provider_.SetLayerTreeHost(NULL);
421 host_.reset(); 420 host_.reset();
422 } else if (!host_) { 421 } else if (!host_) {
423 DCHECK(!WillComposite()); 422 DCHECK(!WillComposite());
424 needs_composite_ = false; 423 needs_composite_ = false;
425 needs_animate_ = false;
426 pending_swapbuffers_ = 0; 424 pending_swapbuffers_ = 0;
427 cc::LayerTreeSettings settings; 425 cc::LayerTreeSettings settings;
428 settings.refresh_rate = 60.0; 426 settings.refresh_rate = 60.0;
429 settings.impl_side_painting = false; 427 settings.impl_side_painting = false;
430 settings.allow_antialiasing = false; 428 settings.allow_antialiasing = false;
431 settings.calculate_top_controls_position = false; 429 settings.calculate_top_controls_position = false;
432 settings.top_controls_height = 0.f; 430 settings.top_controls_height = 0.f;
433 settings.highp_threshold_min = 2048; 431 settings.highp_threshold_min = 2048;
434 432
435 CommandLine* command_line = CommandLine::ForCurrentProcess(); 433 CommandLine* command_line = CommandLine::ForCurrentProcess();
436 settings.initial_debug_state.SetRecordRenderingStats( 434 settings.initial_debug_state.SetRecordRenderingStats(
437 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); 435 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking));
438 settings.initial_debug_state.show_fps_counter = 436 settings.initial_debug_state.show_fps_counter =
439 command_line->HasSwitch(cc::switches::kUIShowFPSCounter); 437 command_line->HasSwitch(cc::switches::kUIShowFPSCounter);
438 // TODO(enne): Update this this compositor to use the scheduler.
439 settings.single_thread_proxy_scheduler = false;
440 440
441 host_ = cc::LayerTreeHost::CreateSingleThreaded( 441 host_ = cc::LayerTreeHost::CreateSingleThreaded(
442 this, 442 this,
443 this, 443 this,
444 HostSharedBitmapManager::current(), 444 HostSharedBitmapManager::current(),
445 settings, 445 settings,
446 base::MessageLoopProxy::current()); 446 base::MessageLoopProxy::current());
447 host_->SetRootLayer(root_layer_); 447 host_->SetRootLayer(root_layer_);
448 448
449 host_->SetVisible(true); 449 host_->SetVisible(true);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 new WebGraphicsContext3DCommandBufferImpl(surface_id, 512 new WebGraphicsContext3DCommandBufferImpl(surface_id,
513 url, 513 url,
514 gpu_channel_host.get(), 514 gpu_channel_host.get(),
515 attributes, 515 attributes,
516 lose_context_when_out_of_memory, 516 lose_context_when_out_of_memory,
517 limits, 517 limits,
518 NULL)); 518 NULL));
519 } 519 }
520 520
521 void CompositorImpl::Layout() { 521 void CompositorImpl::Layout() {
522 // TODO: If we get this callback from the SingleThreadProxy, we need 522 ignore_schedule_composite_ = true;
523 // to stop calling it ourselves in CompositorImpl::Composite().
524 NOTREACHED();
525 client_->Layout(); 523 client_->Layout();
524 ignore_schedule_composite_ = false;
526 } 525 }
527 526
528 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( 527 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface(
529 bool fallback) { 528 bool fallback) {
530 blink::WebGraphicsContext3D::Attributes attrs; 529 blink::WebGraphicsContext3D::Attributes attrs;
531 attrs.shareResources = true; 530 attrs.shareResources = true;
532 attrs.noAutomaticFlushes = true; 531 attrs.noAutomaticFlushes = true;
533 pending_swapbuffers_ = 0; 532 pending_swapbuffers_ = 0;
534 533
535 DCHECK(window_); 534 DCHECK(window_);
(...skipping 28 matching lines...) Expand all
564 return; 563 return;
565 564
566 needs_composite_ = true; 565 needs_composite_ = true;
567 // We currently expect layer tree invalidations at most once per frame 566 // We currently expect layer tree invalidations at most once per frame
568 // during normal operation and therefore try to composite immediately 567 // during normal operation and therefore try to composite immediately
569 // to minimize latency. 568 // to minimize latency.
570 PostComposite(COMPOSITE_IMMEDIATELY); 569 PostComposite(COMPOSITE_IMMEDIATELY);
571 } 570 }
572 571
573 void CompositorImpl::ScheduleAnimation() { 572 void CompositorImpl::ScheduleAnimation() {
574 DCHECK(!needs_animate_ || needs_composite_);
575 DCHECK(!needs_composite_ || WillComposite()); 573 DCHECK(!needs_composite_ || WillComposite());
576 needs_animate_ = true; 574 needs_animate_ = true;
577 575
578 if (needs_composite_) 576 if (needs_composite_)
579 return; 577 return;
580 578
581 TRACE_EVENT0("cc", "CompositorImpl::ScheduleAnimation"); 579 TRACE_EVENT0("cc", "CompositorImpl::ScheduleAnimation");
582 needs_composite_ = true; 580 needs_composite_ = true;
583 PostComposite(COMPOSITE_EVENTUALLY); 581 PostComposite(COMPOSITE_EVENTUALLY);
584 } 582 }
585 583
586 void CompositorImpl::DidPostSwapBuffers() { 584 void CompositorImpl::DidPostSwapBuffers() {
587 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers"); 585 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers");
588 did_post_swapbuffers_ = true; 586 did_post_swapbuffers_ = true;
589 } 587 }
590 588
591 void CompositorImpl::DidCompleteSwapBuffers() { 589 void CompositorImpl::DidCompleteSwapBuffers() {
592 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers"); 590 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers");
593 DCHECK_GT(pending_swapbuffers_, 0U); 591 DCHECK_GT(pending_swapbuffers_, 0U);
594 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_) 592 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_)
595 PostComposite(COMPOSITE_IMMEDIATELY); 593 PostComposite(COMPOSITE_IMMEDIATELY);
596 client_->OnSwapBuffersCompleted(pending_swapbuffers_); 594 client_->OnSwapBuffersCompleted(pending_swapbuffers_);
597 } 595 }
598 596
599 void CompositorImpl::DidAbortSwapBuffers() { 597 void CompositorImpl::DidAbortSwapBuffers() {
600 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers"); 598 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers");
601 // This really gets called only once from 599 // This really gets called only once from
602 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the 600 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the
603 // context was lost. 601 // context was lost.
602 ScheduleComposite();
604 client_->OnSwapBuffersCompleted(0); 603 client_->OnSwapBuffersCompleted(0);
605 } 604 }
606 605
607 void CompositorImpl::DidCommit() { 606 void CompositorImpl::DidCommit() {
608 root_window_->OnCompositingDidCommit(); 607 root_window_->OnCompositingDidCommit();
609 } 608 }
610 609
611 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { 610 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) {
612 root_layer_->AddChild(layer); 611 root_layer_->AddChild(layer);
613 } 612 }
(...skipping 27 matching lines...) Expand all
641 } 640 }
642 641
643 void CompositorImpl::SetNeedsAnimate() { 642 void CompositorImpl::SetNeedsAnimate() {
644 if (!host_) 643 if (!host_)
645 return; 644 return;
646 645
647 host_->SetNeedsAnimate(); 646 host_->SetNeedsAnimate();
648 } 647 }
649 648
650 } // namespace content 649 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698