From 1f1543f012b8834ea760175a023eb127bde2b895 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Wed, 12 Sep 2012 21:08:33 +0000 Subject: re-apply 5508, but with the new compile-flag disabled for now git-svn-id: http://skia.googlecode.com/svn/trunk@5516 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkPaint.cpp | 33 +++++++++++++++++++++++++++++++++ src/core/SkScalerContext.h | 3 +++ 2 files changed, 36 insertions(+) (limited to 'src/core') diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 7e0ea97cdc..506db0e9c3 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -64,6 +64,9 @@ SkPaint::SkPaint() { fTextSize = SkPaintDefaults_TextSize; fTextScaleX = SK_Scalar1; +#ifdef SK_SUPPORT_HINTING_SCALE_FACTOR + fHintingScaleFactor = SK_Scalar1; +#endif fColor = SK_ColorBLACK; fMiterLimit = SkPaintDefaults_MiterLimit; fFlags = SkPaintDefaults_Flags; @@ -343,6 +346,13 @@ void SkPaint::setTextSkewX(SkScalar skewX) { fTextSkewX = skewX; } +#ifdef SK_SUPPORT_HINTING_SCALE_FACTOR +void SkPaint::setHintingScaleFactor(SkScalar hintingScaleFactor) { + GEN_ID_INC_EVAL(hintingScaleFactor != fHintingScaleFactor); + fHintingScaleFactor = hintingScaleFactor; +} +#endif + void SkPaint::setTextEncoding(TextEncoding encoding) { if ((unsigned)encoding <= kGlyphID_TextEncoding) { GEN_ID_INC_EVAL((unsigned)encoding != fTextEncoding); @@ -1500,6 +1510,9 @@ void SkScalerContext::MakeRec(const SkPaint& paint, rec->fTextSize = paint.getTextSize(); rec->fPreScaleX = paint.getTextScaleX(); rec->fPreSkewX = paint.getTextSkewX(); +#ifdef SK_SUPPORT_HINTING_SCALE_FACTOR + rec->fHintingScaleFactor = paint.getHintingScaleFactor(); +#endif if (deviceMatrix) { rec->fPost2x2[0][0] = sk_relax(deviceMatrix->getScaleX()); @@ -1948,10 +1961,18 @@ enum FlatFlags { }; // The size of a flat paint's POD fields + +#ifdef SK_SUPPORT_HINTING_SCALE_FACTOR +static const uint32_t kPODPaintSize = 6 * sizeof(SkScalar) + + 1 * sizeof(SkColor) + + 1 * sizeof(uint16_t) + + 6 * sizeof(uint8_t); +#else static const uint32_t kPODPaintSize = 5 * sizeof(SkScalar) + 1 * sizeof(SkColor) + 1 * sizeof(uint16_t) + 6 * sizeof(uint8_t); +#endif /* To save space/time, we analyze the paint, and write a truncated version of it if there are not tricky elements like shaders, etc. @@ -1981,6 +2002,9 @@ void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const { ptr = write_scalar(ptr, this->getTextSize()); ptr = write_scalar(ptr, this->getTextScaleX()); ptr = write_scalar(ptr, this->getTextSkewX()); +#ifdef SK_SUPPORT_HINTING_SCALE_FACTOR + ptr = write_scalar(ptr, this->getHintingScaleFactor()); +#endif ptr = write_scalar(ptr, this->getStrokeWidth()); ptr = write_scalar(ptr, this->getStrokeMiter()); *ptr++ = this->getColor(); @@ -1997,6 +2021,9 @@ void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const { buffer.writeScalar(fTextSize); buffer.writeScalar(fTextScaleX); buffer.writeScalar(fTextSkewX); +#ifdef SK_SUPPORT_HINTING_SCALE_FACTOR + buffer.writeScalar(fHintingScaleFactor); +#endif buffer.writeScalar(fWidth); buffer.writeScalar(fMiterLimit); buffer.writeColor(fColor); @@ -2042,6 +2069,9 @@ void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) { this->setTextSize(read_scalar(pod)); this->setTextScaleX(read_scalar(pod)); this->setTextSkewX(read_scalar(pod)); +#ifdef SK_SUPPORT_HINTING_SCALE_FACTOR + this->setHintingScaleFactor(read_scalar(pod)); +#endif this->setStrokeWidth(read_scalar(pod)); this->setStrokeMiter(read_scalar(pod)); this->setColor(*pod++); @@ -2068,6 +2098,9 @@ void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) { this->setTextSize(buffer.readScalar()); this->setTextScaleX(buffer.readScalar()); this->setTextSkewX(buffer.readScalar()); +#ifdef SK_SUPPORT_HINTING_SCALE_FACTOR + this->setHintingScaleFactor(buffer.readScalar()); +#endif this->setStrokeWidth(buffer.readScalar()); this->setStrokeMiter(buffer.readScalar()); this->setColor(buffer.readColor()); diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h index 2443aafe6e..8175582522 100644 --- a/src/core/SkScalerContext.h +++ b/src/core/SkScalerContext.h @@ -34,6 +34,9 @@ struct SkScalerContextRec { SkScalar fTextSize, fPreScaleX, fPreSkewX; SkScalar fPost2x2[2][2]; SkScalar fFrameWidth, fMiterLimit; +#ifdef SK_SUPPORT_HINTING_SCALE_FACTOR + SkScalar fHintingScaleFactor; +#endif //These describe the parameters to create (uniquely identify) the pre-blend. uint32_t fLumBits; -- cgit v1.2.3