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

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: Suppress SetLayerTreeHostClientReady in tests 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 394
396 void CompositorImpl::SetVisible(bool visible) { 395 void CompositorImpl::SetVisible(bool visible) {
397 if (!visible) { 396 if (!visible) {
398 if (WillComposite()) 397 if (WillComposite())
399 CancelComposite(); 398 CancelComposite();
400 ui_resource_provider_.SetLayerTreeHost(NULL); 399 ui_resource_provider_.SetLayerTreeHost(NULL);
401 host_.reset(); 400 host_.reset();
402 } else if (!host_) { 401 } else if (!host_) {
403 DCHECK(!WillComposite()); 402 DCHECK(!WillComposite());
404 needs_composite_ = false; 403 needs_composite_ = false;
405 needs_animate_ = false;
406 pending_swapbuffers_ = 0; 404 pending_swapbuffers_ = 0;
407 cc::LayerTreeSettings settings; 405 cc::LayerTreeSettings settings;
408 settings.refresh_rate = 60.0; 406 settings.refresh_rate = 60.0;
409 settings.impl_side_painting = false; 407 settings.impl_side_painting = false;
410 settings.allow_antialiasing = false; 408 settings.allow_antialiasing = false;
411 settings.calculate_top_controls_position = false; 409 settings.calculate_top_controls_position = false;
412 settings.top_controls_height = 0.f; 410 settings.top_controls_height = 0.f;
413 settings.highp_threshold_min = 2048; 411 settings.highp_threshold_min = 2048;
414 412
415 CommandLine* command_line = CommandLine::ForCurrentProcess(); 413 CommandLine* command_line = CommandLine::ForCurrentProcess();
416 settings.initial_debug_state.SetRecordRenderingStats( 414 settings.initial_debug_state.SetRecordRenderingStats(
417 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); 415 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking));
418 settings.initial_debug_state.show_fps_counter = 416 settings.initial_debug_state.show_fps_counter =
419 command_line->HasSwitch(cc::switches::kUIShowFPSCounter); 417 command_line->HasSwitch(cc::switches::kUIShowFPSCounter);
418 // TODO(enne): Update this this compositor to use the scheduler.
419 settings.single_thread_proxy_scheduler = false;
420 420
421 host_ = cc::LayerTreeHost::CreateSingleThreaded( 421 host_ = cc::LayerTreeHost::CreateSingleThreaded(
422 this, this, HostSharedBitmapManager::current(), settings); 422 this, this, HostSharedBitmapManager::current(), settings);
423 host_->SetRootLayer(root_layer_); 423 host_->SetRootLayer(root_layer_);
424 424
425 host_->SetVisible(true); 425 host_->SetVisible(true);
426 host_->SetLayerTreeHostClientReady(); 426 host_->SetLayerTreeHostClientReady();
427 host_->SetViewportSize(size_); 427 host_->SetViewportSize(size_);
428 host_->set_has_transparent_background(has_transparent_background_); 428 host_->set_has_transparent_background(has_transparent_background_);
429 host_->SetDeviceScaleFactor(device_scale_factor_); 429 host_->SetDeviceScaleFactor(device_scale_factor_);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 new WebGraphicsContext3DCommandBufferImpl(surface_id, 488 new WebGraphicsContext3DCommandBufferImpl(surface_id,
489 url, 489 url,
490 gpu_channel_host.get(), 490 gpu_channel_host.get(),
491 attributes, 491 attributes,
492 lose_context_when_out_of_memory, 492 lose_context_when_out_of_memory,
493 limits, 493 limits,
494 NULL)); 494 NULL));
495 } 495 }
496 496
497 void CompositorImpl::Layout() { 497 void CompositorImpl::Layout() {
498 // TODO: If we get this callback from the SingleThreadProxy, we need 498 ignore_schedule_composite_ = true;
499 // to stop calling it ourselves in CompositorImpl::Composite().
500 NOTREACHED();
501 client_->Layout(); 499 client_->Layout();
500 ignore_schedule_composite_ = false;
502 } 501 }
503 502
504 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( 503 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface(
505 bool fallback) { 504 bool fallback) {
506 blink::WebGraphicsContext3D::Attributes attrs; 505 blink::WebGraphicsContext3D::Attributes attrs;
507 attrs.shareResources = true; 506 attrs.shareResources = true;
508 attrs.noAutomaticFlushes = true; 507 attrs.noAutomaticFlushes = true;
509 pending_swapbuffers_ = 0; 508 pending_swapbuffers_ = 0;
510 509
511 DCHECK(window_); 510 DCHECK(window_);
(...skipping 28 matching lines...) Expand all
540 return; 539 return;
541 540
542 needs_composite_ = true; 541 needs_composite_ = true;
543 // We currently expect layer tree invalidations at most once per frame 542 // We currently expect layer tree invalidations at most once per frame
544 // during normal operation and therefore try to composite immediately 543 // during normal operation and therefore try to composite immediately
545 // to minimize latency. 544 // to minimize latency.
546 PostComposite(COMPOSITE_IMMEDIATELY); 545 PostComposite(COMPOSITE_IMMEDIATELY);
547 } 546 }
548 547
549 void CompositorImpl::ScheduleAnimation() { 548 void CompositorImpl::ScheduleAnimation() {
550 DCHECK(!needs_animate_ || needs_composite_);
551 DCHECK(!needs_composite_ || WillComposite()); 549 DCHECK(!needs_composite_ || WillComposite());
552 needs_animate_ = true; 550 needs_animate_ = true;
553 551
554 if (needs_composite_) 552 if (needs_composite_)
555 return; 553 return;
556 554
557 TRACE_EVENT0("cc", "CompositorImpl::ScheduleAnimation"); 555 TRACE_EVENT0("cc", "CompositorImpl::ScheduleAnimation");
558 needs_composite_ = true; 556 needs_composite_ = true;
559 PostComposite(COMPOSITE_EVENTUALLY); 557 PostComposite(COMPOSITE_EVENTUALLY);
560 } 558 }
561 559
562 void CompositorImpl::DidPostSwapBuffers() { 560 void CompositorImpl::DidPostSwapBuffers() {
563 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers"); 561 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers");
564 did_post_swapbuffers_ = true; 562 did_post_swapbuffers_ = true;
565 } 563 }
566 564
567 void CompositorImpl::DidCompleteSwapBuffers() { 565 void CompositorImpl::DidCompleteSwapBuffers() {
568 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers"); 566 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers");
569 DCHECK_GT(pending_swapbuffers_, 0U); 567 DCHECK_GT(pending_swapbuffers_, 0U);
570 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_) 568 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_)
571 PostComposite(COMPOSITE_IMMEDIATELY); 569 PostComposite(COMPOSITE_IMMEDIATELY);
572 client_->OnSwapBuffersCompleted(pending_swapbuffers_); 570 client_->OnSwapBuffersCompleted(pending_swapbuffers_);
573 } 571 }
574 572
575 void CompositorImpl::DidAbortSwapBuffers() { 573 void CompositorImpl::DidAbortSwapBuffers() {
576 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers"); 574 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers");
577 // This really gets called only once from 575 // This really gets called only once from
578 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the 576 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the
579 // context was lost. 577 // context was lost.
578 ScheduleComposite();
580 client_->OnSwapBuffersCompleted(0); 579 client_->OnSwapBuffersCompleted(0);
581 } 580 }
582 581
583 void CompositorImpl::DidCommit() { 582 void CompositorImpl::DidCommit() {
584 root_window_->OnCompositingDidCommit(); 583 root_window_->OnCompositingDidCommit();
585 } 584 }
586 585
587 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { 586 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) {
588 root_layer_->AddChild(layer); 587 root_layer_->AddChild(layer);
589 } 588 }
(...skipping 27 matching lines...) Expand all
617 } 616 }
618 617
619 void CompositorImpl::SetNeedsAnimate() { 618 void CompositorImpl::SetNeedsAnimate() {
620 if (!host_) 619 if (!host_)
621 return; 620 return;
622 621
623 host_->SetNeedsAnimate(); 622 host_->SetNeedsAnimate();
624 } 623 }
625 624
626 } // namespace content 625 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698