summaryrefslogtreecommitdiffstats
path: root/chromium/cc/tiles/software_image_decode_cache.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-29 10:46:47 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-11-02 12:02:10 +0000
commit99677208ff3b216fdfec551fbe548da5520cd6fb (patch)
tree476a4865c10320249360e859d8fdd3e01833b03a /chromium/cc/tiles/software_image_decode_cache.cc
parentc30a6232df03e1efbd9f3b226777b07e087a1122 (diff)
BASELINE: Update Chromium to 86.0.4240.124
Change-Id: Ide0ff151e94cd665ae6521a446995d34a9d1d644 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/cc/tiles/software_image_decode_cache.cc')
-rw-r--r--chromium/cc/tiles/software_image_decode_cache.cc59
1 files changed, 45 insertions, 14 deletions
diff --git a/chromium/cc/tiles/software_image_decode_cache.cc b/chromium/cc/tiles/software_image_decode_cache.cc
index 412c1b02c3c..f2676e80db0 100644
--- a/chromium/cc/tiles/software_image_decode_cache.cc
+++ b/chromium/cc/tiles/software_image_decode_cache.cc
@@ -61,7 +61,8 @@ class SoftwareImageDecodeTaskImpl : public TileTask {
const PaintImage& paint_image,
SoftwareImageDecodeCache::DecodeTaskType task_type,
const ImageDecodeCache::TracingInfo& tracing_info)
- : TileTask(true),
+ : TileTask(TileTask::SupportsConcurrentExecution::kYes,
+ TileTask::SupportsBackgroundThreadPriority::kYes),
cache_(cache),
image_key_(image_key),
paint_image_(paint_image),
@@ -82,7 +83,7 @@ class SoftwareImageDecodeTaskImpl : public TileTask {
const ImageType image_type =
image_metadata ? image_metadata->image_type : ImageType::kInvalid;
devtools_instrumentation::ScopedImageDecodeTask image_decode_task(
- paint_image_.GetRasterSkImage().get(),
+ paint_image_.GetSwSkImage().get(),
devtools_instrumentation::ScopedImageDecodeTask::kSoftware,
ImageDecodeCache::ToScopedTaskType(tracing_info_.task_type),
ImageDecodeCache::ToScopedImageType(image_type));
@@ -181,7 +182,9 @@ SoftwareImageDecodeCache::GetTaskForImageAndRefInternal(
const DrawImage& image,
const TracingInfo& tracing_info,
DecodeTaskType task_type) {
- CacheKey key = CacheKey::FromDrawImage(image, color_type_);
+ CacheKey key = CacheKey::FromDrawImage(
+ image, GetColorTypeForPaintImage(image.target_color_space(),
+ image.paint_image()));
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
"SoftwareImageDecodeCache::GetTaskForImageAndRefInternal", "key",
key.ToString());
@@ -275,7 +278,9 @@ void SoftwareImageDecodeCache::RemoveBudgetForImage(const CacheKey& key,
}
void SoftwareImageDecodeCache::UnrefImage(const DrawImage& image) {
- const CacheKey& key = CacheKey::FromDrawImage(image, color_type_);
+ const CacheKey& key = CacheKey::FromDrawImage(
+ image, GetColorTypeForPaintImage(image.target_color_space(),
+ image.paint_image()));
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
"SoftwareImageDecodeCache::UnrefImage", "key", key.ToString());
@@ -348,7 +353,9 @@ SoftwareImageDecodeCache::DecodeImageIfNecessary(const CacheKey& key,
if (key.type() == CacheKey::kOriginal) {
base::AutoUnlock release(lock_);
local_cache_entry = Utils::DoDecodeImage(
- key, paint_image, color_type_, generator_client_id_,
+ key, paint_image,
+ GetColorTypeForPaintImage(key.target_color_space(), paint_image),
+ generator_client_id_,
base::BindOnce(&SoftwareImageDecodeCache::ClearCache,
base::Unretained(this)));
} else {
@@ -378,7 +385,9 @@ SoftwareImageDecodeCache::DecodeImageIfNecessary(const CacheKey& key,
if (should_decode_to_scale) {
base::AutoUnlock release(lock_);
local_cache_entry = Utils::DoDecodeImage(
- key, paint_image, color_type_, generator_client_id_,
+ key, paint_image,
+ GetColorTypeForPaintImage(key.target_color_space(), paint_image),
+ generator_client_id_,
base::BindOnce(&SoftwareImageDecodeCache::ClearCache,
base::Unretained(this)));
}
@@ -408,8 +417,9 @@ SoftwareImageDecodeCache::DecodeImageIfNecessary(const CacheKey& key,
DrawImage candidate_draw_image(
paint_image, src_rect, kNone_SkFilterQuality, SkMatrix::I(),
key.frame_key().frame_index(), key.target_color_space());
- candidate_key.emplace(
- CacheKey::FromDrawImage(candidate_draw_image, color_type_));
+ candidate_key.emplace(CacheKey::FromDrawImage(
+ candidate_draw_image,
+ GetColorTypeForPaintImage(key.target_color_space(), paint_image)));
}
if (candidate_key) {
@@ -426,7 +436,8 @@ SoftwareImageDecodeCache::DecodeImageIfNecessary(const CacheKey& key,
// already been done to generate the candidate.
local_cache_entry = Utils::GenerateCacheEntryFromCandidate(
key, decoded_draw_image,
- candidate_key->type() == CacheKey::kOriginal, color_type_);
+ candidate_key->type() == CacheKey::kOriginal,
+ GetColorTypeForPaintImage(key.target_color_space(), paint_image));
}
// Unref to balance the GetDecodedImageForDrawInternal() call.
@@ -497,14 +508,14 @@ SoftwareImageDecodeCache::FindCachedCandidate(const CacheKey& key) {
bool SoftwareImageDecodeCache::UseCacheForDrawImage(
const DrawImage& draw_image) const {
- sk_sp<SkImage> sk_image = draw_image.paint_image().GetSkImage();
+ PaintImage paint_image = draw_image.paint_image();
// Software cache doesn't support using texture backed images.
- if (sk_image->isTextureBacked())
+ if (paint_image.IsTextureBacked())
return false;
// Lazy generated images need to have their decode cached.
- if (sk_image->isLazyGenerated())
+ if (paint_image.IsLazyGenerated())
return true;
// Cache images that need to be converted to a non-sRGB color space.
@@ -525,7 +536,9 @@ DecodedDrawImage SoftwareImageDecodeCache::GetDecodedImageForDraw(
base::AutoLock hold(lock_);
return GetDecodedImageForDrawInternal(
- CacheKey::FromDrawImage(draw_image, color_type_),
+ CacheKey::FromDrawImage(
+ draw_image, GetColorTypeForPaintImage(draw_image.target_color_space(),
+ draw_image.paint_image())),
draw_image.paint_image());
}
@@ -565,7 +578,10 @@ void SoftwareImageDecodeCache::DrawWithImageFinished(
DCHECK(UseCacheForDrawImage(image));
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
"SoftwareImageDecodeCache::DrawWithImageFinished", "key",
- CacheKey::FromDrawImage(image, color_type_).ToString());
+ CacheKey::FromDrawImage(
+ image, GetColorTypeForPaintImage(image.target_color_space(),
+ image.paint_image()))
+ .ToString());
UnrefImage(image);
}
@@ -678,6 +694,21 @@ size_t SoftwareImageDecodeCache::GetNumCacheEntriesForTesting() {
return decoded_images_.size();
}
+SkColorType SoftwareImageDecodeCache::GetColorTypeForPaintImage(
+ const gfx::ColorSpace& target_color_space,
+ const PaintImage& paint_image) {
+ // Decode HDR images to half float when targeting HDR.
+ //
+ // TODO(crbug.com/1076568): Once we have access to the display's buffer format
+ // via gfx::DisplayColorSpaces, we should also do this for HBD images.
+ if (paint_image.GetContentColorUsage() == gfx::ContentColorUsage::kHDR &&
+ target_color_space.IsHDR()) {
+ return kRGBA_F16_SkColorType;
+ }
+
+ return color_type_;
+}
+
// MemoryBudget ----------------------------------------------------------------
SoftwareImageDecodeCache::MemoryBudget::MemoryBudget(size_t limit_bytes)
: limit_bytes_(limit_bytes), current_usage_bytes_(0u) {}