Commit Graph

78 Commits

Author SHA1 Message Date
Jason Simmons
886e8500a9 Apply fake bold and italic settings to the SkFont if the typeface needs them
The rules for setting fake bold and italic are based on the implementation
used in Minikin.

Change-Id: I9bbecdbd0198363db0296fa9c68046b4724fbded
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269429
Commit-Queue: Jason Simmons <jsimmons@google.com>
Reviewed-by: Julia Lavrova <jlavrova@google.com>
2020-02-12 22:17:26 +00:00
Jason Simmons
d6ff6f7f12 Fix typo: widthWithGhostSpaces
Change-Id: I14b56069fc273e4b6fcb6d7b528716bf6dc38c00
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269912
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Commit-Queue: Jason Simmons <jsimmons@google.com>
2020-02-11 18:03:27 +00:00
Brian Osman
788b91678f Remove SkTMin and SkTMax
Use std::min and std::max everywhere.

SkTPin still exists. We can't use std::clamp yet, and even when
we can, it has undefined behavior with NaN. SkTPin is written
to ensure that we return a value in the [lo, hi] range.

Change-Id: I506852a36e024ae405358d5078a872e2c77fa71e
Docs-Preview: https://skia.org/?cl=269357
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269357
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-02-07 18:40:09 +00:00
Julia Lavrova
c0360582d2 Cache should work with INF values
Change-Id: I1ae8d95bb85d28fdce9e0cf270583f0224e4dfed
Bug: skia:9874
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268938
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-02-06 19:44:43 +00:00
Brian Osman
116b33e8ab Remove SkMaxScalar and SkMinScalar
Use std::max and std::min instead

Change-Id: Icf3796609e5cb511687fb50bd31229ae4b6b9b39
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268841
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-06 15:43:22 +00:00
Julia Lavrova
95a9e69c8c Make assert less sensitive to rounding errors
Change-Id: I64b28e0cdcb7f44c1ded9c8d23f3b9c9add09861
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268837
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-02-05 20:30:38 +00:00
Julia Lavrova
d3a32c5425 RTL fixes + few small bugs
1. Removed unnecessary iterators (use SkShaper iterators instead)
2. More careful hash function and comparison (ParagraphStyle)
3. computeEmptyMetrics should go after resolveStrut
4. longestLine for line with spaces only should not be 0
5. LTR/RTL * left/right align * latin/arabic * leading/trailing spaces positioning
6. Height for MaxHeight rect (to follow Gary's change)

Change-Id: I3507ff9fb93148e5ef882a2f514078fcea9cfef3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268301
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-02-05 14:40:48 +00:00
Julia Lavrova
fae37b0741 Small fix:
ignore empty unresolved blocks to avoid (unnecessary) ASSERT later

Change-Id: I5abdc7f36d5f9a9be1c52aea2df29f565f606996
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267922
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-01-31 14:30:09 +00:00
Julia Lavrova
7ad393e58a Fix placeholders in cache
Change-Id: I36d488aa7a554131b8e524beeabc4ca9f5777591
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267696
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-01-30 17:29:55 +00:00
Julia Lavrova
7c1142dd7b Dead code
Change-Id: I75eb10ff622743dc95b4f7fbec14f37447ce0edf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267481
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-01-30 17:28:05 +00:00
Julia Lavrova
db543f60a8 Memory leak in cache
Change-Id: I3edebd64a28584412e0dfac6849ee8d608243262
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267441
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-01-29 17:39:37 +00:00
Julia Lavrova
89e678dea2 Skip vertical clipping in unclear case of font height=font size
Change-Id: Ib58c34f6ab3ff36e73b2d9d4b0d4f5d03c72c9dd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267041
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-01-28 17:17:06 +00:00
Julia Lavrova
aec9c8492f Dealing with SkScalar values in cache
Change-Id: I0da874242f243b3d3e71834240adc424bcb965c8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266558
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-01-27 22:41:56 +00:00
Julia Lavrova
c88a3bc3f5 Bidi segmentation BEFORE anything else
Change-Id: I94637e663bc1ffc7d9d6e1c0fb0b28509af45f60
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266200
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-01-23 20:38:26 +00:00
Julia Lavrova
2ea20eae78 Another attempt to aling ellipsis behavior with TxtLib
Change-Id: If556d939e7f61ffa9f60cb68e0c177cb5ca05d49
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265760
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-01-22 22:50:53 +00:00
Julia Lavrova
51a813db80 Calculating drawing area for a line with shadows
Change-Id: Ifb2de5573f4362332cf174012e7ef9bf8248cd59
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265524
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-01-21 22:30:52 +00:00
Julia Lavrova
9bd8351ef3 RTL Paragraph + all it causes
Change-Id: Ia8711bf8a002af7ca9ae603cdd9a109c8af86360
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264640
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-01-15 21:25:16 +00:00
Julia Lavrova
4cf1874981 Fixing the cache
Change-Id: Ief6ce50095c73498307748d30608100c10790746
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264399
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-01-15 16:58:14 +00:00
Julia Lavrova
70e9301c26 Formatting paragraph with width=0
Change-Id: I0a4f2db10835661b33d0ffa69d27e8994b473b24
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263704
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-01-13 14:22:22 +00:00
Julia Lavrova
f6a3f8eb74 height_override without a multiplier
Change-Id: I07b8631928de3e4920393124bac37fefbbaf4c2a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263568
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-01-10 16:44:41 +00:00
Julia Lavrova
c48687a0cc Ellipsis attached to cluster, not word
Change-Id: I3bcef7e57a8f95a12743325363463a3a4039776e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263206
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-01-10 14:40:41 +00:00
Julia Lavrova
567f25a918 Fix a bug with unresolved text
Change-Id: I2226f2a72d91bb83145c7165d98a4ee132f06184
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262223
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-01-06 17:44:53 +00:00
Julia Lavrova
53c1447848 Small bug fixes: leading spaces affect all width measurements,
longest line and so on.

Change-Id: I497022269ad38e3cf6a1920f67b1d9217aa6d805
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260778
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-01-06 14:57:41 +00:00
Mike Klein
f46d5ca492 use std::make_unique
Change-Id: I7c672ff6b8eb95ec8c1123a5bfdb202e1644f494
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259281
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-12-12 22:32:45 +00:00
Julia Lavrova
c5313e6b2a Font features
Change-Id: I8ae44d715fd2fa195c209c8ecb514db3e9644c31
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259100
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2019-12-10 19:19:24 +00:00
Julia Lavrova
f9c6ee5461 Fixing the fix for memory leak
Change-Id: I0be996b30d3d86fc57eb9423ee7df2feb08fbda4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258883
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-12-09 23:29:33 +00:00
Julia Lavrova
90bfd1c1c3 Small changes
Change-Id: Ic9c41a2dd11b4df8ab24037df0109e36536ec6c3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257892
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2019-12-09 21:58:13 +00:00
Hal Canary
3f7c49c96d skparagraph: fix another leak
Change-Id: I2394dfb10994ce055d87f881ea3bd3c88ab634d6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258881
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2019-12-09 21:39:13 +00:00
Hal Canary
189f30216b skparagraph: fix leak
Change-Id: Ieb13a5430ac78ba3d310331c72a96f0323e67d6e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258811
Auto-Submit: Hal Canary <halcanary@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-12-09 19:33:56 +00:00
Jason Simmons
22bb52e95b Get baselines from cached default metrics if the text is empty
Change-Id: Ic04251d60d6d36f80c3e569312495190ba375d85
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258488
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Commit-Queue: Jason Simmons <jsimmons@google.com>
2019-12-06 18:36:55 +00:00
Julia Lavrova
3281b961c5 A new API call on Paragraph: a number of unresolved glyphs
Change-Id: Iba33c0df4aa9f2dc9b816c0954980ac8a971909b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257326
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2019-12-02 19:23:45 +00:00
Julia Lavrova
0193e8c6bd Bug fixes
Change-Id: Id2b75e515a3f9fa695339980a6c9036435f3f5d5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256658
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-11-26 21:12:44 +00:00
Julia Lavrova
c028b42717 Ellipsis again
Change-Id: I895fd394dedc50acd648eeed4f398c375a9812ee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256224
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2019-11-25 19:57:15 +00:00
Jason Simmons
6405340609 Find and cache font family lists and the typeface lists that they map to
If none of the families in the requested list are available, then use the
platform default font family.

Change-Id: If0c69febb112c660f96a768cea8d3ae6b35ea68a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255311
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Commit-Queue: Jason Simmons <jsimmons@google.com>
2019-11-20 20:23:51 +00:00
Julia Lavrova
060cbd90f4 Fixing a memory leak in OneLineShaper
Change-Id: I938ff338bce24efb311fab2232f7b70402843fea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255262
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-11-19 17:09:58 +00:00
Brian Osman
417d299d44 Fix windows DLL builds with shaper included
Change-Id: I7adc1e01f4f9cec56e53e620ba4d04eae61f0b9e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254899
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-11-19 14:50:12 +00:00
Jason Simmons
1fbdfcd853 Use the default font family if no match is found for any of the families in the text style
Change-Id: Ie2b54b8dbb187e11d86996f3752c9bde72528cca
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254817
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2019-11-18 22:35:50 +00:00
Julia Lavrova
b00ccf52de Correct cluster index
Change-Id: Ic657b3fff318e1e76efa4ab7533bc2a833d17802
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/253957
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2019-11-11 19:26:56 +00:00
Julia Lavrova
f0ade8a687 Fixing no icu situation
Change-Id: I9763a0a2a0ee231500b27c11e17e0f5f4df44f29
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/253683
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2019-11-08 18:59:03 +00:00
Julia Lavrova
2e30fde046 Font resolution: all unit tests working
Change-Id: Ie6ee30901d599ceefa42651add79bb0288c54c48
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249004
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Julia Lavrova <jlavrova@google.com>
2019-11-08 17:24:14 +00:00
Kevin Lubick
d3b1fe66d6 [CanvasKit] More Paragraph things
Bug: skia:9469
Change-Id: I72a4912b5b6edd2ddde077a558c2c24b68d7df64
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249556
Reviewed-by: Julia Lavrova <jlavrova@google.com>
2019-10-21 15:27:13 +00:00
Julia Lavrova
191c6080dc Bug fix (strut must be false by default)
Change-Id: I3d778562ae85da048190998faa7f62a2953c099f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/247108
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2019-10-08 20:53:01 +00:00
Julia Lavrova
f3ed273b32 Adding line/style metrics
Fixed some bugs for flutter tests

Change-Id: I43f4b4b185152a8d642127370da5f80fb96f1e9e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/239444
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-10-07 15:07:48 +00:00
Kevin Lubick
369f6a5ea2 [canvaskit] Initial addition of SkParagraph
There are more parts of ParagraphStyle and TextStyle, but
this should be a bulk of the components.

Bug: skia:9469
Change-Id: I87fff6700f41cff49ecbee3a1339e84c36699c93
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244837
Reviewed-by: Julia Lavrova <jlavrova@google.com>
2019-10-03 18:04:55 +00:00
Kevin Lubick
7aeabcfa6a [SkParagraph] Require len if using addText(const char*)
Bug: skia:9469
Change-Id: Ie3ae11db9be4b1cf1645e8db0bf29dc8e59bc4cd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244877
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-09-29 11:39:34 +00:00
Kevin Lubick
61887c7b88 [canvaskit] Create SkFontMgr from passed in data
This repurposes much of our embedded SkFontMgr code
to take in data directly instead of from compiled-in
variables.

Also makes no_font and no_embedded_font work better.

Bug: skia:9469
Change-Id: Ibde49c9a448cfca79c5712aa9abbe15997a163d0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244510
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-09-26 19:27:12 +00:00
Julia Lavrova
166751ef57 Fix for the build
Change-Id: I3da068d09d31f2c05d499f32dedbe14108b5652c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/239107
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2019-09-04 21:59:09 +00:00
Julia Lavrova
526df26b03 Reshuffling bidi regions + empty text sizes + some font resolution bugs
Change-Id: Icc0d688985de7253f3113e5c9657544f68b4e01d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/236217
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-09-04 20:42:15 +00:00
Mike Klein
334a642b20 remove unused sk_sp comparison operators
These unused comparison operators are the only users of
<functional> in SkRefCnt.h, for std::less.  <functional>
is an expensive header to compile, and SkRefCnt.h is popular,
so it helps to cut dependencies like this.

Mostly we just need to add #include <functional> in a few
places that were picking it up via SkRefCnt.h.

In SkPixmapPriv.h, it looked simpler to template the argument,
since everything was inline anyway.

Change-Id: I7c125bb26a04199847357c729a1b178256c6ef8d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/236942
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2019-08-27 14:52:01 +00:00
Mike Klein
48e08aa973 <ostream> -> <iosfwd>
<ostream> is one of the more expensive headers to include
and that's amplified by SkRefCnt.h's popularity.

We've been including <ostream> for sk_sp's operator<<.  That's only
used by Chromium and while we could just sprinkle in a bunch of .get()
calls and remove operator<<, when I started going through and actually
doing that I got the feeling I was making things pointlessly harder to
read and write, and wanted to find a way to make it actually work.

My next instinct was to template it without mentioning ostreams,

    template <typename OS, typename T>
    auto operator<<(OS& os, const sk_sp<T>& sp) -> decltype(os << sp.get()) {
        return os << sp.get();
    }

but that makes this operator<< ambiguous with some other templated operator<<
in GTest.  They got in first, so they win...

So ultimately, switch <ostream> to <iosfwd>.   Anyone using our
operator<<() presumably has <ostream> included already, and the #include
cost for <iosfwd> is small enough that I don't think we'll mind keeping
this around indefinitely.

To repro, look at before/after of -ftime-trace:

    ~/chromium/src/third_party/llvm-build/Release+Asserts/bin/clang++ -I. -Os -c src/core/SkCanvas.cpp -ftime-trace

I have tested locally that Chromium builds with this change.

Change-Id: I9decc2e65b5cc8fd07d8106a5eff81901aedd7d5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/237190
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-08-27 13:08:56 +00:00