f0b5644e6b
SkGlyphRect is a rectangle encoding specialized for union and intersect. It will be used for calculating the bounding boxes of glyph runs, and clipping glyphs for GPU. Change-Id: Icab826b51dc2254ee4006ada84f7fc09e112a933 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319697 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Herb Derby <herb@google.com>
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
/*
|
|
* Copyright 2020 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "src/core/SkGlyph.h"
|
|
#include "tests/Test.h"
|
|
|
|
DEF_TEST(SkGlyphRectBasic, reporter) {
|
|
using namespace skglyph;
|
|
SkGlyphRect r{1, 1, 10, 10};
|
|
REPORTER_ASSERT(reporter, !r.empty());
|
|
SkGlyphRect a = rect_union(r, empty_rect());
|
|
REPORTER_ASSERT(reporter, a.iRect() == SkIRect::MakeLTRB(1, 1, 10, 10));
|
|
|
|
a = rect_intersection(r, full_rect());
|
|
REPORTER_ASSERT(reporter, a.iRect() == SkIRect::MakeLTRB(1, 1, 10, 10));
|
|
|
|
SkGlyphRect acc = full_rect();
|
|
for (int x = -10; x < 10; x++) {
|
|
for(int y = -10; y < 10; y++) {
|
|
acc = rect_intersection(acc, SkGlyphRect(x, y, x + 20, y + 20));
|
|
}
|
|
}
|
|
REPORTER_ASSERT(reporter, acc.iRect() == SkIRect::MakeLTRB(9, 9, 10, 10));
|
|
|
|
acc = empty_rect();
|
|
for (int x = -10; x < 10; x++) {
|
|
for(int y = -10; y < 10; y++) {
|
|
acc = rect_union(acc, SkGlyphRect(x, y, x + 20, y + 20));
|
|
}
|
|
}
|
|
REPORTER_ASSERT(reporter, acc.iRect() == SkIRect::MakeLTRB(-10, -10, 29, 29));
|
|
}
|