0

remove legacy Rect param flag

Update callsites.

Change-Id: I2ebaf88c479c0a8c20953f77fae00cdb77835fee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769212
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691084}
This commit is contained in:
Mike Reed
2019-08-28 09:05:30 +00:00
committed by Commit Bot
parent d042c5eae3
commit 01efa11118
16 changed files with 68 additions and 76 deletions

@ -1991,7 +1991,7 @@ bool PaintOp::GetBounds(const PaintOp* op, SkRect* rect) {
}
case PaintOpType::DrawLine: {
auto* line_op = static_cast<const DrawLineOp*>(op);
rect->set(line_op->x0, line_op->y0, line_op->x1, line_op->y1);
rect->setLTRB(line_op->x0, line_op->y0, line_op->x1, line_op->y1);
rect->sort();
return true;
}

@ -20,7 +20,7 @@ void DrawSelectionRect(const SkBitmap& bitmap, const blink::WebRect& wr) {
flags.setAntiAlias(true);
flags.setStrokeWidth(1.0f);
SkIRect rect; // Bounding rect
rect.set(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height);
rect.setXYWH(wr.x, wr.y, wr.width, wr.height);
canvas.drawIRect(rect, flags);
}

@ -86,8 +86,7 @@ blink::WebSize MockWebThemeEngine::GetSize(WebThemeEngine::Part part) {
static SkIRect webRectToSkIRect(const WebRect& webRect) {
SkIRect irect;
irect.set(webRect.x, webRect.y, webRect.x + webRect.width - 1,
webRect.y + webRect.height - 1);
irect.setXYWH(webRect.x, webRect.y, webRect.width - 1, webRect.height - 1);
return irect;
}
@ -229,8 +228,8 @@ void nestedBoxes(cc::PaintCanvas* canvas,
SkColor innerColor) {
SkIRect lirect;
box(canvas, irect, outerColor);
lirect.set(irect.fLeft + indentLeft, irect.fTop + indentTop,
irect.fRight - indentRight, irect.fBottom - indentBottom);
lirect.setLTRB(irect.fLeft + indentLeft, irect.fTop + indentTop,
irect.fRight - indentRight, irect.fBottom - indentBottom);
box(canvas, lirect, innerColor);
}
@ -242,8 +241,8 @@ void insetBox(cc::PaintCanvas* canvas,
int indentBottom,
SkColor color) {
SkIRect lirect;
lirect.set(irect.fLeft + indentLeft, irect.fTop + indentTop,
irect.fRight - indentRight, irect.fBottom - indentBottom);
lirect.setLTRB(irect.fLeft + indentLeft, irect.fTop + indentTop,
irect.fRight - indentRight, irect.fBottom - indentBottom);
box(canvas, lirect, color);
}
@ -552,8 +551,8 @@ void MockWebThemeEngine::Paint(cc::PaintCanvas* canvas,
if (extraParams->inner_spin.read_only)
state = blink::WebThemeEngine::kStateDisabled;
lirect.set(rect.x, rect.y, rect.x + rect.width - 1,
rect.y + halfHeight - 1);
lirect.setLTRB(rect.x, rect.y, rect.x + rect.width - 1,
rect.y + halfHeight - 1);
box(canvas, lirect, bgColors(state));
bottom = lirect.fBottom;
quarterHeight = lirect.height() / 4;
@ -561,8 +560,8 @@ void MockWebThemeEngine::Paint(cc::PaintCanvas* canvas,
right - quarterWidth, bottom - quarterHeight, left + halfWidth,
top + quarterHeight, edgeColor);
lirect.set(rect.x, rect.y + halfHeight, rect.x + rect.width - 1,
rect.y + 2 * halfHeight - 1);
lirect.setLTRB(rect.x, rect.y + halfHeight, rect.x + rect.width - 1,
rect.y + 2 * halfHeight - 1);
top = lirect.fTop;
bottom = lirect.fBottom;
quarterHeight = lirect.height() / 4;
@ -581,11 +580,9 @@ void MockWebThemeEngine::Paint(cc::PaintCanvas* canvas,
// Emulate clipping
SkIRect tofill = irect;
if (extraParams->progress_bar.determinate) {
tofill.set(extraParams->progress_bar.value_rect_x,
extraParams->progress_bar.value_rect_y,
extraParams->progress_bar.value_rect_x +
tofill.setXYWH(extraParams->progress_bar.value_rect_x,
extraParams->progress_bar.value_rect_y,
extraParams->progress_bar.value_rect_width - 1,
extraParams->progress_bar.value_rect_y +
extraParams->progress_bar.value_rect_height);
}

@ -1085,10 +1085,8 @@ SkRegion* AppWindow::RawDraggableRegionsToSkRegion(
for (auto iter = regions.cbegin(); iter != regions.cend(); ++iter) {
const DraggableRegion& region = *iter;
sk_region->op(
region.bounds.x(),
region.bounds.y(),
region.bounds.right(),
region.bounds.bottom(),
SkIRect::MakeLTRB(region.bounds.x(), region.bounds.y(),
region.bounds.right(), region.bounds.bottom()),
region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
}
return sk_region;

@ -558,7 +558,8 @@ void PaintCanvasVideoRenderer::Paint(scoped_refptr<VideoFrame> video_frame,
}
SkRect dest;
dest.set(dest_rect.x(), dest_rect.y(), dest_rect.right(), dest_rect.bottom());
dest.setLTRB(dest_rect.x(), dest_rect.y(), dest_rect.right(),
dest_rect.bottom());
// Paint black rectangle if there isn't a frame available or the
// frame has an unexpected format.

@ -215,10 +215,6 @@ SK_API void SkDebugf_FileLine(const char* file,
#define SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS
#endif
#ifndef SK_SUPPORT_LEGACY_RECT_PARAMS
#define SK_SUPPORT_LEGACY_RECT_PARAMS
#endif
// Max. verb count for paths rendered by the edge-AA tessellating path renderer.
#define GR_AA_TESSELLATOR_MAX_VERB_COUNT 100

@ -134,8 +134,8 @@ void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
// intersected with any existing clip.
void AddClip(SkCanvas& canvas, int x, int y, int w, int h) {
SkRect rect;
rect.set(SkIntToScalar(x), SkIntToScalar(y),
SkIntToScalar(x + w), SkIntToScalar(y + h));
rect.setXYWH(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(w),
SkIntToScalar(h));
canvas.clipRect(rect);
}
@ -148,8 +148,8 @@ class LayerSaver {
w_(w),
h_(h) {
SkRect bounds;
bounds.set(SkIntToScalar(x_), SkIntToScalar(y_),
SkIntToScalar(right()), SkIntToScalar(bottom()));
bounds.setLTRB(SkIntToScalar(x_), SkIntToScalar(y_), SkIntToScalar(right()),
SkIntToScalar(bottom()));
canvas_.saveLayer(&bounds, NULL);
canvas.clear(SkColorSetARGB(0, 0, 0, 0));
}

@ -225,7 +225,7 @@ cc::PaintCanvas* OffscreenCanvasRenderingContext2D::ExistingDrawingCanvas()
void OffscreenCanvasRenderingContext2D::DidDraw() {
Host()->DidDraw();
dirty_rect_for_commit_.set(0, 0, Width(), Height());
dirty_rect_for_commit_.setWH(Width(), Height());
}
void OffscreenCanvasRenderingContext2D::DidDraw(const SkIRect& dirty_rect) {

@ -640,13 +640,14 @@ static void EnforceDotsAtEndpoints(GraphicsContext& context,
if (use_start_dot) {
SkRect start_dot;
if (is_vertical_line) {
start_dot.set(p1.X() - width / 2, p1.Y(), p1.X() + width - width / 2,
p1.Y() + width + start_dot_growth);
start_dot.setLTRB(p1.X() - width / 2, p1.Y(),
p1.X() + width - width / 2,
p1.Y() + width + start_dot_growth);
p1.SetY(p1.Y() + (2 * width + start_line_offset));
} else {
start_dot.set(p1.X(), p1.Y() - width / 2,
p1.X() + width + start_dot_growth,
p1.Y() + width - width / 2);
start_dot.setLTRB(p1.X(), p1.Y() - width / 2,
p1.X() + width + start_dot_growth,
p1.Y() + width - width / 2);
p1.SetX(p1.X() + (2 * width + start_line_offset));
}
context.DrawRect(start_dot, fill_flags);
@ -654,13 +655,13 @@ static void EnforceDotsAtEndpoints(GraphicsContext& context,
if (use_end_dot) {
SkRect end_dot;
if (is_vertical_line) {
end_dot.set(p2.X() - width / 2, p2.Y() - width - end_dot_growth,
p2.X() + width - width / 2, p2.Y());
end_dot.setLTRB(p2.X() - width / 2, p2.Y() - width - end_dot_growth,
p2.X() + width - width / 2, p2.Y());
// Be sure to stop drawing before we get to the last dot
p2.SetY(p2.Y() - (width + end_dot_growth + 1));
} else {
end_dot.set(p2.X() - width - end_dot_growth, p2.Y() - width / 2, p2.X(),
p2.Y() + width - width / 2);
end_dot.setLTRB(p2.X() - width - end_dot_growth, p2.Y() - width / 2,
p2.X(), p2.Y() + width - width / 2);
// Be sure to stop drawing before we get to the last dot
p2.SetX(p2.X() - (width + end_dot_growth + 1));
}

@ -360,8 +360,8 @@ void Path::AddEllipse(const FloatPoint& p,
SkScalar radius_y_scalar = WebCoreFloatToSkScalar(radius_y);
SkRect oval;
oval.set(cx - radius_x_scalar, cy - radius_y_scalar, cx + radius_x_scalar,
cy + radius_y_scalar);
oval.setLTRB(cx - radius_x_scalar, cy - radius_y_scalar, cx + radius_x_scalar,
cy + radius_y_scalar);
float sweep = end_angle - start_angle;
SkScalar start_degrees = WebCoreFloatToSkScalar(start_angle * 180 / kPiFloat);

@ -31,7 +31,7 @@ class DrawsRectangleCanvas : public SkCanvas {
getTotalMatrix().mapRectToQuad(quad, rect);
SkRect device_rect;
device_rect.set(quad, 4);
device_rect.setBounds(quad, 4);
SkIRect device_clip_bounds;
FloatRect clipped_rect;
if (getDeviceClipBounds(&device_clip_bounds) &&

@ -838,8 +838,8 @@ bool Window::HitTest(const gfx::Point& local_point) {
delegate_->GetHitTestMask(&mask);
SkRegion clip_region;
clip_region.setRect(local_bounds.x(), local_bounds.y(),
local_bounds.width(), local_bounds.height());
clip_region.setRect({local_bounds.x(), local_bounds.y(), local_bounds.width(),
local_bounds.height()});
SkRegion mask_region;
return mask_region.setPath(mask, clip_region) &&
mask_region.contains(local_point.x(), local_point.y());

@ -70,7 +70,7 @@ class WindowOcclusionChangeBuilderTest : public test::AuraTestBase {
// Test that window occlusion info is updated after commit.
TEST_F(WindowOcclusionChangeBuilderTest, SingleWindow) {
SkRegion region;
region.setRect(1, 2, 3, 4);
region.setRect({1, 2, 3, 4});
for (const auto state :
{Window::OcclusionState::VISIBLE, Window::OcclusionState::OCCLUDED,
@ -101,14 +101,14 @@ TEST_F(WindowOcclusionChangeBuilderTest, MultipleWindow) {
auto window1 = CreateTestWindow(&delegate1);
const Window::OcclusionState state1 = Window::OcclusionState::VISIBLE;
SkRegion region1;
region1.setRect(1, 2, 3, 4);
region1.setRect({1, 2, 3, 4});
builder->Add(window1.get(), state1, region1);
OcclusionTrackWindowDelegate delegate2;
auto window2 = CreateTestWindow(&delegate2);
const Window::OcclusionState state2 = Window::OcclusionState::OCCLUDED;
SkRegion region2;
region2.setRect(5, 6, 7, 8);
region2.setRect({5, 6, 7, 8});
builder->Add(window2.get(), state2, region2);
// Changes should not be applied before Commit call.
@ -138,7 +138,7 @@ TEST_F(WindowOcclusionChangeBuilderTest, MultipleChanges) {
builder->Add(window.get(), Window::OcclusionState::HIDDEN, SkRegion());
SkRegion region;
region.setRect(1, 2, 3, 4);
region.setRect({1, 2, 3, 4});
builder->Add(window.get(), Window::OcclusionState::OCCLUDED, region);
// All changes are committed when builder is released.

@ -49,8 +49,10 @@ SkColor NativeThemeAndroid::GetSystemColor(ColorId color_id,
void NativeThemeAndroid::AdjustCheckboxRadioRectForPadding(SkRect* rect) const {
// Take 1px for padding around the checkbox/radio button.
rect->iset(rect->x() + 1, rect->y() + 1, rect->right() - 1,
rect->bottom() - 1);
rect->setLTRB(static_cast<int>(rect->x()) + 1,
static_cast<int>(rect->y()) + 1,
static_cast<int>(rect->right()) - 1,
static_cast<int>(rect->bottom()) - 1);
}
NativeThemeAndroid::NativeThemeAndroid() {

@ -308,8 +308,7 @@ void NativeThemeBase::PaintArrowButton(
}
SkIRect skrect;
skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y()
+ rect.height());
skrect.setXYWH(rect.x(), rect.y(), rect.width(), rect.height());
// Paint the background (the area visible behind the rounded corners).
flags.setColor(backgroundColor);
canvas->drawIRect(skrect, flags);
@ -435,7 +434,7 @@ void NativeThemeBase::PaintScrollbarTrack(
cc::PaintFlags flags;
SkIRect skrect;
skrect.set(rect.x(), rect.y(), rect.right(), rect.bottom());
skrect.setLTRB(rect.x(), rect.y(), rect.right(), rect.bottom());
SkScalar track_hsv[3];
SkColorToHSV(kTrackColor, track_hsv);
flags.setColor(SaturateAndBrighten(track_hsv, 0, 0));
@ -467,20 +466,20 @@ void NativeThemeBase::PaintScrollbarThumb(cc::PaintCanvas* canvas,
SkIRect skrect;
if (vertical)
skrect.set(rect.x(), rect.y(), midx + 1, rect.y() + rect.height());
skrect.setLTRB(rect.x(), rect.y(), midx + 1, rect.y() + rect.height());
else
skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), midy + 1);
skrect.setLTRB(rect.x(), rect.y(), rect.x() + rect.width(), midy + 1);
canvas->drawIRect(skrect, flags);
flags.setColor(SaturateAndBrighten(thumb, 0, -0.02f));
if (vertical) {
skrect.set(
midx + 1, rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
skrect.setLTRB(midx + 1, rect.y(), rect.x() + rect.width(),
rect.y() + rect.height());
} else {
skrect.set(
rect.x(), midy + 1, rect.x() + rect.width(), rect.y() + rect.height());
skrect.setLTRB(rect.x(), midy + 1, rect.x() + rect.width(),
rect.y() + rect.height());
}
canvas->drawIRect(skrect, flags);
@ -729,7 +728,7 @@ void NativeThemeBase::PaintTextField(cc::PaintCanvas* canvas,
const TextFieldExtraParams& text,
ColorScheme color_scheme) const {
SkRect bounds;
bounds.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1);
bounds.setLTRB(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1);
cc::PaintFlags fill_flags;
fill_flags.setStyle(cc::PaintFlags::kFill_Style);
@ -823,15 +822,11 @@ void NativeThemeBase::PaintSliderTrack(cc::PaintCanvas* canvas,
SkRect skrect;
if (slider.vertical) {
skrect.set(std::max(rect.x(), kMidX - 2),
rect.y(),
std::min(rect.right(), kMidX + 2),
rect.bottom());
skrect.setLTRB(std::max(rect.x(), kMidX - 2), rect.y(),
std::min(rect.right(), kMidX + 2), rect.bottom());
} else {
skrect.set(rect.x(),
std::max(rect.y(), kMidY - 2),
rect.right(),
std::min(rect.bottom(), kMidY + 2));
skrect.setLTRB(rect.x(), std::max(rect.y(), kMidY - 2), rect.right(),
std::min(rect.bottom(), kMidY + 2));
}
canvas->drawRect(skrect, flags);
}
@ -850,18 +845,18 @@ void NativeThemeBase::PaintSliderThumb(cc::PaintCanvas* canvas,
SkIRect skrect;
if (slider.vertical)
skrect.set(rect.x(), rect.y(), kMidX + 1, rect.bottom());
skrect.setLTRB(rect.x(), rect.y(), kMidX + 1, rect.bottom());
else
skrect.set(rect.x(), rect.y(), rect.right(), kMidY + 1);
skrect.setLTRB(rect.x(), rect.y(), rect.right(), kMidY + 1);
canvas->drawIRect(skrect, flags);
flags.setColor(hovered ? kSliderThumbLightGrey : kSliderThumbDarkGrey);
if (slider.vertical)
skrect.set(kMidX + 1, rect.y(), rect.right(), rect.bottom());
skrect.setLTRB(kMidX + 1, rect.y(), rect.right(), rect.bottom());
else
skrect.set(rect.x(), kMidY + 1, rect.right(), rect.bottom());
skrect.setLTRB(rect.x(), kMidY + 1, rect.right(), rect.bottom());
canvas->drawIRect(skrect, flags);
@ -959,7 +954,9 @@ void NativeThemeBase::PaintFrameTopArea(
void NativeThemeBase::AdjustCheckboxRadioRectForPadding(SkRect* rect) const {
// By default we only take 1px from right and bottom for the drop shadow.
rect->iset(rect->x(), rect->y(), rect->right() - 1, rect->bottom() - 1);
rect->setLTRB(static_cast<int>(rect->x()), static_cast<int>(rect->y()),
static_cast<int>(rect->right()) - 1,
static_cast<int>(rect->bottom()) - 1);
}
SkColor NativeThemeBase::SaturateAndBrighten(SkScalar* hsv,
@ -990,7 +987,7 @@ void NativeThemeBase::DrawVertLine(cc::PaintCanvas* canvas,
int y2,
const cc::PaintFlags& flags) const {
SkIRect skrect;
skrect.set(x, y1, x + 1, y2 + 1);
skrect.setLTRB(x, y1, x + 1, y2 + 1);
canvas->drawIRect(skrect, flags);
}
@ -1000,7 +997,7 @@ void NativeThemeBase::DrawHorizLine(cc::PaintCanvas* canvas,
int y,
const cc::PaintFlags& flags) const {
SkIRect skrect;
skrect.set(x1, y, x2 + 1, y + 1);
skrect.setLTRB(x1, y, x2 + 1, y + 1);
canvas->drawIRect(skrect, flags);
}

@ -25,7 +25,7 @@ bool MaskedTargeterDelegate::DoesIntersectRect(const View* target,
// Return whether or not |rect| intersects the custom hit test mask
// of |target|.
SkRegion clip_region;
clip_region.setRect(0, 0, target->width(), target->height());
clip_region.setRect({0, 0, target->width(), target->height()});
SkRegion mask_region;
return mask_region.setPath(mask, clip_region) &&
mask_region.intersects(RectToSkIRect(rect));