Make paint flags consistently uint32_t
Change internal plumbing of paint flags (including CssParse) to uint32_t consistently, to match the type used in the client. This will probably prevent compiler warnings. Also renames "float" to "double" to avoid confusion about precision. Change-Id: I80374712c4067ca9e7711cc2d4ec33c440ab9c7c
This commit is contained in:
@@ -54,7 +54,7 @@ class CssValue {
|
||||
public:
|
||||
enum Type {
|
||||
UNKNOWN,
|
||||
FLOAT,
|
||||
DOUBLE,
|
||||
STRING
|
||||
};
|
||||
enum Units {
|
||||
@@ -65,15 +65,16 @@ public:
|
||||
};
|
||||
CssValue() : mType(UNKNOWN) { }
|
||||
explicit CssValue(double v) :
|
||||
mType(FLOAT), floatValue(v), mUnits(SCALAR) { }
|
||||
mType(DOUBLE), doubleValue(v), mUnits(SCALAR) { }
|
||||
Type getType() const { return mType; }
|
||||
double getFloatValue() const { return floatValue; }
|
||||
int32_t getIntValue() const { return floatValue; }
|
||||
double getDoubleValue() const { return doubleValue; }
|
||||
int32_t getIntValue() const { return doubleValue; }
|
||||
uint32_t getUintValue() const { return doubleValue; }
|
||||
std::string getStringValue() const { return stringValue; }
|
||||
std::string toString(CssTag tag) const;
|
||||
void setFloatValue(double v) {
|
||||
mType = FLOAT;
|
||||
floatValue = v;
|
||||
void setDoubleValue(double v) {
|
||||
mType = DOUBLE;
|
||||
doubleValue = v;
|
||||
}
|
||||
void setStringValue(const std::string& v) {
|
||||
mType = STRING;
|
||||
@@ -81,7 +82,7 @@ public:
|
||||
}
|
||||
private:
|
||||
Type mType;
|
||||
double floatValue;
|
||||
double doubleValue;
|
||||
std::string stringValue;
|
||||
Units mUnits;
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ struct MinikinPaint {
|
||||
float size;
|
||||
float scaleX;
|
||||
float skewX;
|
||||
int32_t paintFlags;
|
||||
uint32_t paintFlags;
|
||||
};
|
||||
|
||||
struct MinikinRect {
|
||||
|
||||
@@ -123,21 +123,21 @@ static bool parseValue(const string& str, size_t* off, size_t len, CssTag tag, C
|
||||
return false;
|
||||
}
|
||||
}
|
||||
v->setFloatValue(fv);
|
||||
v->setDoubleValue(fv);
|
||||
*off = endptr - data;
|
||||
return true;
|
||||
}
|
||||
|
||||
string CssValue::toString(CssTag tag) const {
|
||||
if (mType == FLOAT) {
|
||||
if (mType == DOUBLE) {
|
||||
if (tag == fontStyle) {
|
||||
return floatValue ? "italic" : "normal";
|
||||
return doubleValue ? "italic" : "normal";
|
||||
} else if (tag == minikinVariant) {
|
||||
if (floatValue == VARIANT_COMPACT) return "compact";
|
||||
if (floatValue == VARIANT_ELEGANT) return "elegant";
|
||||
if (doubleValue == VARIANT_COMPACT) return "compact";
|
||||
if (doubleValue == VARIANT_ELEGANT) return "elegant";
|
||||
}
|
||||
char buf[64];
|
||||
sprintf(buf, "%g", floatValue);
|
||||
sprintf(buf, "%g", doubleValue);
|
||||
return string(buf);
|
||||
} else if (mType == STRING) {
|
||||
return stringValue; // should probably quote
|
||||
|
||||
@@ -512,13 +512,13 @@ void Layout::doLayout(const uint16_t* buf, size_t start, size_t count, size_t bu
|
||||
ctx.props.parse(css);
|
||||
ctx.style = styleFromCss(ctx.props);
|
||||
|
||||
ctx.paint.size = ctx.props.value(fontSize).getFloatValue();
|
||||
ctx.paint.size = ctx.props.value(fontSize).getDoubleValue();
|
||||
ctx.paint.scaleX = ctx.props.hasTag(fontScaleX)
|
||||
? ctx.props.value(fontScaleX).getFloatValue() : 1;
|
||||
? ctx.props.value(fontScaleX).getDoubleValue() : 1;
|
||||
ctx.paint.skewX = ctx.props.hasTag(fontSkewX)
|
||||
? ctx.props.value(fontSkewX).getFloatValue() : 0;
|
||||
? ctx.props.value(fontSkewX).getDoubleValue() : 0;
|
||||
ctx.paint.paintFlags = ctx.props.hasTag(paintFlags)
|
||||
?ctx.props.value(paintFlags).getIntValue() : 0;
|
||||
? ctx.props.value(paintFlags).getUintValue() : 0;
|
||||
int bidiFlags = ctx.props.hasTag(minikinBidi) ? ctx.props.value(minikinBidi).getIntValue() : 0;
|
||||
bool isRtl = (bidiFlags & kDirection_Mask) != 0;
|
||||
bool doSingleRun = true;
|
||||
|
||||
Reference in New Issue
Block a user