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 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 } | 140 } |
141 | 141 |
142 bool BindToClient(cc::OutputSurfaceClient* client) override { | 142 bool BindToClient(cc::OutputSurfaceClient* client) override { |
143 if (!OutputSurface::BindToClient(client)) | 143 if (!OutputSurface::BindToClient(client)) |
144 return false; | 144 return false; |
145 | 145 |
146 GetCommandBufferProxy()->SetSwapBuffersCompletionCallback( | 146 GetCommandBufferProxy()->SetSwapBuffersCompletionCallback( |
147 swap_buffers_completion_callback_.callback()); | 147 swap_buffers_completion_callback_.callback()); |
148 | 148 |
149 populate_gpu_capabilities_callback_.Run( | 149 populate_gpu_capabilities_callback_.Run( |
150 context_provider_->ContextCapabilities().gpu); | 150 context_provider_->ContextCapabilities()); |
151 compositor_->AddObserver(this); | 151 compositor_->AddObserver(this); |
152 | 152 |
153 client->SetBeginFrameSource(begin_frame_source_.get()); | 153 client->SetBeginFrameSource(begin_frame_source_.get()); |
154 | 154 |
155 return true; | 155 return true; |
156 } | 156 } |
157 | 157 |
158 void DetachFromClient() override { | 158 void DetachFromClient() override { |
159 client_->SetBeginFrameSource(nullptr); | 159 client_->SetBeginFrameSource(nullptr); |
160 OutputSurface::DetachFromClient(); | 160 OutputSurface::DetachFromClient(); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 if (host_) | 411 if (host_) |
412 host_->set_has_transparent_background(flag); | 412 host_->set_has_transparent_background(flag); |
413 } | 413 } |
414 | 414 |
415 void CompositorImpl::SetNeedsComposite() { | 415 void CompositorImpl::SetNeedsComposite() { |
416 if (!host_->visible()) | 416 if (!host_->visible()) |
417 return; | 417 return; |
418 host_->SetNeedsAnimate(); | 418 host_->SetNeedsAnimate(); |
419 } | 419 } |
420 | 420 |
421 static std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> | |
422 CreateGpuProcessViewContext( | |
423 const scoped_refptr<gpu::GpuChannelHost>& gpu_channel_host, | |
424 const gpu::gles2::ContextCreationAttribHelper& attributes, | |
425 int surface_id) { | |
426 GURL url("chrome://gpu/Compositor::createContext3D"); | |
427 static const size_t kBytesPerPixel = 4; | |
428 gfx::DeviceDisplayInfo display_info; | |
429 size_t full_screen_texture_size_in_bytes = | |
430 display_info.GetDisplayHeight() * | |
431 display_info.GetDisplayWidth() * | |
432 kBytesPerPixel; | |
433 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | |
434 limits.command_buffer_size = 64 * 1024; | |
435 limits.start_transfer_buffer_size = 64 * 1024; | |
436 limits.min_transfer_buffer_size = 64 * 1024; | |
437 limits.max_transfer_buffer_size = std::min( | |
438 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize); | |
439 limits.mapped_memory_reclaim_limit = 2 * 1024 * 1024; | |
440 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); | |
441 gpu::SurfaceHandle surface_handle = tracker->GetSurfaceHandle(surface_id); | |
442 bool share_resources = true; | |
443 bool automatic_flushes = false; | |
444 return base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( | |
445 surface_handle, url, gpu_channel_host.get(), attributes, | |
446 gfx::PreferIntegratedGpu, share_resources, automatic_flushes, limits, | |
447 nullptr)); | |
448 } | |
449 | |
450 void CompositorImpl::UpdateLayerTreeHost() { | 421 void CompositorImpl::UpdateLayerTreeHost() { |
451 client_->UpdateLayerTreeHost(); | 422 client_->UpdateLayerTreeHost(); |
452 if (needs_animate_) { | 423 if (needs_animate_) { |
453 needs_animate_ = false; | 424 needs_animate_ = false; |
454 root_window_->Animate(base::TimeTicks::Now()); | 425 root_window_->Animate(base::TimeTicks::Now()); |
455 } | 426 } |
456 } | 427 } |
457 | 428 |
458 void CompositorImpl::OnGpuChannelEstablished() { | 429 void CompositorImpl::OnGpuChannelEstablished() { |
459 establish_gpu_channel_timeout_.Stop(); | 430 establish_gpu_channel_timeout_.Stop(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
542 DCHECK(window_); | 513 DCHECK(window_); |
543 DCHECK(surface_id_); | 514 DCHECK(surface_id_); |
544 | 515 |
545 BrowserGpuChannelHostFactory* factory = | 516 BrowserGpuChannelHostFactory* factory = |
546 BrowserGpuChannelHostFactory::instance(); | 517 BrowserGpuChannelHostFactory::instance(); |
547 // This channel might be lost (and even if it isn't right now, it might | 518 // This channel might be lost (and even if it isn't right now, it might |
548 // still get marked as lost from the IO thread, at any point in time really). | 519 // still get marked as lost from the IO thread, at any point in time really). |
549 // But from here on just try and always lead to either | 520 // But from here on just try and always lead to either |
550 // DidInitializeOutputSurface() or DidFailToInitializeOutputSurface(). | 521 // DidInitializeOutputSurface() or DidFailToInitializeOutputSurface(). |
551 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); | 522 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); |
523 | |
524 GURL url("chrome://gpu/CompositorImpl::CreateOutputSurface"); | |
525 gpu::SurfaceHandle surface_handle = | |
526 GpuSurfaceTracker::Get()->GetSurfaceHandle(surface_id_); | |
527 constexpr bool share_resources = true; | |
528 constexpr bool automatic_flushes = false; | |
529 | |
530 // TODO(danakj): Why are these limits lower here? This context is used by the | |
danakj
2016/04/19 02:02:11
Would like feedback here from sievers/boliu
| |
531 // browser compositor (so limits like RenderWidget make sense), but also by | |
532 // the display compositor and GpuProcessTransportFactory doesn't set limits | |
533 // on the display compositor context, and we do issue a fair number of draw | |
534 // commands? | |
piman
2016/04/19 03:22:17
We should look into it. In the best case, if I cou
| |
535 gpu::SharedMemoryLimits limits; | |
536 limits.command_buffer_size = 64 * 1024; | |
537 limits.start_transfer_buffer_size = 64 * 1024; | |
538 limits.min_transfer_buffer_size = 64 * 1024; | |
539 constexpr size_t kBytesPerPixel = 4; | |
540 const size_t full_screen_texture_size_in_bytes = | |
541 gfx::DeviceDisplayInfo().GetDisplayHeight() * | |
542 gfx::DeviceDisplayInfo().GetDisplayWidth() * kBytesPerPixel; | |
543 limits.max_transfer_buffer_size = std::min( | |
544 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize); | |
545 // TODO(danakj): Why this limit on the compositor context? | |
danakj
2016/04/19 02:02:11
And here
no sievers
2016/04/19 20:24:13
We definitely want to limit all shared memory aggr
danakj
2016/04/20 00:01:53
OK I've turned this one into a TODO, and the above
no sievers
2016/04/20 00:06:29
sounds/looks good. thanks!
| |
546 limits.mapped_memory_reclaim_limit = 2 * 1024 * 1024; | |
547 | |
552 scoped_refptr<ContextProviderCommandBuffer> context_provider( | 548 scoped_refptr<ContextProviderCommandBuffer> context_provider( |
553 new ContextProviderCommandBuffer( | 549 new ContextProviderCommandBuffer( |
554 CreateGpuProcessViewContext(gpu_channel_host, attributes, | 550 base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( |
555 surface_id_), | 551 surface_handle, url, gpu_channel_host.get(), attributes, |
556 DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT)); | 552 gfx::PreferIntegratedGpu, share_resources, automatic_flushes, |
553 nullptr)), | |
554 limits, DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT)); | |
557 DCHECK(context_provider.get()); | 555 DCHECK(context_provider.get()); |
558 | 556 |
559 std::unique_ptr<cc::OutputSurface> real_output_surface( | 557 std::unique_ptr<cc::OutputSurface> real_output_surface( |
560 new OutputSurfaceWithoutParent( | 558 new OutputSurfaceWithoutParent( |
561 this, context_provider, | 559 this, context_provider, |
562 base::Bind(&CompositorImpl::PopulateGpuCapabilities, | 560 base::Bind(&CompositorImpl::PopulateGpuCapabilities, |
563 base::Unretained(this)), | 561 base::Unretained(this)), |
564 base::WrapUnique(new ExternalBeginFrameSource(this)))); | 562 base::WrapUnique(new ExternalBeginFrameSource(this)))); |
565 | 563 |
566 cc::SurfaceManager* manager = GetSurfaceManager(); | 564 cc::SurfaceManager* manager = GetSurfaceManager(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 | 654 |
657 void CompositorImpl::SetNeedsAnimate() { | 655 void CompositorImpl::SetNeedsAnimate() { |
658 needs_animate_ = true; | 656 needs_animate_ = true; |
659 if (!host_->visible()) | 657 if (!host_->visible()) |
660 return; | 658 return; |
661 | 659 |
662 host_->SetNeedsAnimate(); | 660 host_->SetNeedsAnimate(); |
663 } | 661 } |
664 | 662 |
665 } // namespace content | 663 } // namespace content |
OLD | NEW |