[cc] Make "no_cache" only accessible through PaintImageBuilder
This was suggested as a cleanup in https://chromium-review.googlesource.com/c/chromium/src/+/4683446. Let's do it, it's cleaner. Bug: 1464610 Change-Id: I375e65d38f4c9338d9c2aa43348596648109a52b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4907029 Reviewed-by: ccameron chromium <ccameron@chromium.org> Reviewed-by: K. Moon <kmoon@chromium.org> Commit-Queue: Benoit Lize <lizeb@chromium.org> Cr-Commit-Position: refs/heads/main@{#1205172}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
f398c68b02
commit
a706558653
@ -280,7 +280,6 @@ class CC_PAINT_EXPORT PaintImage {
|
|||||||
bool is_high_bit_depth() const { return is_high_bit_depth_; }
|
bool is_high_bit_depth() const { return is_high_bit_depth_; }
|
||||||
bool may_be_lcp_candidate() const { return may_be_lcp_candidate_; }
|
bool may_be_lcp_candidate() const { return may_be_lcp_candidate_; }
|
||||||
bool no_cache() const { return no_cache_; }
|
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_; }
|
int repetition_count() const { return repetition_count_; }
|
||||||
bool ShouldAnimate() const;
|
bool ShouldAnimate() const;
|
||||||
AnimationSequenceId reset_animation_sequence_id() const {
|
AnimationSequenceId reset_animation_sequence_id() const {
|
||||||
|
@ -101,6 +101,10 @@ class CC_PAINT_EXPORT PaintImageBuilder {
|
|||||||
paint_image_.may_be_lcp_candidate_ = may_be_lcp_candidate;
|
paint_image_.may_be_lcp_candidate_ = may_be_lcp_candidate;
|
||||||
return std::move(*this);
|
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) {
|
PaintImageBuilder&& set_repetition_count(int count) {
|
||||||
paint_image_.repetition_count_ = count;
|
paint_image_.repetition_count_ = count;
|
||||||
return std::move(*this);
|
return std::move(*this);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "cc/paint/color_filter.h"
|
#include "cc/paint/color_filter.h"
|
||||||
#include "cc/paint/draw_image.h"
|
#include "cc/paint/draw_image.h"
|
||||||
#include "cc/paint/image_transfer_cache_entry.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_image_builder.h"
|
||||||
#include "cc/paint/paint_op_writer.h"
|
#include "cc/paint/paint_op_writer.h"
|
||||||
#include "cc/test/fake_paint_image_generator.h"
|
#include "cc/test/fake_paint_image_generator.h"
|
||||||
@ -4882,9 +4883,12 @@ TEST_P(GpuImageDecodeCachePurgeOnTimerTest, NoDeadlock) {
|
|||||||
|
|
||||||
TEST_P(GpuImageDecodeCachePurgeOnTimerTest, NoCache) {
|
TEST_P(GpuImageDecodeCachePurgeOnTimerTest, NoCache) {
|
||||||
const uint32_t client_id = cache_->GenerateClientId();
|
const uint32_t client_id = cache_->GenerateClientId();
|
||||||
PaintImage image = CreatePaintImageInternal(GetNormalImageSize());
|
PaintImage image_no_cache =
|
||||||
image.set_no_cache(true);
|
PaintImageBuilder::WithCopy(
|
||||||
DrawImage draw_image = CreateDrawImageInternal(image);
|
CreatePaintImageInternal(GetNormalImageSize()))
|
||||||
|
.set_no_cache(true)
|
||||||
|
.TakePaintImage();
|
||||||
|
DrawImage draw_image = CreateDrawImageInternal(image_no_cache);
|
||||||
|
|
||||||
ImageDecodeCache::TaskResult result = cache_->GetTaskForImageAndRef(
|
ImageDecodeCache::TaskResult result = cache_->GetTaskForImageAndRef(
|
||||||
client_id, draw_image, ImageDecodeCache::TracingInfo());
|
client_id, draw_image, ImageDecodeCache::TracingInfo());
|
||||||
|
@ -1883,12 +1883,6 @@ void PdfViewWebPlugin::ClearDeferredInvalidates() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PdfViewWebPlugin::UpdateSnapshot(sk_sp<SkImage> snapshot) {
|
void PdfViewWebPlugin::UpdateSnapshot(sk_sp<SkImage> 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),
|
// Every time something changes (e.g. scale or scroll position),
|
||||||
// `UpdateSnapshot()` is called, so the snapshot is effectively used only
|
// `UpdateSnapshot()` is called, so the snapshot is effectively used only
|
||||||
// once. Make it "no-cache" so that the old snapshots are not cached
|
// once. Make it "no-cache" so that the old snapshots are not cached
|
||||||
@ -1899,7 +1893,12 @@ void PdfViewWebPlugin::UpdateSnapshot(sk_sp<SkImage> snapshot) {
|
|||||||
// service transfer cache. The size of the service transfer cache is bounded,
|
// 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
|
// so on desktop this "only" causes a 256MiB memory spike, but it's completely
|
||||||
// wasted memory nonetheless.
|
// 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())
|
if (!plugin_rect_.IsEmpty())
|
||||||
InvalidatePluginContainer();
|
InvalidatePluginContainer();
|
||||||
|
Reference in New Issue
Block a user