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

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

Issue 441343002: Revert 287747 "Make SingleThreadProxy a SchedulerClient" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
« no previous file with comments | « trunk/src/cc/trees/thread_proxy.cc ('k') | trunk/src/content/public/common/content_switches.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 (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();
317 318
318 const base::TimeTicks frame_time = gfx::FrameTime::Now(); 319 const base::TimeTicks frame_time = gfx::FrameTime::Now();
319 if (needs_animate_) { 320 if (needs_animate_) {
320 needs_animate_ = false; 321 needs_animate_ = false;
321 root_window_->Animate(frame_time); 322 root_window_->Animate(frame_time);
322 } 323 }
323 ignore_schedule_composite_ = false; 324 ignore_schedule_composite_ = false;
324 325
325 did_post_swapbuffers_ = false; 326 did_post_swapbuffers_ = false;
326 host_->Composite(frame_time); 327 host_->Composite(frame_time);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 host_->Composite(base::TimeTicks::Now()); 415 host_->Composite(base::TimeTicks::Now());
415 ignore_schedule_composite_ = false; 416 ignore_schedule_composite_ = false;
416 } 417 }
417 if (WillComposite()) 418 if (WillComposite())
418 CancelComposite(); 419 CancelComposite();
419 ui_resource_provider_.SetLayerTreeHost(NULL); 420 ui_resource_provider_.SetLayerTreeHost(NULL);
420 host_.reset(); 421 host_.reset();
421 } else if (!host_) { 422 } else if (!host_) {
422 DCHECK(!WillComposite()); 423 DCHECK(!WillComposite());
423 needs_composite_ = false; 424 needs_composite_ = false;
425 needs_animate_ = false;
424 pending_swapbuffers_ = 0; 426 pending_swapbuffers_ = 0;
425 cc::LayerTreeSettings settings; 427 cc::LayerTreeSettings settings;
426 settings.refresh_rate = 60.0; 428 settings.refresh_rate = 60.0;
427 settings.impl_side_painting = false; 429 settings.impl_side_painting = false;
428 settings.allow_antialiasing = false; 430 settings.allow_antialiasing = false;
429 settings.calculate_top_controls_position = false; 431 settings.calculate_top_controls_position = false;
430 settings.top_controls_height = 0.f; 432 settings.top_controls_height = 0.f;
431 settings.highp_threshold_min = 2048; 433 settings.highp_threshold_min = 2048;
432 434
433 CommandLine* command_line = CommandLine::ForCurrentProcess(); 435 CommandLine* command_line = CommandLine::ForCurrentProcess();
434 settings.initial_debug_state.SetRecordRenderingStats( 436 settings.initial_debug_state.SetRecordRenderingStats(
435 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); 437 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking));
436 settings.initial_debug_state.show_fps_counter = 438 settings.initial_debug_state.show_fps_counter =
437 command_line->HasSwitch(cc::switches::kUIShowFPSCounter); 439 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 ignore_schedule_composite_ = true; 522 // TODO: If we get this callback from the SingleThreadProxy, we need
523 // to stop calling it ourselves in CompositorImpl::Composite().
524 NOTREACHED();
523 client_->Layout(); 525 client_->Layout();
524 ignore_schedule_composite_ = false;
525 } 526 }
526 527
527 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( 528 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface(
528 bool fallback) { 529 bool fallback) {
529 blink::WebGraphicsContext3D::Attributes attrs; 530 blink::WebGraphicsContext3D::Attributes attrs;
530 attrs.shareResources = true; 531 attrs.shareResources = true;
531 attrs.noAutomaticFlushes = true; 532 attrs.noAutomaticFlushes = true;
532 pending_swapbuffers_ = 0; 533 pending_swapbuffers_ = 0;
533 534
534 DCHECK(window_); 535 DCHECK(window_);
(...skipping 28 matching lines...) Expand all
563 return; 564 return;
564 565
565 needs_composite_ = true; 566 needs_composite_ = true;
566 // We currently expect layer tree invalidations at most once per frame 567 // We currently expect layer tree invalidations at most once per frame
567 // during normal operation and therefore try to composite immediately 568 // during normal operation and therefore try to composite immediately
568 // to minimize latency. 569 // to minimize latency.
569 PostComposite(COMPOSITE_IMMEDIATELY); 570 PostComposite(COMPOSITE_IMMEDIATELY);
570 } 571 }
571 572
572 void CompositorImpl::ScheduleAnimation() { 573 void CompositorImpl::ScheduleAnimation() {
574 DCHECK(!needs_animate_ || needs_composite_);
573 DCHECK(!needs_composite_ || WillComposite()); 575 DCHECK(!needs_composite_ || WillComposite());
574 needs_animate_ = true; 576 needs_animate_ = true;
575 577
576 if (needs_composite_) 578 if (needs_composite_)
577 return; 579 return;
578 580
579 TRACE_EVENT0("cc", "CompositorImpl::ScheduleAnimation"); 581 TRACE_EVENT0("cc", "CompositorImpl::ScheduleAnimation");
580 needs_composite_ = true; 582 needs_composite_ = true;
581 PostComposite(COMPOSITE_EVENTUALLY); 583 PostComposite(COMPOSITE_EVENTUALLY);
582 } 584 }
583 585
584 void CompositorImpl::DidPostSwapBuffers() { 586 void CompositorImpl::DidPostSwapBuffers() {
585 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers"); 587 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers");
586 did_post_swapbuffers_ = true; 588 did_post_swapbuffers_ = true;
587 } 589 }
588 590
589 void CompositorImpl::DidCompleteSwapBuffers() { 591 void CompositorImpl::DidCompleteSwapBuffers() {
590 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers"); 592 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers");
591 DCHECK_GT(pending_swapbuffers_, 0U); 593 DCHECK_GT(pending_swapbuffers_, 0U);
592 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_) 594 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_)
593 PostComposite(COMPOSITE_IMMEDIATELY); 595 PostComposite(COMPOSITE_IMMEDIATELY);
594 client_->OnSwapBuffersCompleted(pending_swapbuffers_); 596 client_->OnSwapBuffersCompleted(pending_swapbuffers_);
595 } 597 }
596 598
597 void CompositorImpl::DidAbortSwapBuffers() { 599 void CompositorImpl::DidAbortSwapBuffers() {
598 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers"); 600 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers");
599 // This really gets called only once from 601 // This really gets called only once from
600 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the 602 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the
601 // context was lost. 603 // context was lost.
602 ScheduleComposite();
603 client_->OnSwapBuffersCompleted(0); 604 client_->OnSwapBuffersCompleted(0);
604 } 605 }
605 606
606 void CompositorImpl::DidCommit() { 607 void CompositorImpl::DidCommit() {
607 root_window_->OnCompositingDidCommit(); 608 root_window_->OnCompositingDidCommit();
608 } 609 }
609 610
610 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { 611 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) {
611 root_layer_->AddChild(layer); 612 root_layer_->AddChild(layer);
612 } 613 }
(...skipping 27 matching lines...) Expand all
640 } 641 }
641 642
642 void CompositorImpl::SetNeedsAnimate() { 643 void CompositorImpl::SetNeedsAnimate() {
643 if (!host_) 644 if (!host_)
644 return; 645 return;
645 646
646 host_->SetNeedsAnimate(); 647 host_->SetNeedsAnimate();
647 } 648 }
648 649
649 } // namespace content 650 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/cc/trees/thread_proxy.cc ('k') | trunk/src/content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698