OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "SkiaTextMetrics.h" | 5 #include "SkiaTextMetrics.h" |
6 | 6 |
7 #include "wtf/MathExtras.h" | 7 #include "wtf/MathExtras.h" |
8 | 8 |
9 #include <SkPath.h> | 9 #include <SkPath.h> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 m_paint->getTextWidths(&glyph, sizeof(glyph), nullptr, &skBounds); | 45 m_paint->getTextWidths(&glyph, sizeof(glyph), nullptr, &skBounds); |
46 if (!m_paint->isSubpixelText()) { | 46 if (!m_paint->isSubpixelText()) { |
47 // Use roundOut() rather than round() to avoid rendering glyphs | 47 // Use roundOut() rather than round() to avoid rendering glyphs |
48 // outside the visual overflow rect. crbug.com/452914. | 48 // outside the visual overflow rect. crbug.com/452914. |
49 SkIRect ir; | 49 SkIRect ir; |
50 skBounds.roundOut(&ir); | 50 skBounds.roundOut(&ir); |
51 skBounds.set(ir); | 51 skBounds.set(ir); |
52 } | 52 } |
53 | 53 |
54 // Invert y-axis because Skia is y-grows-down but we set up HarfBuzz to be y-g
rows-up. | 54 // Invert y-axis because Skia is y-grows-down but we set up HarfBuzz to be |
| 55 // y-grows-up. |
55 extents->x_bearing = SkiaScalarToHarfBuzzPosition(skBounds.fLeft); | 56 extents->x_bearing = SkiaScalarToHarfBuzzPosition(skBounds.fLeft); |
56 extents->y_bearing = SkiaScalarToHarfBuzzPosition(-skBounds.fTop); | 57 extents->y_bearing = SkiaScalarToHarfBuzzPosition(-skBounds.fTop); |
57 extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); | 58 extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); |
58 extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); | 59 extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); |
59 } | 60 } |
60 | 61 |
61 void SkiaTextMetrics::getSkiaBoundsForGlyph(Glyph glyph, SkRect* bounds) { | 62 void SkiaTextMetrics::getSkiaBoundsForGlyph(Glyph glyph, SkRect* bounds) { |
62 #if OS(MACOSX) | 63 #if OS(MACOSX) |
63 // TODO(drott): Remove this once we have better metrics bounds | 64 // TODO(drott): Remove this once we have better metrics bounds |
64 // on Mac, https://bugs.chromium.org/p/skia/issues/detail?id=5328 | 65 // on Mac, https://bugs.chromium.org/p/skia/issues/detail?id=5328 |
(...skipping 15 matching lines...) Expand all Loading... |
80 SkScalar skWidth; | 81 SkScalar skWidth; |
81 m_paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, nullptr); | 82 m_paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, nullptr); |
82 | 83 |
83 if (!m_paint->isSubpixelText()) | 84 if (!m_paint->isSubpixelText()) |
84 skWidth = SkScalarRoundToInt(skWidth); | 85 skWidth = SkScalarRoundToInt(skWidth); |
85 | 86 |
86 return SkScalarToFloat(skWidth); | 87 return SkScalarToFloat(skWidth); |
87 } | 88 } |
88 | 89 |
89 } // namespace blink | 90 } // namespace blink |
OLD | NEW |