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

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: Mac browser compositor fixes Created 6 years, 5 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 399
401 void CompositorImpl::SetVisible(bool visible) { 400 void CompositorImpl::SetVisible(bool visible) {
402 if (!visible) { 401 if (!visible) {
403 if (WillComposite()) 402 if (WillComposite())
404 CancelComposite(); 403 CancelComposite();
405 ui_resource_provider_.SetLayerTreeHost(NULL); 404 ui_resource_provider_.SetLayerTreeHost(NULL);
406 host_.reset(); 405 host_.reset();
407 } else if (!host_) { 406 } else if (!host_) {
408 DCHECK(!WillComposite()); 407 DCHECK(!WillComposite());
409 needs_composite_ = false; 408 needs_composite_ = false;
410 needs_animate_ = false;
411 pending_swapbuffers_ = 0; 409 pending_swapbuffers_ = 0;
412 cc::LayerTreeSettings settings; 410 cc::LayerTreeSettings settings;
413 settings.refresh_rate = 60.0; 411 settings.refresh_rate = 60.0;
414 settings.impl_side_painting = false; 412 settings.impl_side_painting = false;
415 settings.allow_antialiasing = false; 413 settings.allow_antialiasing = false;
416 settings.calculate_top_controls_position = false; 414 settings.calculate_top_controls_position = false;
417 settings.top_controls_height = 0.f; 415 settings.top_controls_height = 0.f;
418 settings.highp_threshold_min = 2048; 416 settings.highp_threshold_min = 2048;
419 417
420 CommandLine* command_line = CommandLine::ForCurrentProcess(); 418 CommandLine* command_line = CommandLine::ForCurrentProcess();
421 settings.initial_debug_state.SetRecordRenderingStats( 419 settings.initial_debug_state.SetRecordRenderingStats(
422 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); 420 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking));
423 settings.initial_debug_state.show_fps_counter = 421 settings.initial_debug_state.show_fps_counter =
424 command_line->HasSwitch(cc::switches::kUIShowFPSCounter); 422 command_line->HasSwitch(cc::switches::kUIShowFPSCounter);
423 // TODO(enne): Update this this compositor to use the scheduler.
424 settings.single_thread_proxy_scheduler = false;
425 425
426 host_ = cc::LayerTreeHost::CreateSingleThreaded( 426 host_ = cc::LayerTreeHost::CreateSingleThreaded(
427 this, 427 this,
428 this, 428 this,
429 HostSharedBitmapManager::current(), 429 HostSharedBitmapManager::current(),
430 settings, 430 settings,
431 base::MessageLoopProxy::current()); 431 base::MessageLoopProxy::current());
432 host_->SetRootLayer(root_layer_); 432 host_->SetRootLayer(root_layer_);
433 433
434 host_->SetVisible(true); 434 host_->SetVisible(true);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 new WebGraphicsContext3DCommandBufferImpl(surface_id, 497 new WebGraphicsContext3DCommandBufferImpl(surface_id,
498 url, 498 url,
499 gpu_channel_host.get(), 499 gpu_channel_host.get(),
500 attributes, 500 attributes,
501 lose_context_when_out_of_memory, 501 lose_context_when_out_of_memory,
502 limits, 502 limits,
503 NULL)); 503 NULL));
504 } 504 }
505 505
506 void CompositorImpl::Layout() { 506 void CompositorImpl::Layout() {
507 // TODO: If we get this callback from the SingleThreadProxy, we need 507 ignore_schedule_composite_ = true;
508 // to stop calling it ourselves in CompositorImpl::Composite().
509 NOTREACHED();
510 client_->Layout(); 508 client_->Layout();
509 ignore_schedule_composite_ = false;
511 } 510 }
512 511
513 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( 512 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface(
514 bool fallback) { 513 bool fallback) {
515 blink::WebGraphicsContext3D::Attributes attrs; 514 blink::WebGraphicsContext3D::Attributes attrs;
516 attrs.shareResources = true; 515 attrs.shareResources = true;
517 attrs.noAutomaticFlushes = true; 516 attrs.noAutomaticFlushes = true;
518 pending_swapbuffers_ = 0; 517 pending_swapbuffers_ = 0;
519 518
520 DCHECK(window_); 519 DCHECK(window_);
(...skipping 28 matching lines...) Expand all
549 return; 548 return;
550 549
551 needs_composite_ = true; 550 needs_composite_ = true;
552 // We currently expect layer tree invalidations at most once per frame 551 // We currently expect layer tree invalidations at most once per frame
553 // during normal operation and therefore try to composite immediately 552 // during normal operation and therefore try to composite immediately
554 // to minimize latency. 553 // to minimize latency.
555 PostComposite(COMPOSITE_IMMEDIATELY); 554 PostComposite(COMPOSITE_IMMEDIATELY);
556 } 555 }
557 556
558 void CompositorImpl::ScheduleAnimation() { 557 void CompositorImpl::ScheduleAnimation() {
559 DCHECK(!needs_animate_ || needs_composite_);
560 DCHECK(!needs_composite_ || WillComposite()); 558 DCHECK(!needs_composite_ || WillComposite());
561 needs_animate_ = true; 559 needs_animate_ = true;
562 560
563 if (needs_composite_) 561 if (needs_composite_)
564 return; 562 return;
565 563
566 TRACE_EVENT0("cc", "CompositorImpl::ScheduleAnimation"); 564 TRACE_EVENT0("cc", "CompositorImpl::ScheduleAnimation");
567 needs_composite_ = true; 565 needs_composite_ = true;
568 PostComposite(COMPOSITE_EVENTUALLY); 566 PostComposite(COMPOSITE_EVENTUALLY);
569 } 567 }
570 568
571 void CompositorImpl::DidPostSwapBuffers() { 569 void CompositorImpl::DidPostSwapBuffers() {
572 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers"); 570 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers");
573 did_post_swapbuffers_ = true; 571 did_post_swapbuffers_ = true;
574 } 572 }
575 573
576 void CompositorImpl::DidCompleteSwapBuffers() { 574 void CompositorImpl::DidCompleteSwapBuffers() {
577 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers"); 575 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers");
578 DCHECK_GT(pending_swapbuffers_, 0U); 576 DCHECK_GT(pending_swapbuffers_, 0U);
579 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_) 577 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_)
580 PostComposite(COMPOSITE_IMMEDIATELY); 578 PostComposite(COMPOSITE_IMMEDIATELY);
581 client_->OnSwapBuffersCompleted(pending_swapbuffers_); 579 client_->OnSwapBuffersCompleted(pending_swapbuffers_);
582 } 580 }
583 581
584 void CompositorImpl::DidAbortSwapBuffers() { 582 void CompositorImpl::DidAbortSwapBuffers() {
585 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers"); 583 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers");
586 // This really gets called only once from 584 // This really gets called only once from
587 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the 585 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the
588 // context was lost. 586 // context was lost.
587 ScheduleComposite();
589 client_->OnSwapBuffersCompleted(0); 588 client_->OnSwapBuffersCompleted(0);
590 } 589 }
591 590
592 void CompositorImpl::DidCommit() { 591 void CompositorImpl::DidCommit() {
593 root_window_->OnCompositingDidCommit(); 592 root_window_->OnCompositingDidCommit();
594 } 593 }
595 594
596 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { 595 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) {
597 root_layer_->AddChild(layer); 596 root_layer_->AddChild(layer);
598 } 597 }
(...skipping 27 matching lines...) Expand all
626 } 625 }
627 626
628 void CompositorImpl::SetNeedsAnimate() { 627 void CompositorImpl::SetNeedsAnimate() {
629 if (!host_) 628 if (!host_)
630 return; 629 return;
631 630
632 host_->SetNeedsAnimate(); 631 host_->SetNeedsAnimate();
633 } 632 }
634 633
635 } // namespace content 634 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698