提交 09f1901d 编写于 作者: B Behdad Esfahbod

Add doLayout variant that does NOT take css string

New API removes CSS string and directly takes needed objects.

Bug: 16651112
Change-Id: Ie5f7c2ab05be6cbd77cae0a5fd6bb453771ada59
上级 41b1aa18
......@@ -68,9 +68,13 @@ public:
void dump() const;
void setFontCollection(const FontCollection* collection);
// Deprecated. Will be removed.
void doLayout(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
const std::string& css);
void doLayout(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
int bidiFlags, const FontStyle &style, const MinikinPaint &paint);
void draw(Bitmap*, int x0, int y0, float size) const;
// This must be called before any invocations.
......
......@@ -497,24 +497,36 @@ static void clearHbFonts(LayoutContext* ctx) {
void Layout::doLayout(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
const string& css) {
AutoMutex _l(gMinikinLock);
LayoutContext ctx;
CssProperties props;
props.parse(css);
ctx.style = styleFromCss(props);
FontStyle style = styleFromCss(props);
MinikinPaint paint;
ctx.paint.size = props.value(fontSize).getDoubleValue();
ctx.paint.scaleX = props.hasTag(fontScaleX)
paint.size = props.value(fontSize).getDoubleValue();
paint.scaleX = props.hasTag(fontScaleX)
? props.value(fontScaleX).getDoubleValue() : 1;
ctx.paint.skewX = props.hasTag(fontSkewX)
paint.skewX = props.hasTag(fontSkewX)
? props.value(fontSkewX).getDoubleValue() : 0;
ctx.paint.letterSpacing = props.hasTag(letterSpacing)
paint.letterSpacing = props.hasTag(letterSpacing)
? props.value(letterSpacing).getDoubleValue() : 0;
ctx.paint.paintFlags = props.hasTag(paintFlags)
paint.paintFlags = props.hasTag(paintFlags)
? props.value(paintFlags).getUintValue() : 0;
int bidiFlags = props.hasTag(minikinBidi) ? props.value(minikinBidi).getIntValue() : 0;
doLayout(buf, start, count, bufSize, bidiFlags, style, paint);
}
void Layout::doLayout(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
int bidiFlags, const FontStyle &style, const MinikinPaint &paint) {
AutoMutex _l(gMinikinLock);
LayoutContext ctx;
ctx.style = style;
ctx.paint = paint;
bool isRtl = (bidiFlags & kDirection_Mask) != 0;
bool doSingleRun = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册