diff options
author | Behdad Esfahbod <behdad@google.com> | 2014-08-21 16:30:03 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@google.com> | 2014-08-21 17:26:04 -0400 |
commit | 6da7796cbe8a17efd61a3302369e69bb222fdb4f (patch) | |
tree | 8f94adeb30d8bb3c21436e8ea3c6d8b1057b7c4f /include/minikin/Layout.h | |
parent | 288c915963b3500c7efb958ba613650e2ecdfdfa (diff) | |
download | android_frameworks_minikin-6da7796cbe8a17efd61a3302369e69bb222fdb4f.tar.gz android_frameworks_minikin-6da7796cbe8a17efd61a3302369e69bb222fdb4f.tar.bz2 android_frameworks_minikin-6da7796cbe8a17efd61a3302369e69bb222fdb4f.zip |
Fix Layout initialization in the skipCache path
C++ local var initialization always tricks me. Previously, Layout
didn't have a constructor, which meant that defining it on the stack
left mAdvance uninitialized. This was not an issue when we were doing
"new Layout()", since that invokes zero-initialization, but was an
issue for the skipCache path that was allocating layout on stack by
just "Layout l" instead of "Layout l = Layout()". To avoid surprises,
add a constructors that clears everything.
Also adds reset() method to reset the layout for reuse.
Change-Id: I3e02f00da9dd7d360abe13f63c310f6882292d0a
Diffstat (limited to 'include/minikin/Layout.h')
-rw-r--r-- | include/minikin/Layout.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/include/minikin/Layout.h b/include/minikin/Layout.h index c88d087..9f87597 100644 --- a/include/minikin/Layout.h +++ b/include/minikin/Layout.h @@ -64,6 +64,14 @@ class LayoutContext; // extend through the lifetime of the Layout object. class Layout { public: + + Layout() : mGlyphs(), mAdvances(), mCollection(0), mFaces(), mAdvance(0), mBounds() { + mBounds.setEmpty(); + } + + // Clears layout, ready to be used again + void reset(); + void dump() const; void setFontCollection(const FontCollection* collection); @@ -72,8 +80,7 @@ public: void draw(Bitmap*, int x0, int y0, float size) const; - // This must be called before any invocations. - // TODO: probably have a factory instead + // Deprecated. Nont needed. Remove when callers are removed. static void init(); // public accessors |