summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2018-02-06 17:27:39 -0800
committerSeigo Nonaka <nona@google.com>2018-02-08 13:26:58 -0800
commitb6741838575d75b6a8b3f6eae10548a5d94df622 (patch)
tree97df47b6718b841da7dbc88ec1fa5718306902cb /include
parent3dec83e56fd8ac0a42d54aea56d586b94d6f407d (diff)
downloadminikin-b6741838575d75b6a8b3f6eae10548a5d94df622.tar.gz
Introduce own mutex for LayoutCache
To remove global mutex from Layout, need to introduce own mutex for guarding mCache member variable. Also need to move append logic into inside LayoutCache to be able to guard cached layout. StaticLayout creation time: MeasuredText Balanced Hyphenation : 708,143 -> 702,095: (-0.9%) MeasuredText Balanced NoHyphenation: 544,137 -> 534,731: (-1.7%) MeasuredText Greedy Hyphenation : 496,402 -> 483,748: (-2.5%) MeasuredText Greedy NoHyphenation : 496,945 -> 486,470: (-2.1%) RandomText Balanced Hyphenation : 18,126,777 -> 18,092,188: (-0.2%) RandomText Balanced NoHyphenation : 7,640,891 -> 7,622,978: (-0.2%) RandomText Greedy Hyphenation : 7,577,412 -> 7,535,832: (-0.5%) RandomText Greedy NoHyphenation : 7,576,184 -> 7,541,479: (-0.5%) MeasuredText creation time: NoStyled Hyphenation : 17,974,637 -> 17,957,290: (-0.1%) NoStyled Hyphenation WidthOnly : 17,554,572 -> 17,526,213: (-0.2%) NoStyled NoHyphenation : 7,575,486 -> 7,541,455: (-0.4%) NoStyled NoHyphenation WidthOnly : 7,141,395 -> 7,127,556: (-0.2%) Styled Hyphenation : 14,902,479 -> 14,850,494: (-0.3%) Styled Hyphenation WidthOnly : 13,981,196 -> 13,875,643: (-0.8%) Styled NoHyphenation : 14,371,167 -> 14,404,258: (+0.2%) Styled NoHyphenation WidthOnly : 13,627,253 -> 13,496,432: (-1.0%) StaticLayout.draw time: MeasuredText NoStyled : 663,550 -> 666,351: (+0.4%) MeasuredText NoStyled WithoutCache : 650,371 -> 655,528: (+0.8%) MeasuredText Styled : 883,965 -> 865,664: (-2.1%) MeasuredText Styled WithoutCache : 924,090 -> 901,887: (-2.4%) RandomText NoStyled : 553,092 -> 576,268: (+4.2%) RandomText NoStyled WithoutCache : 6,896,348 -> 6,899,642: (+0.0%) RandomText Styled : 2,959,402 -> 2,936,847: (-0.8%) RandomText Styled WithoutCache : 3,398,857 -> 3,395,033: (-0.1%) Bug: 37567215 Test: minikin_tests Change-Id: I75d9f1994a43d9bced02979201bdc8180a16c3ac
Diffstat (limited to 'include')
-rw-r--r--include/minikin/Layout.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/include/minikin/Layout.h b/include/minikin/Layout.h
index 7e8adc3..4f22918 100644
--- a/include/minikin/Layout.h
+++ b/include/minikin/Layout.h
@@ -111,11 +111,11 @@ public:
// Get advances, copying into caller-provided buffer. The size of this
// buffer must match the length of the string (count arg to doLayout).
- void getAdvances(float* advances);
+ void getAdvances(float* advances) const;
// Get extents, copying into caller-provided buffer. The size of this buffer must match the
// length of the string (count arg to doLayout).
- void getExtents(MinikinExtent* extents);
+ void getExtents(MinikinExtent* extents) const;
// The i parameter is an offset within the buf relative to start, it is < count, where
// start and count are the parameters to doLayout
@@ -137,6 +137,7 @@ public:
private:
friend class LayoutCacheKey;
+ friend class LayoutCache;
// TODO: Remove friend class with decoupling building logic from Layout.
friend class LayoutCompositer;
@@ -171,7 +172,7 @@ private:
LayoutContext* ctx, StartHyphenEdit startHyphen, EndHyphenEdit endHyphen);
// Append another layout (for example, cached value) into this one
- void appendLayout(Layout* src, size_t start, float extraAdvance);
+ void appendLayout(const Layout& src, size_t start, float extraAdvance);
std::vector<LayoutGlyph> mGlyphs;
@@ -207,8 +208,7 @@ public:
}
void append(const Layout& layout, uint32_t start, float extraAdvance) {
- // TODO: remove const cast.
- mLayout.appendLayout(const_cast<Layout*>(&layout), start, extraAdvance);
+ mLayout.appendLayout(layout, start, extraAdvance);
}
Layout build() { return std::move(mLayout); }