skia2/tests/PathOpsDRectTest.cpp
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00

76 lines
2.5 KiB
C++

/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "src/pathops/SkPathOpsCubic.h"
#include "src/pathops/SkPathOpsLine.h"
#include "src/pathops/SkPathOpsQuad.h"
#include "src/pathops/SkPathOpsRect.h"
#include "tests/PathOpsTestCommon.h"
#include "tests/Test.h"
static const QuadPts quadTests[] = {
{{{1, 1}, {2, 1}, {0, 2}}},
{{{0, 0}, {1, 1}, {3, 1}}},
{{{2, 0}, {1, 1}, {2, 2}}},
{{{4, 0}, {0, 1}, {4, 2}}},
{{{0, 0}, {0, 1}, {1, 1}}},
};
static const CubicPts cubicTests[] = {
{{{2, 0}, {3, 1}, {2, 2}, {1, 1}}},
{{{3, 1}, {2, 2}, {1, 1}, {2, 0}}},
{{{3, 0}, {2, 1}, {3, 2}, {1, 1}}},
};
static const size_t quadTests_count = SK_ARRAY_COUNT(quadTests);
static const size_t cubicTests_count = SK_ARRAY_COUNT(cubicTests);
static void setRawBounds(const SkDQuad& quad, SkDRect* rect) {
rect->set(quad[0]);
rect->add(quad[1]);
rect->add(quad[2]);
}
static void setRawBounds(const SkDCubic& cubic, SkDRect* rect) {
rect->set(cubic[0]);
rect->add(cubic[1]);
rect->add(cubic[2]);
rect->add(cubic[3]);
}
DEF_TEST(PathOpsDRect, reporter) {
size_t index;
SkDRect rect, rect2;
for (index = 0; index < quadTests_count; ++index) {
const QuadPts& q = quadTests[index];
SkDQuad quad;
quad.debugSet(q.fPts);
SkASSERT(ValidQuad(quad));
setRawBounds(quad, &rect);
rect2.setBounds(quad);
REPORTER_ASSERT(reporter, rect.intersects(rect2));
// FIXME: add a recursive box subdivision method to verify that tight bounds is correct
SkDPoint leftTop = {rect2.fLeft, rect2.fTop};
REPORTER_ASSERT(reporter, rect.contains(leftTop));
SkDPoint rightBottom = {rect2.fRight, rect2.fBottom};
REPORTER_ASSERT(reporter, rect.contains(rightBottom));
}
for (index = 0; index < cubicTests_count; ++index) {
const CubicPts& c = cubicTests[index];
SkDCubic cubic;
cubic.debugSet(c.fPts);
SkASSERT(ValidCubic(cubic));
setRawBounds(cubic, &rect);
rect2.setBounds(cubic);
REPORTER_ASSERT(reporter, rect.intersects(rect2));
// FIXME: add a recursive box subdivision method to verify that tight bounds is correct
SkDPoint leftTop = {rect2.fLeft, rect2.fTop};
REPORTER_ASSERT(reporter, rect.contains(leftTop));
SkDPoint rightBottom = {rect2.fRight, rect2.fBottom};
REPORTER_ASSERT(reporter, rect.contains(rightBottom));
}
}