Flutter Engine
The Flutter Engine
PathOpsDRectTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2012 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 */
13#include "tests/Test.h"
14
15#include <array>
16#include <cstddef>
17
18static const QuadPts quadTests[] = {
19 {{{1, 1}, {2, 1}, {0, 2}}},
20 {{{0, 0}, {1, 1}, {3, 1}}},
21 {{{2, 0}, {1, 1}, {2, 2}}},
22 {{{4, 0}, {0, 1}, {4, 2}}},
23 {{{0, 0}, {0, 1}, {1, 1}}},
24};
25
26static const CubicPts cubicTests[] = {
27 {{{2, 0}, {3, 1}, {2, 2}, {1, 1}}},
28 {{{3, 1}, {2, 2}, {1, 1}, {2, 0}}},
29 {{{3, 0}, {2, 1}, {3, 2}, {1, 1}}},
30};
31
32static const size_t quadTests_count = std::size(quadTests);
33static const size_t cubicTests_count = std::size(cubicTests);
34
35static void setRawBounds(const SkDQuad& quad, SkDRect* rect) {
36 rect->set(quad[0]);
37 rect->add(quad[1]);
38 rect->add(quad[2]);
39}
40
41static void setRawBounds(const SkDCubic& cubic, SkDRect* rect) {
42 rect->set(cubic[0]);
43 rect->add(cubic[1]);
44 rect->add(cubic[2]);
45 rect->add(cubic[3]);
46}
47
48DEF_TEST(PathOpsDRect, reporter) {
49 size_t index;
50 SkDRect rect, rect2;
51 for (index = 0; index < quadTests_count; ++index) {
52 const QuadPts& q = quadTests[index];
53 SkDQuad quad;
54 quad.debugSet(q.fPts);
55 SkASSERT(ValidQuad(quad));
56 setRawBounds(quad, &rect);
57 rect2.setBounds(quad);
58 REPORTER_ASSERT(reporter, rect.intersects(rect2));
59 // FIXME: add a recursive box subdivision method to verify that tight bounds is correct
60 SkDPoint leftTop = {rect2.fLeft, rect2.fTop};
61 REPORTER_ASSERT(reporter, rect.contains(leftTop));
62 SkDPoint rightBottom = {rect2.fRight, rect2.fBottom};
63 REPORTER_ASSERT(reporter, rect.contains(rightBottom));
64 }
65 for (index = 0; index < cubicTests_count; ++index) {
66 const CubicPts& c = cubicTests[index];
68 cubic.debugSet(c.fPts);
71 rect2.setBounds(cubic);
72 REPORTER_ASSERT(reporter, rect.intersects(rect2));
73 // FIXME: add a recursive box subdivision method to verify that tight bounds is correct
74 SkDPoint leftTop = {rect2.fLeft, rect2.fTop};
75 REPORTER_ASSERT(reporter, rect.contains(leftTop));
76 SkDPoint rightBottom = {rect2.fRight, rect2.fBottom};
77 REPORTER_ASSERT(reporter, rect.contains(rightBottom));
78 }
79}
reporter
Definition: FontMgrTest.cpp:39
static void setRawBounds(const SkDQuad &quad, SkDRect *rect)
static const size_t cubicTests_count
static const QuadPts quadTests[]
static const size_t quadTests_count
DEF_TEST(PathOpsDRect, reporter)
static const CubicPts cubicTests[]
bool ValidCubic(const SkDCubic &cubic)
bool ValidQuad(const SkDQuad &quad)
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
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
AI float cubic(float precision, const SkPoint pts[], const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:195
SkDPoint fPts[kPointCount]
SkDPoint fPts[kPointCount]
void debugSet(const SkDPoint *pts)
double fTop
Definition: SkPathOpsRect.h:22
double fRight
Definition: SkPathOpsRect.h:22
double fBottom
Definition: SkPathOpsRect.h:22
void setBounds(const SkDConic &curve)
Definition: SkPathOpsRect.h:59
double fLeft
Definition: SkPathOpsRect.h:22