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

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

Issue 1900993002: Move SharedMemoryLimits out of WebGraphicsContext3DCommandBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@limits
Patch Set: move-limits: types Created 4 years, 8 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
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 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 gpu::SharedMemoryLimits limits;
531 // This limit is meant to hold the contents of the display compositor
532 // 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
534 limits.command_buffer_size = 64 * 1024;
535 // These limits are meant to hold the uploads for the browser UI without
536 // any excess space.
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): 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
552 scoped_refptr<ContextProviderCommandBuffer> context_provider( 550 scoped_refptr<ContextProviderCommandBuffer> context_provider(
553 new ContextProviderCommandBuffer( 551 new ContextProviderCommandBuffer(
554 CreateGpuProcessViewContext(gpu_channel_host, attributes, 552 base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl(
555 surface_id_), 553 surface_handle, url, gpu_channel_host.get(), attributes,
556 DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT)); 554 gfx::PreferIntegratedGpu, share_resources, automatic_flushes,
555 nullptr)),
556 limits, DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT));
557 DCHECK(context_provider.get()); 557 DCHECK(context_provider.get());
558 558
559 std::unique_ptr<cc::OutputSurface> real_output_surface( 559 std::unique_ptr<cc::OutputSurface> real_output_surface(
560 new OutputSurfaceWithoutParent( 560 new OutputSurfaceWithoutParent(
561 this, context_provider, 561 this, context_provider,
562 base::Bind(&CompositorImpl::PopulateGpuCapabilities, 562 base::Bind(&CompositorImpl::PopulateGpuCapabilities,
563 base::Unretained(this)), 563 base::Unretained(this)),
564 base::WrapUnique(new ExternalBeginFrameSource(this)))); 564 base::WrapUnique(new ExternalBeginFrameSource(this))));
565 565
566 cc::SurfaceManager* manager = GetSurfaceManager(); 566 cc::SurfaceManager* manager = GetSurfaceManager();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 656
657 void CompositorImpl::SetNeedsAnimate() { 657 void CompositorImpl::SetNeedsAnimate() {
658 needs_animate_ = true; 658 needs_animate_ = true;
659 if (!host_->visible()) 659 if (!host_->visible())
660 return; 660 return;
661 661
662 host_->SetNeedsAnimate(); 662 host_->SetNeedsAnimate();
663 } 663 }
664 664
665 } // namespace content 665 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_ipc_browsertests.cc ('k') | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698