Flutter Engine
The Flutter Engine
PathOpsBoundsTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
16#include "tests/Test.h"
17
18#include <array>
19#include <cstddef>
20
21static const SkRect sectTests[][2] = {
22 {{2, 0, 4, 1}, {4, 0, 6, 1}},
23 {{2, 0, 4, 1}, {3, 0, 5, 1}},
24 {{2, 0, 4, 1}, {3, 0, 5, 0}},
25 {{2, 0, 4, 1}, {3, 1, 5, 2}},
26 {{2, 1, 4, 2}, {1, 0, 5, 3}},
27 {{2, 1, 5, 3}, {3, 1, 4, 2}},
28 {{2, 0, 4, 1}, {3, 0, 3, 0}}, // intersecting an empty bounds is OK
29 {{2, 0, 4, 1}, {4, 1, 5, 2}}, // touching just on a corner is OK
30};
31
32static const size_t sectTestsCount = std::size(sectTests);
33
34static const SkRect noSectTests[][2] = {
35 {{2, 0, 4, 1}, {5, 0, 6, 1}},
36 {{2, 0, 4, 1}, {3, 2, 5, 2}},
37};
38
39static const size_t noSectTestsCount = std::size(noSectTests);
40
41DEF_TEST(PathOpsBounds, reporter) {
42 for (size_t index = 0; index < sectTestsCount; ++index) {
43 const SkPathOpsBounds& bounds1 = static_cast<const SkPathOpsBounds&>(sectTests[index][0]);
44 SkASSERT(ValidBounds(bounds1));
45 const SkPathOpsBounds& bounds2 = static_cast<const SkPathOpsBounds&>(sectTests[index][1]);
46 SkASSERT(ValidBounds(bounds2));
47 bool touches = SkPathOpsBounds::Intersects(bounds1, bounds2);
48 REPORTER_ASSERT(reporter, touches);
49 }
50 for (size_t index = 0; index < noSectTestsCount; ++index) {
51 const SkPathOpsBounds& bounds1 = static_cast<const SkPathOpsBounds&>(noSectTests[index][0]);
52 SkASSERT(ValidBounds(bounds1));
53 const SkPathOpsBounds& bounds2 = static_cast<const SkPathOpsBounds&>(noSectTests[index][1]);
54 SkASSERT(ValidBounds(bounds2));
55 bool touches = SkPathOpsBounds::Intersects(bounds1, bounds2);
56 REPORTER_ASSERT(reporter, !touches);
57 }
59 bounds.setEmpty();
60 bounds.add(1, 2, 3, 4);
61 SkPathOpsBounds expected;
62 expected.setLTRB(0, 0, 3, 4);
63 REPORTER_ASSERT(reporter, bounds == expected);
64 bounds.setEmpty();
65 SkPathOpsBounds ordinal;
66 ordinal.setLTRB(1, 2, 3, 4);
67 bounds.add(ordinal);
68 REPORTER_ASSERT(reporter, bounds == expected);
69 bounds.setEmpty();
70 SkDPoint botRight = {3, 4};
71 bounds.add(botRight);
72 REPORTER_ASSERT(reporter, bounds == expected);
73 const SkPoint curvePts[] = {{0, 0}, {1, 2}, {3, 4}, {5, 6}};
74 SkDCurve curve;
75 curve.fQuad.set(curvePts);
76 curve.setQuadBounds(curvePts, 1, 0, 1, &bounds);
77 expected.setLTRB(0, 0, 3, 4);
78 REPORTER_ASSERT(reporter, bounds == expected);
79 curve.fCubic.set(curvePts);
80 curve.setCubicBounds(curvePts, 1, 0, 1, &bounds);
81 expected.setLTRB(0, 0, 5, 6);
82 REPORTER_ASSERT(reporter, bounds == expected);
83}
reporter
Definition: FontMgrTest.cpp:39
DEF_TEST(PathOpsBounds, reporter)
static const SkRect noSectTests[][2]
static const size_t noSectTestsCount
static const SkRect sectTests[][2]
static const size_t sectTestsCount
bool ValidBounds(const SkPathOpsBounds &bounds)
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
Optional< SkRect > bounds
Definition: SkRecords.h:189
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
const SkDCubic & set(const SkPoint pts[kPointCount] SkDEBUGPARAMS(SkOpGlobalState *state=nullptr))
SkDQuad fQuad
void setCubicBounds(const SkPoint curve[4], SkScalar, double s, double e, SkPathOpsBounds *)
SkDCubic fCubic
void setQuadBounds(const SkPoint curve[3], SkScalar, double s, double e, SkPathOpsBounds *)
const SkDQuad & set(const SkPoint pts[kPointCount] SkDEBUGPARAMS(SkOpGlobalState *state=nullptr))
Definition: SkPathOpsQuad.h:65
static bool Intersects(const SkPathOpsBounds &a, const SkPathOpsBounds &b)
void setLTRB(float left, float top, float right, float bottom)
Definition: SkRect.h:865