Files
rk35xx-android14/external/skia/tests/SkGlyphTest.cpp
T
hmz007 36ed224bac Rockchip Anroid14_SDK 20240628-rkr5 (2556df1a)
Signed-off-by: hmz007 <hmz007@gmail.com>
Change-Id: Ib87fdbe7a0be7dc961af3500fe9ea4589a127f9f
2024-10-29 18:12:02 +08:00

41 lines
1.3 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 "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#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.rect() == SkRect::MakeLTRB(1, 1, 10, 10));
auto widthHeight = a.widthHeight();
REPORTER_ASSERT(reporter, widthHeight.x() == 9 && widthHeight.y() == 9);
a = rect_intersection(r, full_rect());
REPORTER_ASSERT(reporter, a.rect() == SkRect::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.rect() == SkRect::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.rect() == SkRect::MakeLTRB(-10, -10, 29, 29));
}