2018-01-03 20:35:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkRectPriv_DEFINED
|
|
|
|
#define SkRectPriv_DEFINED
|
|
|
|
|
|
|
|
#include "SkRect.h"
|
|
|
|
|
|
|
|
class SkRectPriv {
|
|
|
|
public:
|
2018-01-17 17:20:04 +00:00
|
|
|
// Returns an irect that is very large, and can be safely round-trip with SkRect and still
|
|
|
|
// be considered non-empty (i.e. width/height > 0) even if we round-out the SkRect.
|
|
|
|
static SkIRect MakeILarge() {
|
|
|
|
// SK_MaxS32 >> 1 seemed better, but it did not survive round-trip with SkRect and rounding.
|
|
|
|
// Also, 1 << 29 can be perfectly represented in float, while SK_MaxS32 >> 1 cannot.
|
|
|
|
const int32_t large = 1 << 29;
|
|
|
|
return { -large, -large, large, large };
|
2018-01-09 20:36:51 +00:00
|
|
|
}
|
2018-01-08 20:05:02 +00:00
|
|
|
|
2018-01-09 20:36:51 +00:00
|
|
|
static SkIRect MakeILargestInverted() {
|
|
|
|
return { SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32 };
|
2018-01-08 20:05:02 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 17:20:04 +00:00
|
|
|
static SkRect MakeLargeS32() {
|
2018-01-09 20:36:51 +00:00
|
|
|
SkRect r;
|
2018-01-17 17:20:04 +00:00
|
|
|
r.set(MakeILarge());
|
2018-01-09 20:36:51 +00:00
|
|
|
return r;
|
2018-01-08 20:05:02 +00:00
|
|
|
}
|
|
|
|
|
2018-01-09 20:36:51 +00:00
|
|
|
static SkRect MakeLargest() {
|
|
|
|
return { SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax };
|
2018-01-08 20:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static SkRect MakeLargestInverted() {
|
|
|
|
return { SK_ScalarMax, SK_ScalarMax, SK_ScalarMin, SK_ScalarMin };
|
|
|
|
}
|
|
|
|
|
2018-01-08 22:09:54 +00:00
|
|
|
static void GrowToInclude(SkRect* r, const SkPoint& pt) {
|
|
|
|
r->fLeft = SkMinScalar(pt.fX, r->fLeft);
|
|
|
|
r->fRight = SkMaxScalar(pt.fX, r->fRight);
|
|
|
|
r->fTop = SkMinScalar(pt.fY, r->fTop);
|
|
|
|
r->fBottom = SkMaxScalar(pt.fY, r->fBottom);
|
|
|
|
}
|
2018-01-03 20:35:33 +00:00
|
|
|
};
|
|
|
|
|
2018-01-08 20:05:02 +00:00
|
|
|
|
2018-01-03 20:35:33 +00:00
|
|
|
#endif
|