• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 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  */
7 
8 #include "include/core/SkPoint.h"
9 #include "include/core/SkRect.h"
10 #include "src/core/SkGlyph.h"
11 #include "tests/Test.h"
12 
DEF_TEST(SkGlyphRectBasic,reporter)13 DEF_TEST(SkGlyphRectBasic, reporter) {
14     using namespace skglyph;
15     SkGlyphRect r{1, 1, 10, 10};
16     REPORTER_ASSERT(reporter, !r.empty());
17     SkGlyphRect a = rect_union(r, empty_rect());
18     REPORTER_ASSERT(reporter, a.rect() == SkRect::MakeLTRB(1, 1, 10, 10));
19     auto widthHeight = a.widthHeight();
20     REPORTER_ASSERT(reporter, widthHeight.x() == 9 && widthHeight.y() == 9);
21 
22     a = rect_intersection(r, full_rect());
23     REPORTER_ASSERT(reporter, a.rect() == SkRect::MakeLTRB(1, 1, 10, 10));
24 
25     SkGlyphRect acc = full_rect();
26     for (int x = -10; x < 10; x++) {
27         for(int y = -10; y < 10; y++) {
28             acc = rect_intersection(acc, SkGlyphRect(x, y, x + 20, y + 20));
29         }
30     }
31     REPORTER_ASSERT(reporter, acc.rect() == SkRect::MakeLTRB(9, 9, 10, 10));
32 
33     acc = empty_rect();
34     for (int x = -10; x < 10; x++) {
35         for(int y = -10; y < 10; y++) {
36             acc = rect_union(acc, SkGlyphRect(x, y, x + 20, y + 20));
37         }
38     }
39     REPORTER_ASSERT(reporter, acc.rect() == SkRect::MakeLTRB(-10, -10, 29, 29));
40 }
41