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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 // Unretained because we cancel the task on shutdown. | 291 // Unretained because we cancel the task on shutdown. |
292 current_composite_task_.reset(new base::CancelableClosure( | 292 current_composite_task_.reset(new base::CancelableClosure( |
293 base::Bind(&CompositorImpl::Composite, base::Unretained(this), trigger))); | 293 base::Bind(&CompositorImpl::Composite, base::Unretained(this), trigger))); |
294 base::MessageLoop::current()->PostDelayedTask( | 294 base::MessageLoop::current()->PostDelayedTask( |
295 FROM_HERE, current_composite_task_->callback(), delay); | 295 FROM_HERE, current_composite_task_->callback(), delay); |
296 } | 296 } |
297 | 297 |
298 void CompositorImpl::Composite(CompositingTrigger trigger) { | 298 void CompositorImpl::Composite(CompositingTrigger trigger) { |
299 BrowserGpuChannelHostFactory* factory = | 299 BrowserGpuChannelHostFactory* factory = |
300 BrowserGpuChannelHostFactory::instance(); | 300 BrowserGpuChannelHostFactory::instance(); |
301 if (!factory->GetGpuChannel() || factory->GetGpuChannel()->IsLost()) { | 301 if (!factory->GetGpuChannel() || factory->GetGpuChannel()->IsLost()) { |
no sievers
2014/09/25 17:59:29
Can 301-308 actually be removed now that LTH::Comp
enne (OOO)
2014/09/25 19:05:05
If you don't mind me punting, I was going to remov
| |
302 CauseForGpuLaunch cause = | 302 CauseForGpuLaunch cause = |
303 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 303 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
304 factory->EstablishGpuChannel( | 304 factory->EstablishGpuChannel(cause, |
305 cause, | 305 base::Bind(&CompositorImpl::ScheduleComposite, |
306 base::Bind(&CompositorImpl::OnGpuChannelEstablished, | 306 weak_factory_.GetWeakPtr())); |
307 weak_factory_.GetWeakPtr())); | |
308 return; | 307 return; |
309 } | 308 } |
310 | 309 |
311 DCHECK(host_); | 310 DCHECK(host_); |
312 DCHECK(trigger == COMPOSITE_IMMEDIATELY || trigger == COMPOSITE_EVENTUALLY); | 311 DCHECK(trigger == COMPOSITE_IMMEDIATELY || trigger == COMPOSITE_EVENTUALLY); |
313 DCHECK(needs_composite_); | 312 DCHECK(needs_composite_); |
314 DCHECK(!DidCompositeThisFrame()); | 313 DCHECK(!DidCompositeThisFrame()); |
315 | 314 |
316 if (trigger == COMPOSITE_IMMEDIATELY) | 315 if (trigger == COMPOSITE_IMMEDIATELY) |
317 will_composite_immediately_ = false; | 316 will_composite_immediately_ = false; |
(...skipping 26 matching lines...) Expand all Loading... | |
344 | 343 |
345 did_post_swapbuffers_ = false; | 344 did_post_swapbuffers_ = false; |
346 host_->Composite(frame_time); | 345 host_->Composite(frame_time); |
347 if (did_post_swapbuffers_) | 346 if (did_post_swapbuffers_) |
348 pending_swapbuffers_++; | 347 pending_swapbuffers_++; |
349 | 348 |
350 // Need to track vsync to avoid compositing more than once per frame. | 349 // Need to track vsync to avoid compositing more than once per frame. |
351 root_window_->RequestVSyncUpdate(); | 350 root_window_->RequestVSyncUpdate(); |
352 } | 351 } |
353 | 352 |
354 void CompositorImpl::OnGpuChannelEstablished() { | |
355 ScheduleComposite(); | |
356 } | |
357 | |
358 UIResourceProvider& CompositorImpl::GetUIResourceProvider() { | 353 UIResourceProvider& CompositorImpl::GetUIResourceProvider() { |
359 return ui_resource_provider_; | 354 return ui_resource_provider_; |
360 } | 355 } |
361 | 356 |
362 ui::SystemUIResourceManager& CompositorImpl::GetSystemUIResourceManager() { | 357 ui::SystemUIResourceManager& CompositorImpl::GetSystemUIResourceManager() { |
363 return ui_resource_provider_.GetSystemUIResourceManager(); | 358 return ui_resource_provider_.GetSystemUIResourceManager(); |
364 } | 359 } |
365 | 360 |
366 void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) { | 361 void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) { |
367 if (subroot_layer_) { | 362 if (subroot_layer_) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 limits, | 536 limits, |
542 NULL)); | 537 NULL)); |
543 } | 538 } |
544 | 539 |
545 void CompositorImpl::Layout() { | 540 void CompositorImpl::Layout() { |
546 ignore_schedule_composite_ = true; | 541 ignore_schedule_composite_ = true; |
547 client_->Layout(); | 542 client_->Layout(); |
548 ignore_schedule_composite_ = false; | 543 ignore_schedule_composite_ = false; |
549 } | 544 } |
550 | 545 |
551 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( | 546 void CompositorImpl::RequestNewOutputSurface(bool fallback) { |
552 bool fallback) { | 547 BrowserGpuChannelHostFactory* factory = |
548 BrowserGpuChannelHostFactory::instance(); | |
549 if (!factory->GetGpuChannel() || factory->GetGpuChannel()->IsLost()) { | |
550 CauseForGpuLaunch cause = | |
551 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | |
552 factory->EstablishGpuChannel( | |
553 cause, | |
554 base::Bind(&CompositorImpl::CreateOutputSurface, | |
555 weak_factory_.GetWeakPtr(), | |
556 fallback)); | |
557 return; | |
558 } | |
559 | |
560 CreateOutputSurface(fallback); | |
561 } | |
562 | |
563 void CompositorImpl::CreateOutputSurface(bool fallback) { | |
553 blink::WebGraphicsContext3D::Attributes attrs; | 564 blink::WebGraphicsContext3D::Attributes attrs; |
554 attrs.shareResources = true; | 565 attrs.shareResources = true; |
555 attrs.noAutomaticFlushes = true; | 566 attrs.noAutomaticFlushes = true; |
556 pending_swapbuffers_ = 0; | 567 pending_swapbuffers_ = 0; |
557 | 568 |
558 DCHECK(window_); | 569 DCHECK(window_); |
559 DCHECK(surface_id_); | 570 DCHECK(surface_id_); |
560 | 571 |
561 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 572 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
562 BrowserGpuChannelHostFactory* factory = | 573 BrowserGpuChannelHostFactory* factory = |
563 BrowserGpuChannelHostFactory::instance(); | 574 BrowserGpuChannelHostFactory::instance(); |
564 scoped_refptr<GpuChannelHost> gpu_channel_host = factory->GetGpuChannel(); | 575 scoped_refptr<GpuChannelHost> gpu_channel_host = factory->GetGpuChannel(); |
565 if (gpu_channel_host && !gpu_channel_host->IsLost()) { | 576 if (gpu_channel_host && !gpu_channel_host->IsLost()) { |
566 context_provider = ContextProviderCommandBuffer::Create( | 577 context_provider = ContextProviderCommandBuffer::Create( |
567 CreateGpuProcessViewContext(gpu_channel_host, attrs, surface_id_), | 578 CreateGpuProcessViewContext(gpu_channel_host, attrs, surface_id_), |
568 "BrowserCompositor"); | 579 "BrowserCompositor"); |
569 } | 580 } |
570 if (!context_provider.get()) { | 581 if (!context_provider.get()) { |
571 LOG(ERROR) << "Failed to create 3D context for compositor."; | 582 LOG(ERROR) << "Failed to create 3D context for compositor."; |
572 return scoped_ptr<cc::OutputSurface>(); | 583 host_->SetOutputSurface(scoped_ptr<cc::OutputSurface>()); |
584 return; | |
573 } | 585 } |
574 | 586 |
575 return scoped_ptr<cc::OutputSurface>(new OutputSurfaceWithoutParent( | 587 host_->SetOutputSurface( |
576 context_provider, weak_factory_.GetWeakPtr())); | 588 scoped_ptr<cc::OutputSurface>(new OutputSurfaceWithoutParent( |
589 context_provider, weak_factory_.GetWeakPtr()))); | |
577 } | 590 } |
578 | 591 |
579 void CompositorImpl::PopulateGpuCapabilities( | 592 void CompositorImpl::PopulateGpuCapabilities( |
580 gpu::Capabilities gpu_capabilities) { | 593 gpu::Capabilities gpu_capabilities) { |
581 ui_resource_provider_.SetSupportsETC1NonPowerOfTwo( | 594 ui_resource_provider_.SetSupportsETC1NonPowerOfTwo( |
582 gpu_capabilities.texture_format_etc1_npot); | 595 gpu_capabilities.texture_format_etc1_npot); |
583 } | 596 } |
584 | 597 |
585 void CompositorImpl::OnLostResources() { | 598 void CompositorImpl::OnLostResources() { |
586 client_->DidLoseResources(); | 599 client_->DidLoseResources(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
669 } | 682 } |
670 | 683 |
671 void CompositorImpl::SetNeedsAnimate() { | 684 void CompositorImpl::SetNeedsAnimate() { |
672 if (!host_) | 685 if (!host_) |
673 return; | 686 return; |
674 | 687 |
675 host_->SetNeedsAnimate(); | 688 host_->SetNeedsAnimate(); |
676 } | 689 } |
677 | 690 |
678 } // namespace content | 691 } // namespace content |
OLD | NEW |