0

Check result of Sk[I]Rect::intersect

https://skia-review.googlesource.com/c/skia/+/589412 will be adding
[[nodiscard]] to these functions.

Bug: skia:11782
Change-Id: I450154cc651e0f0375b5e690e4d815a97960e911
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798849
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Cr-Commit-Position: refs/heads/main@{#1344282}
This commit is contained in:
Michael Ludwig
2024-08-20 18:21:30 +00:00
committed by Chromium LUCI CQ
parent dc05420a7b
commit 3927c5eff6
3 changed files with 8 additions and 10 deletions
skia/ext
third_party/blink/renderer/modules/canvas/canvas2d

@ -83,13 +83,8 @@ void DrawGainmapImageRect(SkCanvas* canvas,
// Compute `dest_rect_clipped` to be intersected with the pre-image of the
// clip rect of `canvas`.
SkRect dest_rect_clipped = dest_rect;
const SkMatrix& dest_to_device = canvas->getTotalMatrix();
SkMatrix device_to_dest;
if (dest_to_device.invert(&device_to_dest)) {
SkRect dest_clip_rect;
device_to_dest.mapRect(&dest_clip_rect,
SkRect::Make(canvas->getDeviceClipBounds()));
dest_rect_clipped.intersect(dest_clip_rect);
if (!dest_rect_clipped.intersect(canvas->getLocalClipBounds())) {
return;
}
// Compute the input rect for the base and gainmap images.

@ -91,7 +91,10 @@ void Tiling::GetTileRect(
dest_rect_.y() + y * tile_size_.height(),
dest_rect_.x() + (x + 1) * tile_size_.width(),
dest_rect_.y() + (y + 1) * tile_size_.height());
tile_dest_rect.intersect(dest_rect_);
if (!tile_dest_rect.intersect(dest_rect_)) {
tile_dest_rect = SkRect::MakeEmpty();
return;
}
tile_source_rects.resize(source_count_);
tile_source_subset_rects.resize(source_count_);

@ -927,8 +927,8 @@ ALWAYS_INLINE void BaseRenderingContext2D::ResetAlphaIfNeeded(
if (!c->getLocalClipBounds(&alpha_bounds)) {
return;
}
if (bounds) {
alpha_bounds.intersect(gfx::RectFToSkRect(*bounds));
if (bounds && !alpha_bounds.intersect(gfx::RectFToSkRect(*bounds))) {
return;
}
c->drawRect(alpha_bounds, flags);
}