content: Use lower command buffer memory for OOP raster contexts.

Since most commands with OOP raster are paint commands sent via the
transfer buffer and not GL commands sent via the command buffer, we
can use a much smaller command buffer.

R=piman@chromium.org

Bug: 859635
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I8a52395b40f240d774ea2f54cc7f4961ab0ac2ce
Reviewed-on: https://chromium-review.googlesource.com/1134471
Reviewed-by: Antoine Labour <piman@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574732}
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index ed9ecda..bb93141 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -2394,9 +2394,12 @@
   bool support_gles2_interface = !support_oop_rasterization;
   bool support_raster_interface = true;
   bool support_grcontext = !support_oop_rasterization;
+  auto shared_memory_limits =
+      support_oop_rasterization ? gpu::SharedMemoryLimits::ForOOPRasterContext()
+                                : gpu::SharedMemoryLimits();
   shared_worker_context_provider_ = CreateOffscreenContext(
       std::move(gpu_channel_host), GetGpuMemoryBufferManager(),
-      gpu::SharedMemoryLimits(), support_locking, support_gles2_interface,
+      shared_memory_limits, support_locking, support_gles2_interface,
       support_raster_interface, support_oop_rasterization, support_grcontext,
       ui::command_buffer_metrics::ContextType::RENDER_WORKER,
       kGpuStreamIdWorker, kGpuStreamPriorityWorker);
diff --git a/gpu/command_buffer/client/shared_memory_limits.h b/gpu/command_buffer/client/shared_memory_limits.h
index 16da712..992a3dd8c 100644
--- a/gpu/command_buffer/client/shared_memory_limits.h
+++ b/gpu/command_buffer/client/shared_memory_limits.h
@@ -54,6 +54,16 @@
     limits.min_transfer_buffer_size = 64 * 1024;
     return limits;
   }
+
+  static SharedMemoryLimits ForOOPRasterContext() {
+    SharedMemoryLimits limits;
+    limits.command_buffer_size = 64 * 1024;
+    // TODO(khushalsagar): See if transfer buffer sizes can be fine-tuned
+    // further. A 16M max_transfer_buffer_size doesn't make sense if only paint
+    // commands are being sent through this buffer, and all large transfers use
+    // the transfer cache backed by mapped memory.
+    return limits;
+  }
 };
 
 }  // namespace gpu