ensure we never change the text_encoding of the master paint, since it is used

to interpret the text/length parameters in draw[Pos]Text.



git-svn-id: http://skia.googlecode.com/svn/trunk@2724 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-11-21 16:42:10 +00:00
parent 8ef3fd0ca6
commit 8426058dee
2 changed files with 17 additions and 6 deletions

View File

@ -22,7 +22,8 @@ public:
* Bits specifies which aspects of the layer's paint should replace the
* corresponding aspects on the draw's paint.
* kEntirePaint_Bits means use the layer's paint completely.
* 0 means ignore the layer's paint.
* 0 means ignore the layer's paint... except that LayerInfo's fFlagsMask
* and fColorMode are always applied.
*/
enum Bits {
kStyle_Bit = 1 << 0, //!< use this layer's Style/stroke settings
@ -33,7 +34,15 @@ public:
kColorFilter_Bit = 1 << 5, //!< use this layer's colorfilter
kXfermode_Bit = 1 << 6, //!< use this layer's xfermode
kEntirePaint_Bits = -1, //!< use this layer's paint entirely
/**
* Use the layer's paint entirely, with these exceptions:
* - We never override the draw's paint's text_encoding, since that is
* used to interpret the text/len parameters in draw[Pos]Text.
* - Flags and Color are always computed using the LayerInfo's
* fFlagsMask and fColorMode.
*/
kEntirePaint_Bits = -1,
};
typedef int32_t BitFlags;

View File

@ -72,15 +72,18 @@ static SkColor xferColor(SkColor src, SkColor dst, SkXfermode::Mode mode) {
}
}
// Even with kEntirePaint_Bits, we always ensure that the master paint's
// text-encoding is respected, since that controls how we interpret the
// text/length parameters of a draw[Pos]Text call.
void SkLayerDrawLooper::ApplyInfo(SkPaint* dst, const SkPaint& src,
const LayerInfo& info) {
uint32_t mask = info.fFlagsMask;
dst->setFlags((dst->getFlags() & ~mask) | (src.getFlags() & mask));
dst->setColor(xferColor(src.getColor(), dst->getColor(), info.fColorMode));
BitFlags bits = info.fPaintBits;
SkPaint::TextEncoding encoding = dst->getTextEncoding();
if (0 == bits) {
return;
@ -92,6 +95,7 @@ void SkLayerDrawLooper::ApplyInfo(SkPaint* dst, const SkPaint& src,
*dst = src;
dst->setFlags(f);
dst->setColor(c);
dst->setTextEncoding(encoding);
return;
}
@ -123,13 +127,11 @@ void SkLayerDrawLooper::ApplyInfo(SkPaint* dst, const SkPaint& src,
dst->setXfermode(src.getXfermode());
}
// we never copy these
// we don't override these
#if 0
dst->setFlags(src.getFlags());
dst->setTypeface(src.getTypeface());
dst->setTextSize(src.getTextSize());
dst->setTextScaleX(src.getTextScaleX());
dst->setTextSkewX(src.getTextSkewX());
dst->setRasterizer(src.getRasterizer());
dst->setLooper(src.getLooper());
dst->setTextEncoding(src.getTextEncoding());