Commit 14a51794 authored by Jonah Chin's avatar Jonah Chin Committed by Commit Bot

Fix GetSkImage() related crashes in virtual/oopr-canvas2D tests

Replace various PaintImage::GetSkImage() callers with direct PaintImage
equivalents.

More details about overall PaintImage effort: crbug.com/1023259
Info about the OOPR-Canvas2D project: crbug.com/1018894

Bug: 1031050
Change-Id: I0a673e7171c5162c58e5496662b73cd96e5072e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2337677
Commit-Queue: Jonah Chin <jochin@microsoft.com>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795246}
parent 6a380975
......@@ -261,7 +261,7 @@ class CC_PAINT_EXPORT PaintImage {
return paint_worklet_input_ || !!GetSkImage() || texture_backing_;
}
bool IsLazyGenerated() const {
return paint_worklet_input_ ? false : GetSkImage()->isLazyGenerated();
return paint_record_ || paint_image_generator_;
}
bool IsPaintWorklet() const { return !!paint_worklet_input_; }
bool IsTextureBacked() const;
......
......@@ -508,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.
......
......@@ -239,13 +239,8 @@ void AcceleratedStaticBitmapImage::Draw(
}
bool AcceleratedStaticBitmapImage::IsValid() const {
// TODO: Remove explicit cast after http://review.skia.org/304776 lands.
if (texture_backing_ && (!skia_context_provider_wrapper_ ||
!texture_backing_->GetAcceleratedSkImage()->isValid(
static_cast<GrRecordingContext*>(
ContextProvider()->GetGrContext())))) {
if (texture_backing_ && !skia_context_provider_wrapper_)
return false;
}
if (mailbox_ref_->is_cross_thread()) {
// If context is is from another thread, validity cannot be verified. Just
......
......@@ -29,7 +29,7 @@ sk_sp<PaintShader> ImagePattern::CreateShader(const SkMatrix& local_matrix) {
}
bool ImagePattern::IsTextureBacked() const {
return tile_image_ && tile_image_.GetSkImage()->isTextureBacked();
return tile_image_ && tile_image_.IsTextureBacked();
}
} // namespace blink
......@@ -39,8 +39,7 @@ void MemoryManagedPaintCanvas::UpdateMemoryUsage(const cc::PaintImage& image) {
return;
cached_image_ids_.insert(image.GetContentIdForFrame(0u));
total_stored_image_memory_ +=
image.GetSkImage()->imageInfo().computeMinByteSize();
total_stored_image_memory_ += image.GetSkImageInfo().computeMinByteSize();
if (total_stored_image_memory_ > kMaxPinnedMemory)
set_needs_flush_callback_.Run();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment