[go: nahoru, domu]

cc: Enable MSAA only for layers with slow paths.

Currently MSAA is controlled using a global switch for all layers which
is enabled based on whether currently painted content on any layer has
slow paths. Switching this state tears down all tile resources, both on
pending and active tree. As such this switching can be quite expensive
since we need to re-raster the entire visible viewport and causes jank,
because the active tree can not be redrawn until its tiles are ready.

For a long scrolling page where only some content of a layer has slow
paths, this switching can occur each time this content scrolls in and
out of the interest rect.

Avoid the above by allow MSAA to be applied on a per layer basis. Since
the decision changes only when the painted content of a layer is
updated, which should already be invalidated in that case, this avoids
any unnecessary raster invalidation.

R=ericrk@chromium.org

Bug: 1013758
Change-Id: I00678d21abb09b00c1246246076ee1a4e50d1822
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891746
Auto-Submit: Khushal <khushalsagar@chromium.org>
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Reviewed-by: Eric Karl <ericrk@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712297}
diff --git a/cc/raster/gpu_raster_buffer_provider.cc b/cc/raster/gpu_raster_buffer_provider.cc
index cbe878b..481e7be9 100644
--- a/cc/raster/gpu_raster_buffer_provider.cc
+++ b/cc/raster/gpu_raster_buffer_provider.cc
@@ -128,8 +128,7 @@
     const gfx::Rect& playback_rect,
     const gfx::AxisTransform2d& transform,
     const RasterSource::PlaybackSettings& playback_settings,
-    viz::RasterContextProvider* context_provider,
-    int msaa_sample_count) {
+    viz::RasterContextProvider* context_provider) {
   gpu::raster::RasterInterface* ri = context_provider->RasterInterface();
   if (mailbox->IsZero()) {
     DCHECK(!sync_token.HasData());
@@ -146,9 +145,9 @@
     ri->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
   }
 
-  ri->BeginRasterCHROMIUM(raster_source->background_color(), msaa_sample_count,
-                          playback_settings.use_lcd_text, color_space,
-                          mailbox->name);
+  ri->BeginRasterCHROMIUM(
+      raster_source->background_color(), playback_settings.msaa_sample_count,
+      playback_settings.use_lcd_text, color_space, mailbox->name);
   float recording_to_raster_scale =
       transform.scale() / raster_source->recording_scale_factor();
   gfx::Size content_size = raster_source->GetContentSize(transform.scale());
@@ -183,7 +182,6 @@
     const gfx::AxisTransform2d& transform,
     const RasterSource::PlaybackSettings& playback_settings,
     viz::RasterContextProvider* context_provider,
-    int msaa_sample_count,
     bool unpremultiply_and_dither,
     const gfx::Size& max_tile_size) {
   gpu::raster::RasterInterface* ri = context_provider->RasterInterface();
@@ -215,13 +213,13 @@
       scoped_surface.emplace(context_provider->GrContext(), sk_color_space,
                              texture_id, texture_target, resource_size,
                              resource_format, playback_settings.use_lcd_text,
-                             msaa_sample_count);
+                             playback_settings.msaa_sample_count);
       surface = scoped_surface->surface();
     } else {
       scoped_dither_surface.emplace(
           context_provider, sk_color_space, playback_rect, raster_full_rect,
           max_tile_size, texture_id, resource_size,
-          playback_settings.use_lcd_text, msaa_sample_count);
+          playback_settings.use_lcd_text, playback_settings.msaa_sample_count);
       surface = scoped_dither_surface->surface();
     }
 
@@ -346,7 +344,6 @@
     viz::ContextProvider* compositor_context_provider,
     viz::RasterContextProvider* worker_context_provider,
     bool use_gpu_memory_buffer_resources,
-    int gpu_rasterization_msaa_sample_count,
     viz::ResourceFormat tile_format,
     const gfx::Size& max_tile_size,
     bool unpremultiply_and_dither_low_bit_depth_tiles,
@@ -355,7 +352,6 @@
     : compositor_context_provider_(compositor_context_provider),
       worker_context_provider_(worker_context_provider),
       use_gpu_memory_buffer_resources_(use_gpu_memory_buffer_resources),
-      msaa_sample_count_(gpu_rasterization_msaa_sample_count),
       tile_format_(tile_format),
       max_tile_size_(max_tile_size),
       unpremultiply_and_dither_low_bit_depth_tiles_(
@@ -402,13 +398,6 @@
   return !ShouldUnpremultiplyAndDitherResource(GetResourceFormat());
 }
 
-bool GpuRasterBufferProvider::CanPartialRasterIntoProvidedResource() const {
-  // Partial raster doesn't support MSAA, as the MSAA resolve is unaware of clip
-  // rects.
-  // TODO(crbug.com/629683): See if we can work around this limitation.
-  return msaa_sample_count_ == 0;
-}
-
 bool GpuRasterBufferProvider::IsResourceReadyToDraw(
     const ResourcePool::InUsePoolResource& resource) const {
   const gpu::SyncToken& sync_token = resource.gpu_backing()->mailbox_sync_token;
@@ -421,6 +410,10 @@
       sync_token);
 }
 
+bool GpuRasterBufferProvider::CanPartialRasterIntoProvidedResource() const {
+  return true;
+}
+
 uint64_t GpuRasterBufferProvider::SetReadyToDrawCallback(
     const std::vector<const ResourcePool::InUsePoolResource*>& resources,
     base::OnceClosure callback,
@@ -566,19 +559,17 @@
     if (measure_raster_metric)
       timer.emplace();
     if (enable_oop_rasterization_) {
-      RasterizeSourceOOP(raster_source, resource_has_previous_content, mailbox,
-                         sync_token, texture_target,
-                         texture_is_overlay_candidate, resource_size,
-                         resource_format, color_space, raster_full_rect,
-                         playback_rect, transform, playback_settings,
-                         worker_context_provider_, msaa_sample_count_);
+      RasterizeSourceOOP(
+          raster_source, resource_has_previous_content, mailbox, sync_token,
+          texture_target, texture_is_overlay_candidate, resource_size,
+          resource_format, color_space, raster_full_rect, playback_rect,
+          transform, playback_settings, worker_context_provider_);
     } else {
       RasterizeSource(raster_source, resource_has_previous_content, mailbox,
                       sync_token, texture_target, texture_is_overlay_candidate,
                       resource_size, resource_format, color_space,
                       raster_full_rect, playback_rect, transform,
                       playback_settings, worker_context_provider_,
-                      msaa_sample_count_,
                       ShouldUnpremultiplyAndDitherResource(resource_format),
                       max_tile_size_);
     }