26#include <initializer_list>
30 for (
int j = 0; j < bm.
height(); ++j) {
31 for (
int i = 0;
i < bm.
width(); ++
i) {
49 paint.setStrokeWidth(10);
50 paint.setColor(0xff00ff00);
71 const SkRect r = { 1.5f, 1, 3.5f, 3 };
75 paint.setColor(0xff00ff00);
76 paint.setStrokeWidth(1);
77 paint.setAntiAlias(
true);
83 paint.setColor(0xff000000);
84 paint.setStrokeWidth(1);
90 paint.setColor(0xff00ff00);
91 paint.setStrokeWidth(1);
92 paint.setAntiAlias(
true);
97 paint.setColor(0xff000000);
98 paint.setStrokeWidth(0.99f);
142 const SkRect zeror = { 0, 0, 0, 0 };
143 for (
const SkPoint* pts : { p0, p1, p2, p3 }) {
144 for (
int n = 1; n <= 4; ++n) {
167 const SkRect r = { -big, -big, big, big };
193 Expectation
tests[] = {
197 {
a, {6, 6, 10, 10}, {2, 10, 12, 15},
false},
205 {
a, {15, 17, 20, 40},
a,
true},
207 {
a, {0, 0, 6, 20}, {6, 3, 12, 15},
true},
209 {
a, {6, 0, 20, 20}, {2, 3, 6, 15},
true},
211 {
a, {0, 0, 20, 6}, {2, 6, 12, 15},
true},
213 {
a, {0, 10, 20, 20}, {2, 3, 12, 10},
true},
215 {
a, {0, 6, 20, 10}, {2, 10, 12, 15},
false},
217 {
a, {6, 0, 10, 20}, {2, 3, 6, 15},
false},
219 {
a, {0, 0, 4, 4}, {2, 4, 12, 15},
false},
221 {
a, {10, 0, 14, 7}, {2, 3, 10, 15},
false},
223 {
a, {0, 12, 5, 20}, {2, 3, 12, 12},
false},
225 {
a, {10, 12, 20, 20}, {2, 3, 10, 15},
false},
227 {
a, {0, 6, 8, 10}, {2, 10, 12, 15},
false},
229 {
a, {8, 6, 20, 10}, {2, 3, 8, 15},
false},
231 {
a, {6, 0, 10, 7}, {2, 7, 12, 15},
false},
233 {
a, {4, 6, 8, 20}, {8, 3, 12, 15},
false}
236 for (
const Expectation&
e :
tests) {
294 {
"Identity matrix contains success",
true,
297 {
"Identity matrix contains failure",
false,
300 {
"Identity mapped rect contains itself",
true,
303 {
"Scaled rect contains success",
true,
304 SkMatrix::Scale(2.f, 3.4f), {0,0,4,4}, {1,1,6,6}},
306 {
"Scaled rect contains failure",
false,
307 SkMatrix::Scale(0.25f, 0.3f), {0,0,8,8}, {0,0,5,5}},
309 {
"Rotate rect contains success",
true,
310 SkMatrix::RotateDeg(45.f, {10.f, 10.f}), {0,0,20,20}, {3,3,17,17}},
312 {
"Rotate rect contains failure",
false,
313 SkMatrix::RotateDeg(45.f, {10.f, 10.f}), {0,0,20,20}, {2,2,18,18}},
315 {
"Negative scale contains success",
true,
316 SkMatrix::Scale(-1.f, 1.f), {0,0,10,10}, {-9,1,-1,9}},
318 {
"Empty rect contains nothing",
false,
319 SkMatrix::RotateDeg(45.f, {0.f, 0.f}), {10,10,10,20}, {10,14,10,16}},
321 {
"MakeEmpty() contains nothing",
false,
324 {
"Unsorted rect contains nothing",
false,
327 {
"Unsorted rect is contained",
true,
332 {
"Epsilon not contained",
true,
334 -0.173648f, 0.984808f, 17.3648f,
335 0.000000f, 0.000000f, 1.0000f)
337 {0, 0, 134, 215}, {0, 0, 100, 200}, 0.001f},
346 SkVector bOffset = t.m.mapVector(0.5f, 0.5f);
356 bOffset = t.m.mapVector(0.5f, 0.5f);
372 p.preTranslate(0.f, 5.f, -0.1f);
381 p.setRow(3, {-.2f, -.6f, 0.f, 8.f});
392 p.setRow(3, {-.2f, -.6f, 0.f, 8.f});
393 const SkRect na =
a.makeOffset(16.f, 31.f);
408 static constexpr SkIRect kSrc = {0,0,10,10};
410 {
"src left edge", {-15, -5, -2, 15}, {0, 0, 1, 10}},
411 {
"src left edge clipped to dst", {-15, 2, -2, 8}, {0, 2, 1, 8}},
412 {
"src top-left corner", {-15,-15, -2, -2}, {0, 0, 1, 1}},
413 {
"src top edge", { -5,-10, 15, -2}, {0, 0, 10, 1}},
414 {
"src top edge clipped to dst", { 2,-10, 8, -2}, {2, 0, 8, 1}},
415 {
"src top-right corner", { 15,-15, 20, -2}, {9, 0, 10, 1}},
416 {
"src right edge", { 15, -5, 20, 15}, {9, 0, 10, 10}},
417 {
"src right edge clipped to dst", { 15, 2, 20, 8}, {9, 2, 10, 8}},
418 {
"src bottom-right corner", { 15, 15, 20, 20}, {9, 9, 10, 10}},
419 {
"src bottom edge", { -5, 15, 15, 20}, {0, 9, 10, 10}},
420 {
"src bottom edge clipped to dst", { 2, 15, 8, 20}, {2, 9, 8, 10}},
421 {
"src bottom-left corner", {-15, 15, -2, 20}, {0, 9, 1, 10}},
422 {
"src intersects dst high", { 2, 2, 15, 15}, {2, 2, 10, 10}},
423 {
"src intersects dst low", { -5, -5, 8, 8}, {0, 0, 8, 8}},
424 {
"src contains dst", { 2, 2, 8, 8}, {2, 2, 8, 8}},
425 {
"src contained in dst", { -5, -5, 15, 15}, {0, 0, 10, 10}}
446 if (
sizeof(
void*) == 8) {
447 const int w = 67108863;
452 auto canvas = surf->getCanvas();
454 const SkRect r = { 257, 213, 67109120, 214 };
456 paint.setAntiAlias(
true);
459 canvas->drawRect(r,
paint);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static void test_stroke_width_clipping(skiatest::Reporter *reporter)
static void test_skbug4406(skiatest::Reporter *reporter)
static float make_big_value(skiatest::Reporter *reporter)
static bool has_green_pixels(const SkBitmap &bm)
#define SkColorGetG(color)
constexpr SkColor SK_ColorTRANSPARENT
static bool SkIsFinite(T x, Pack... values)
static size_t difference(size_t minuend, size_t subtrahend)
#define SK_ScalarInfinity
#define REPORTER_ASSERT(r, cond,...)
SkColor getColor(int x, int y) const
void allocN32Pixels(int width, int height, bool isOpaque=false)
void eraseColor(SkColor4f) const
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void scale(SkScalar sx, SkScalar sy)
static SkM44 Rotate(SkV3 axis, SkScalar radians)
static SkM44 Perspective(float near, float far, float angle)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static SkMatrix RotateDeg(SkScalar deg)
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
static const SkMatrix & I()
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
static constexpr float HalfWidth(const SkRect &r)
static SkIRect MakeILarge()
static SkIRect ClosestDisjointEdge(const SkIRect &src, const SkIRect &dst)
static SkRect MakeLargeS32()
static constexpr SkRect MakeLargestInverted()
static SkRect MakeLargest()
static constexpr float HalfHeight(const SkRect &r)
static SkIRect MakeILargestInverted()
static bool Subtract(const SkRect &a, const SkRect &b, SkRect *out)
static bool QuadContainsRect(const SkMatrix &m, const SkIRect &a, const SkIRect &b, float tol=0.f)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SINT bool isfinite(const Vec< N, T > &v)
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
static constexpr SkIRect MakeEmpty()
static SkImageInfo MakeN32Premul(int width, int height)
static SkRect Make(const SkISize &size)
constexpr SkRect makeOffset(float dx, float dy) const
SkScalar fLeft
smaller x-axis bounds
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
constexpr float centerX() const
void offset(float dx, float dy)
constexpr float height() const
bool setBoundsCheck(const SkPoint pts[], int count)
constexpr float centerY() const
constexpr float width() const
void setBoundsNoCheck(const SkPoint pts[], int count)
static constexpr SkRect MakeWH(float w, float h)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
SkScalar fTop
smaller y-axis bounds