diff --git a/cc/paint/paint_image.h b/cc/paint/paint_image.h index 2e9e4b38ae6cf9..caa218e7ecc386 100644 --- a/cc/paint/paint_image.h +++ b/cc/paint/paint_image.h @@ -280,7 +280,6 @@ class CC_PAINT_EXPORT PaintImage { bool is_high_bit_depth() const { return is_high_bit_depth_; } bool may_be_lcp_candidate() const { return may_be_lcp_candidate_; } bool no_cache() const { return no_cache_; } - void set_no_cache(bool no_cache) { no_cache_ = no_cache; } int repetition_count() const { return repetition_count_; } bool ShouldAnimate() const; AnimationSequenceId reset_animation_sequence_id() const { diff --git a/cc/paint/paint_image_builder.h b/cc/paint/paint_image_builder.h index eeaaed0a502e27..b6bbf6069752c6 100644 --- a/cc/paint/paint_image_builder.h +++ b/cc/paint/paint_image_builder.h @@ -101,6 +101,10 @@ class CC_PAINT_EXPORT PaintImageBuilder { paint_image_.may_be_lcp_candidate_ = may_be_lcp_candidate; return std::move(*this); } + PaintImageBuilder&& set_no_cache(bool no_cache) { + paint_image_.no_cache_ = no_cache; + return std::move(*this); + } PaintImageBuilder&& set_repetition_count(int count) { paint_image_.repetition_count_ = count; return std::move(*this); diff --git a/cc/tiles/gpu_image_decode_cache_unittest.cc b/cc/tiles/gpu_image_decode_cache_unittest.cc index 25ba57d3207e5a..bbdb9bed5c62d0 100644 --- a/cc/tiles/gpu_image_decode_cache_unittest.cc +++ b/cc/tiles/gpu_image_decode_cache_unittest.cc @@ -24,6 +24,7 @@ #include "cc/paint/color_filter.h" #include "cc/paint/draw_image.h" #include "cc/paint/image_transfer_cache_entry.h" +#include "cc/paint/paint_image.h" #include "cc/paint/paint_image_builder.h" #include "cc/paint/paint_op_writer.h" #include "cc/test/fake_paint_image_generator.h" @@ -4882,9 +4883,12 @@ TEST_P(GpuImageDecodeCachePurgeOnTimerTest, NoDeadlock) { TEST_P(GpuImageDecodeCachePurgeOnTimerTest, NoCache) { const uint32_t client_id = cache_->GenerateClientId(); - PaintImage image = CreatePaintImageInternal(GetNormalImageSize()); - image.set_no_cache(true); - DrawImage draw_image = CreateDrawImageInternal(image); + PaintImage image_no_cache = + PaintImageBuilder::WithCopy( + CreatePaintImageInternal(GetNormalImageSize())) + .set_no_cache(true) + .TakePaintImage(); + DrawImage draw_image = CreateDrawImageInternal(image_no_cache); ImageDecodeCache::TaskResult result = cache_->GetTaskForImageAndRef( client_id, draw_image, ImageDecodeCache::TracingInfo()); diff --git a/pdf/pdf_view_web_plugin.cc b/pdf/pdf_view_web_plugin.cc index 6811cd5b0f7df5..cfa6a3cae983fd 100644 --- a/pdf/pdf_view_web_plugin.cc +++ b/pdf/pdf_view_web_plugin.cc @@ -1883,12 +1883,6 @@ void PdfViewWebPlugin::ClearDeferredInvalidates() { } void PdfViewWebPlugin::UpdateSnapshot(sk_sp snapshot) { - snapshot_ = - cc::PaintImageBuilder::WithDefault() - .set_image(std::move(snapshot), cc::PaintImage::GetNextContentId()) - .set_id(cc::PaintImage::GetNextId()) - .TakePaintImage(); - // Every time something changes (e.g. scale or scroll position), // `UpdateSnapshot()` is called, so the snapshot is effectively used only // once. Make it "no-cache" so that the old snapshots are not cached @@ -1899,7 +1893,12 @@ void PdfViewWebPlugin::UpdateSnapshot(sk_sp snapshot) { // service transfer cache. The size of the service transfer cache is bounded, // so on desktop this "only" causes a 256MiB memory spike, but it's completely // wasted memory nonetheless. - snapshot_.set_no_cache(true); + snapshot_ = + cc::PaintImageBuilder::WithDefault() + .set_image(std::move(snapshot), cc::PaintImage::GetNextContentId()) + .set_id(cc::PaintImage::GetNextId()) + .set_no_cache(true) + .TakePaintImage(); if (!plugin_rect_.IsEmpty()) InvalidatePluginContainer();