Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 settings.allow_antialiasing = false; | 409 settings.allow_antialiasing = false; |
| 411 settings.calculate_top_controls_position = false; | 410 settings.calculate_top_controls_position = false; |
| 412 settings.top_controls_height = 0.f; | 411 settings.top_controls_height = 0.f; |
| 413 settings.highp_threshold_min = 2048; | 412 settings.highp_threshold_min = 2048; |
| 414 | 413 |
| 415 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 414 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 416 settings.initial_debug_state.SetRecordRenderingStats( | 415 settings.initial_debug_state.SetRecordRenderingStats( |
| 417 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); | 416 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); |
| 418 settings.initial_debug_state.show_fps_counter = | 417 settings.initial_debug_state.show_fps_counter = |
| 419 command_line->HasSwitch(cc::switches::kUIShowFPSCounter); | 418 command_line->HasSwitch(cc::switches::kUIShowFPSCounter); |
| 419 // TODO(enne): Update this this compositor to use the scheduler. | |
| 420 settings.single_thread_proxy_scheduler = false; | |
| 420 | 421 |
| 421 host_ = cc::LayerTreeHost::CreateSingleThreaded( | 422 host_ = cc::LayerTreeHost::CreateSingleThreaded( |
| 422 this, this, HostSharedBitmapManager::current(), settings); | 423 this, this, HostSharedBitmapManager::current(), settings); |
| 423 host_->SetRootLayer(root_layer_); | 424 host_->SetRootLayer(root_layer_); |
| 424 | 425 |
| 425 host_->SetVisible(true); | 426 host_->SetVisible(true); |
| 426 host_->SetLayerTreeHostClientReady(); | 427 host_->SetLayerTreeHostClientReady(); |
| 427 host_->SetViewportSize(size_); | 428 host_->SetViewportSize(size_); |
| 428 host_->set_has_transparent_background(has_transparent_background_); | 429 host_->set_has_transparent_background(has_transparent_background_); |
| 429 host_->SetDeviceScaleFactor(device_scale_factor_); | 430 host_->SetDeviceScaleFactor(device_scale_factor_); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 new WebGraphicsContext3DCommandBufferImpl(surface_id, | 489 new WebGraphicsContext3DCommandBufferImpl(surface_id, |
| 489 url, | 490 url, |
| 490 gpu_channel_host.get(), | 491 gpu_channel_host.get(), |
| 491 attributes, | 492 attributes, |
| 492 lose_context_when_out_of_memory, | 493 lose_context_when_out_of_memory, |
| 493 limits, | 494 limits, |
| 494 NULL)); | 495 NULL)); |
| 495 } | 496 } |
| 496 | 497 |
| 497 void CompositorImpl::Layout() { | 498 void CompositorImpl::Layout() { |
| 498 // TODO: If we get this callback from the SingleThreadProxy, we need | 499 ignore_schedule_composite_ = true; |
| 499 // to stop calling it ourselves in CompositorImpl::Composite(). | |
| 500 NOTREACHED(); | |
| 501 client_->Layout(); | 500 client_->Layout(); |
| 501 ignore_schedule_composite_ = false; | |
| 502 } | 502 } |
| 503 | 503 |
| 504 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( | 504 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( |
| 505 bool fallback) { | 505 bool fallback) { |
| 506 blink::WebGraphicsContext3D::Attributes attrs; | 506 blink::WebGraphicsContext3D::Attributes attrs; |
| 507 attrs.shareResources = true; | 507 attrs.shareResources = true; |
| 508 attrs.noAutomaticFlushes = true; | 508 attrs.noAutomaticFlushes = true; |
| 509 pending_swapbuffers_ = 0; | 509 pending_swapbuffers_ = 0; |
| 510 | 510 |
| 511 DCHECK(window_); | 511 DCHECK(window_); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_) | 570 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_) |
| 571 PostComposite(COMPOSITE_IMMEDIATELY); | 571 PostComposite(COMPOSITE_IMMEDIATELY); |
| 572 client_->OnSwapBuffersCompleted(pending_swapbuffers_); | 572 client_->OnSwapBuffersCompleted(pending_swapbuffers_); |
| 573 } | 573 } |
| 574 | 574 |
| 575 void CompositorImpl::DidAbortSwapBuffers() { | 575 void CompositorImpl::DidAbortSwapBuffers() { |
| 576 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers"); | 576 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers"); |
| 577 // This really gets called only once from | 577 // This really gets called only once from |
| 578 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the | 578 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the |
| 579 // context was lost. | 579 // context was lost. |
| 580 ScheduleComposite(); | |
|
danakj
2014/06/19 17:20:36
How come this is needed now?
enne (OOO)
2014/06/19 20:32:28
This is the equivalent of the removed lines in voi
| |
| 580 client_->OnSwapBuffersCompleted(0); | 581 client_->OnSwapBuffersCompleted(0); |
| 581 } | 582 } |
| 582 | 583 |
| 583 void CompositorImpl::DidCommit() { | 584 void CompositorImpl::DidCommit() { |
| 584 root_window_->OnCompositingDidCommit(); | 585 root_window_->OnCompositingDidCommit(); |
| 585 } | 586 } |
| 586 | 587 |
| 587 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { | 588 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { |
| 588 root_layer_->AddChild(layer); | 589 root_layer_->AddChild(layer); |
| 589 } | 590 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 617 } | 618 } |
| 618 | 619 |
| 619 void CompositorImpl::SetNeedsAnimate() { | 620 void CompositorImpl::SetNeedsAnimate() { |
| 620 if (!host_) | 621 if (!host_) |
| 621 return; | 622 return; |
| 622 | 623 |
| 623 host_->SetNeedsAnimate(); | 624 host_->SetNeedsAnimate(); |
| 624 } | 625 } |
| 625 | 626 |
| 626 } // namespace content | 627 } // namespace content |
| OLD | NEW |