am df03550a: Fix Layout initialization in the skipCache path

* commit 'df03550a40706a55ca1bfcb67da62765194cf98f':
  Fix Layout initialization in the skipCache path
This commit is contained in:
Behdad Esfahbod 2014-08-21 22:09:56 +00:00 committed by Android Git Automerger
commit 55f6f0cd86
2 changed files with 20 additions and 8 deletions

View File

@ -64,6 +64,14 @@ class LayoutContext;
// extend through the lifetime of the Layout object. // extend through the lifetime of the Layout object.
class Layout { class Layout {
public: 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 dump() const;
void setFontCollection(const FontCollection* collection); void setFontCollection(const FontCollection* collection);
@ -72,8 +80,7 @@ public:
void draw(Bitmap*, int x0, int y0, float size) const; void draw(Bitmap*, int x0, int y0, float size) const;
// This must be called before any invocations. // Deprecated. Nont needed. Remove when callers are removed.
// TODO: probably have a factory instead
static void init(); static void init();
// public accessors // public accessors

View File

@ -267,10 +267,18 @@ void MinikinRect::join(const MinikinRect& r) {
} }
} }
// TODO: the actual initialization is deferred, maybe make this explicit // Deprecated. Remove when callers are removed.
void Layout::init() { void Layout::init() {
} }
void Layout::reset() {
mGlyphs.clear();
mFaces.clear();
mBounds.setEmpty();
mAdvances.clear();
mAdvance = 0;
}
void Layout::setFontCollection(const FontCollection* collection) { void Layout::setFontCollection(const FontCollection* collection) {
mCollection = collection; mCollection = collection;
} }
@ -513,12 +521,9 @@ void Layout::doLayout(const uint16_t* buf, size_t start, size_t count, size_t bu
bool isRtl = (bidiFlags & kDirection_Mask) != 0; bool isRtl = (bidiFlags & kDirection_Mask) != 0;
bool doSingleRun = true; bool doSingleRun = true;
mGlyphs.clear(); reset();
mFaces.clear();
mBounds.setEmpty();
mAdvances.clear();
mAdvances.resize(count, 0); mAdvances.resize(count, 0);
mAdvance = 0;
if (!(bidiFlags == kBidi_Force_LTR || bidiFlags == kBidi_Force_RTL)) { if (!(bidiFlags == kBidi_Force_LTR || bidiFlags == kBidi_Force_RTL)) {
UBiDi* bidi = ubidi_open(); UBiDi* bidi = ubidi_open();
if (bidi) { if (bidi) {