Fix Dawn 2D Canvas.

Dawn doesn't currently report its maximum texture size, which causes
Canvas to think the max is zero. So canvas backing store allocation
always fails, and we end up with a software canvas.

The easiest thing for now is to avoid the maximum size test for Dawn.

Bug: 1076141

Change-Id: I73df1aeb9af7ad438889f9e0f7792c870d1b9201
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2199693
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Khushal <khushalsagar@chromium.org>
Reviewed-by: Juanmi Huertas <juanmihd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#768808}
diff --git a/third_party/blink/renderer/platform/graphics/canvas_resource_provider.cc b/third_party/blink/renderer/platform/graphics/canvas_resource_provider.cc
index 8bd111f3..04a4f36 100644
--- a/third_party/blink/renderer/platform/graphics/canvas_resource_provider.cc
+++ b/third_party/blink/renderer/platform/graphics/canvas_resource_provider.cc
@@ -180,10 +180,10 @@
       base::WeakPtr<CanvasResourceDispatcher> resource_dispatcher,
       bool is_origin_top_left,
       bool is_accelerated,
-      bool is_webgpu,
+      bool use_webgpu,
       uint32_t shared_image_usage_flags)
       : CanvasResourceProvider(
-            is_webgpu ? kWebGPUSharedImage : kSharedImage,
+            use_webgpu ? kWebGPUSharedImage : kSharedImage,
             size,
             msaa_sample_count,
             filter_quality,
@@ -1013,8 +1013,13 @@
 
   const auto& capabilities =
       context_provider_wrapper->ContextProvider()->GetCapabilities();
-  if (size.Width() > capabilities.max_texture_size ||
-      size.Height() > capabilities.max_texture_size) {
+  bool use_webgpu =
+      raster_mode == RasterMode::kGPU &&
+      base::FeatureList::IsEnabled(blink::features::kDawn2dCanvas);
+  // TODO(senorblanco): once Dawn reports maximum texture size, Dawn Canvas
+  // should respect it.  http://crbug.com/1082760
+  if (!use_webgpu && (size.Width() > capabilities.max_texture_size ||
+                      size.Height() > capabilities.max_texture_size)) {
     return nullptr;
   }
 
@@ -1034,9 +1039,7 @@
   auto provider = std::make_unique<CanvasResourceProviderSharedImage>(
       size, msaa_sample_count, filter_quality, color_params,
       context_provider_wrapper, nullptr /* resource_dispatcher */,
-      is_origin_top_left, raster_mode == RasterMode::kGPU,
-      raster_mode == RasterMode::kGPU &&
-          base::FeatureList::IsEnabled(blink::features::kDawn2dCanvas),
+      is_origin_top_left, raster_mode == RasterMode::kGPU, use_webgpu,
       shared_image_usage_flags);
   if (provider->IsValid())
     return provider;