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

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/compositor/gpu_process_transport_factory.h" 5 #include "content/browser/compositor/gpu_process_transport_factory.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 27 matching lines...) Expand all
38 #include "content/browser/gpu/gpu_data_manager_impl.h" 38 #include "content/browser/gpu/gpu_data_manager_impl.h"
39 #include "content/browser/gpu/gpu_surface_tracker.h" 39 #include "content/browser/gpu/gpu_surface_tracker.h"
40 #include "content/browser/renderer_host/render_widget_host_impl.h" 40 #include "content/browser/renderer_host/render_widget_host_impl.h"
41 #include "content/common/gpu/client/context_provider_command_buffer.h" 41 #include "content/common/gpu/client/context_provider_command_buffer.h"
42 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 42 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
43 #include "content/common/gpu_process_launch_causes.h" 43 #include "content/common/gpu_process_launch_causes.h"
44 #include "content/common/host_shared_bitmap_manager.h" 44 #include "content/common/host_shared_bitmap_manager.h"
45 #include "content/public/common/content_switches.h" 45 #include "content/public/common/content_switches.h"
46 #include "gpu/GLES2/gl2extchromium.h" 46 #include "gpu/GLES2/gl2extchromium.h"
47 #include "gpu/command_buffer/client/gles2_interface.h" 47 #include "gpu/command_buffer/client/gles2_interface.h"
48 #include "gpu/command_buffer/client/shared_memory_limits.h"
48 #include "gpu/command_buffer/common/mailbox.h" 49 #include "gpu/command_buffer/common/mailbox.h"
49 #include "gpu/ipc/client/gpu_channel_host.h" 50 #include "gpu/ipc/client/gpu_channel_host.h"
50 #include "third_party/khronos/GLES2/gl2.h" 51 #include "third_party/khronos/GLES2/gl2.h"
51 #include "ui/compositor/compositor.h" 52 #include "ui/compositor/compositor.h"
52 #include "ui/compositor/compositor_constants.h" 53 #include "ui/compositor/compositor_constants.h"
53 #include "ui/compositor/compositor_switches.h" 54 #include "ui/compositor/compositor_switches.h"
54 #include "ui/compositor/layer.h" 55 #include "ui/compositor/layer.h"
55 #include "ui/gfx/geometry/size.h" 56 #include "ui/gfx/geometry/size.h"
56 57
57 #if defined(MOJO_RUNNER_CLIENT) 58 #if defined(MOJO_RUNNER_CLIENT)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 attributes.bind_generates_resource = false; 114 attributes.bind_generates_resource = false;
114 attributes.lose_context_when_out_of_memory = true; 115 attributes.lose_context_when_out_of_memory = true;
115 116
116 bool share_resources = true; 117 bool share_resources = true;
117 bool automatic_flushes = false; 118 bool automatic_flushes = false;
118 119
119 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); 120 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon");
120 return base::WrapUnique(new content::WebGraphicsContext3DCommandBufferImpl( 121 return base::WrapUnique(new content::WebGraphicsContext3DCommandBufferImpl(
121 surface_handle, url, gpu_channel_host.get(), attributes, 122 surface_handle, url, gpu_channel_host.get(), attributes,
122 gfx::PreferIntegratedGpu, share_resources, automatic_flushes, 123 gfx::PreferIntegratedGpu, share_resources, automatic_flushes,
123 content::WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(),
124 nullptr)); 124 nullptr));
125 } 125 }
126 126
127 } // namespace 127 } // namespace
128 128
129 namespace content { 129 namespace content {
130 130
131 struct GpuProcessTransportFactory::PerCompositorData { 131 struct GpuProcessTransportFactory::PerCompositorData {
132 int surface_id; 132 int surface_id;
133 BrowserCompositorOutputSurface* surface; 133 BrowserCompositorOutputSurface* surface;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } else { 328 } else {
329 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); 329 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get();
330 gpu::SurfaceHandle surface_handle = 330 gpu::SurfaceHandle surface_handle =
331 data->surface_id ? tracker->GetSurfaceHandle(data->surface_id) 331 data->surface_id ? tracker->GetSurfaceHandle(data->surface_id)
332 : gpu::kNullSurfaceHandle; 332 : gpu::kNullSurfaceHandle;
333 333
334 // This context is used for both the browser compositor and the display 334 // This context is used for both the browser compositor and the display
335 // compositor. 335 // compositor.
336 context_provider = new ContextProviderCommandBuffer( 336 context_provider = new ContextProviderCommandBuffer(
337 CreateContextCommon(gpu_channel_host, surface_handle), 337 CreateContextCommon(gpu_channel_host, surface_handle),
338 DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); 338 gpu::SharedMemoryLimits(), DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT);
339 if (!context_provider->BindToCurrentThread()) 339 if (!context_provider->BindToCurrentThread())
340 context_provider = nullptr; 340 context_provider = nullptr;
341 341
342 if (!shared_worker_context_provider_) { 342 if (!shared_worker_context_provider_) {
343 shared_worker_context_provider_ = new ContextProviderCommandBuffer( 343 shared_worker_context_provider_ = new ContextProviderCommandBuffer(
344 CreateContextCommon(std::move(gpu_channel_host), 344 CreateContextCommon(std::move(gpu_channel_host),
345 gpu::kNullSurfaceHandle), 345 gpu::kNullSurfaceHandle),
346 BROWSER_WORKER_CONTEXT); 346 gpu::SharedMemoryLimits(), BROWSER_WORKER_CONTEXT);
347 if (shared_worker_context_provider_->BindToCurrentThread()) 347 if (shared_worker_context_provider_->BindToCurrentThread())
348 shared_worker_context_provider_->SetupLock(); 348 shared_worker_context_provider_->SetupLock();
349 else 349 else
350 shared_worker_context_provider_ = nullptr; 350 shared_worker_context_provider_ = nullptr;
351 } 351 }
352 } 352 }
353 353
354 bool created_gpu_browser_compositor = 354 bool created_gpu_browser_compositor =
355 !!context_provider && !!shared_worker_context_provider_; 355 !!context_provider && !!shared_worker_context_provider_;
356 356
(...skipping 12 matching lines...) Expand all
369 } 369 }
370 } 370 }
371 371
372 std::unique_ptr<BrowserCompositorOutputSurface> surface; 372 std::unique_ptr<BrowserCompositorOutputSurface> surface;
373 if (!create_gpu_output_surface) { 373 if (!create_gpu_output_surface) {
374 surface = base::WrapUnique(new SoftwareBrowserCompositorOutputSurface( 374 surface = base::WrapUnique(new SoftwareBrowserCompositorOutputSurface(
375 CreateSoftwareOutputDevice(compositor.get()), 375 CreateSoftwareOutputDevice(compositor.get()),
376 compositor->vsync_manager(), compositor->task_runner().get())); 376 compositor->vsync_manager(), compositor->task_runner().get()));
377 } else { 377 } else {
378 DCHECK(context_provider); 378 DCHECK(context_provider);
379 ContextProvider::Capabilities capabilities = 379 const auto& capabilities = context_provider->ContextCapabilities();
380 context_provider->ContextCapabilities();
381 if (!data->surface_id) { 380 if (!data->surface_id) {
382 surface = base::WrapUnique(new OffscreenBrowserCompositorOutputSurface( 381 surface = base::WrapUnique(new OffscreenBrowserCompositorOutputSurface(
383 context_provider, shared_worker_context_provider_, 382 context_provider, shared_worker_context_provider_,
384 compositor->vsync_manager(), compositor->task_runner().get(), 383 compositor->vsync_manager(), compositor->task_runner().get(),
385 std::unique_ptr<BrowserCompositorOverlayCandidateValidator>())); 384 std::unique_ptr<BrowserCompositorOverlayCandidateValidator>()));
386 } else if (capabilities.gpu.surfaceless) { 385 } else if (capabilities.surfaceless) {
387 GLenum target = GL_TEXTURE_2D; 386 GLenum target = GL_TEXTURE_2D;
388 GLenum format = GL_RGB; 387 GLenum format = GL_RGB;
389 #if defined(OS_MACOSX) 388 #if defined(OS_MACOSX)
390 target = GL_TEXTURE_RECTANGLE_ARB; 389 target = GL_TEXTURE_RECTANGLE_ARB;
391 format = GL_RGBA; 390 format = GL_RGBA;
392 #endif 391 #endif
393 surface = 392 surface =
394 base::WrapUnique(new GpuSurfacelessBrowserCompositorOutputSurface( 393 base::WrapUnique(new GpuSurfacelessBrowserCompositorOutputSurface(
395 context_provider, shared_worker_context_provider_, 394 context_provider, shared_worker_context_provider_,
396 data->surface_id, compositor->vsync_manager(), 395 data->surface_id, compositor->vsync_manager(),
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; 620 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
622 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( 621 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(
623 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); 622 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause));
624 if (!gpu_channel_host) 623 if (!gpu_channel_host)
625 return nullptr; 624 return nullptr;
626 625
627 // We need a separate context from the compositor's so that skia and gl_helper 626 // We need a separate context from the compositor's so that skia and gl_helper
628 // don't step on each other. 627 // don't step on each other.
629 shared_main_thread_contexts_ = new ContextProviderCommandBuffer( 628 shared_main_thread_contexts_ = new ContextProviderCommandBuffer(
630 CreateContextCommon(std::move(gpu_channel_host), gpu::kNullSurfaceHandle), 629 CreateContextCommon(std::move(gpu_channel_host), gpu::kNullSurfaceHandle),
631 BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); 630 gpu::SharedMemoryLimits(), BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT);
632 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( 631 shared_main_thread_contexts_->SetLostContextCallback(base::Bind(
633 &GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback, 632 &GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback,
634 callback_factory_.GetWeakPtr())); 633 callback_factory_.GetWeakPtr()));
635 if (!shared_main_thread_contexts_->BindToCurrentThread()) 634 if (!shared_main_thread_contexts_->BindToCurrentThread())
636 shared_main_thread_contexts_ = nullptr; 635 shared_main_thread_contexts_ = nullptr;
637 return shared_main_thread_contexts_; 636 return shared_main_thread_contexts_;
638 } 637 }
639 638
640 GpuProcessTransportFactory::PerCompositorData* 639 GpuProcessTransportFactory::PerCompositorData*
641 GpuProcessTransportFactory::CreatePerCompositorData( 640 GpuProcessTransportFactory::CreatePerCompositorData(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, 679 FOR_EACH_OBSERVER(ImageTransportFactoryObserver,
681 observer_list_, 680 observer_list_,
682 OnLostResources()); 681 OnLostResources());
683 682
684 // Kill things that use the shared context before killing the shared context. 683 // Kill things that use the shared context before killing the shared context.
685 lost_gl_helper.reset(); 684 lost_gl_helper.reset();
686 lost_shared_main_thread_contexts = NULL; 685 lost_shared_main_thread_contexts = NULL;
687 } 686 }
688 687
689 } // namespace content 688 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698