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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 // But from here on just try and always lead to either | 520 // But from here on just try and always lead to either |
521 // DidInitializeOutputSurface() or DidFailToInitializeOutputSurface(). | 521 // DidInitializeOutputSurface() or DidFailToInitializeOutputSurface(). |
522 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); | 522 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); |
523 | 523 |
524 GURL url("chrome://gpu/CompositorImpl::CreateOutputSurface"); | 524 GURL url("chrome://gpu/CompositorImpl::CreateOutputSurface"); |
525 gpu::SurfaceHandle surface_handle = | 525 gpu::SurfaceHandle surface_handle = |
526 GpuSurfaceTracker::Get()->GetSurfaceHandle(surface_id_); | 526 GpuSurfaceTracker::Get()->GetSurfaceHandle(surface_id_); |
527 constexpr bool share_resources = false; | 527 constexpr bool share_resources = false; |
528 constexpr bool automatic_flushes = false; | 528 constexpr bool automatic_flushes = false; |
529 | 529 |
| 530 constexpr size_t kBytesPerPixel = 4; |
| 531 const size_t full_screen_texture_size_in_bytes = |
| 532 gfx::DeviceDisplayInfo().GetDisplayHeight() * |
| 533 gfx::DeviceDisplayInfo().GetDisplayWidth() * kBytesPerPixel; |
| 534 |
530 gpu::SharedMemoryLimits limits; | 535 gpu::SharedMemoryLimits limits; |
531 // This limit is meant to hold the contents of the display compositor | 536 // This limit is meant to hold the contents of the display compositor |
532 // drawing the scene. See discussion here: | 537 // drawing the scene. See discussion here: |
533 // https://codereview.chromium.org/1900993002/diff/90001/content/browser/rende
rer_host/compositor_impl_android.cc?context=3&column_width=80&tab_spaces=8 | 538 // https://codereview.chromium.org/1900993002/diff/90001/content/browser/rende
rer_host/compositor_impl_android.cc?context=3&column_width=80&tab_spaces=8 |
534 limits.command_buffer_size = 64 * 1024; | 539 limits.command_buffer_size = 64 * 1024; |
535 // These limits are meant to hold the uploads for the browser UI without | 540 // These limits are meant to hold the uploads for the browser UI without |
536 // any excess space. | 541 // any excess space. |
537 limits.start_transfer_buffer_size = 64 * 1024; | 542 limits.start_transfer_buffer_size = 64 * 1024; |
538 limits.min_transfer_buffer_size = 64 * 1024; | 543 limits.min_transfer_buffer_size = 64 * 1024; |
539 constexpr size_t kBytesPerPixel = 4; | 544 limits.max_transfer_buffer_size = full_screen_texture_size_in_bytes; |
540 const size_t full_screen_texture_size_in_bytes = | 545 // Texture uploads may use mapped memory so give a reasonable limit for them. |
541 gfx::DeviceDisplayInfo().GetDisplayHeight() * | 546 limits.mapped_memory_reclaim_limit = full_screen_texture_size_in_bytes; |
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): This limit should be on the GLHelper context instead in | |
546 // RWHVAndroid since that is where we do the async readback and map gpu | |
547 // memory to do so. | |
548 limits.mapped_memory_reclaim_limit = 2 * 1024 * 1024; | |
549 | 547 |
550 scoped_refptr<ContextProviderCommandBuffer> context_provider( | 548 scoped_refptr<ContextProviderCommandBuffer> context_provider( |
551 new ContextProviderCommandBuffer( | 549 new ContextProviderCommandBuffer( |
552 base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( | 550 base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( |
553 surface_handle, url, gpu_channel_host.get(), attributes, | 551 surface_handle, url, gpu_channel_host.get(), attributes, |
554 gfx::PreferIntegratedGpu, share_resources, automatic_flushes, | 552 gfx::PreferIntegratedGpu, share_resources, automatic_flushes, |
555 nullptr)), | 553 nullptr)), |
556 limits, DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT)); | 554 limits, DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT)); |
557 DCHECK(context_provider.get()); | 555 DCHECK(context_provider.get()); |
558 | 556 |
(...skipping 97 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 |