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

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

Powered by Google App Engine
This is Rietveld 408576698