diff options
author | joshualitt <joshualitt@google.com> | 2015-07-31 15:10:31 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-31 15:10:31 -0700 |
commit | d164a710c7658ee5326f2b61bcb7cd91bb019592 (patch) | |
tree | fe27ef4e363ade1aae1b176c4c2d08b201dedb96 /src/fonts | |
parent | f96bee384dea60a4e96035878e2671cd49d3b406 (diff) |
Revert of adding gm to use random scaler context (patchset #4 id:60001 of https://codereview.chromium.org/1268853008/)
Reason for revert:
breaking bots
Original issue's description:
> adding gm to use random scaler context
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/853336c532504b3436d7dcbf252419f00c79066d
TBR=bsalomon@google.com,joshualitt@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1259033004
Diffstat (limited to 'src/fonts')
-rw-r--r-- | src/fonts/SkRandomScalerContext.cpp | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/src/fonts/SkRandomScalerContext.cpp b/src/fonts/SkRandomScalerContext.cpp index 0693682faa..34392d6ed3 100644 --- a/src/fonts/SkRandomScalerContext.cpp +++ b/src/fonts/SkRandomScalerContext.cpp @@ -28,6 +28,7 @@ protected: private: SkRandomTypeface* fFace; SkScalerContext* fProxy; + SkMatrix fMatrix; bool fFakeIt; }; @@ -40,7 +41,28 @@ SkRandomScalerContext::SkRandomScalerContext(SkRandomTypeface* face, const SkDes : SkScalerContext(face, desc) , fFace(face) , fFakeIt(fakeIt) { - fProxy = face->proxy()->createScalerContext(desc); + size_t descSize = SkDescriptor::ComputeOverhead(1) + sizeof(SkScalerContext::Rec); + SkAutoDescriptor ad(descSize); + SkDescriptor* newDesc = ad.getDesc(); + + newDesc->init(); + void* entry = newDesc->addEntry(kRec_SkDescriptorTag, + sizeof(SkScalerContext::Rec), &fRec); + { + SkScalerContext::Rec* rec = (SkScalerContext::Rec*)entry; + rec->fTextSize = STD_SIZE; + rec->fPreScaleX = SK_Scalar1; + rec->fPreSkewX = 0; + rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1; + rec->fPost2x2[1][0] = rec->fPost2x2[0][1] = 0; + } + SkASSERT(descSize == newDesc->getLength()); + newDesc->computeChecksum(); + + fProxy = face->proxy()->createScalerContext(newDesc); + + fRec.getSingleMatrix(&fMatrix); + fMatrix.preScale(SK_Scalar1 / STD_SIZE, SK_Scalar1 / STD_SIZE); } SkRandomScalerContext::~SkRandomScalerContext() { @@ -57,6 +79,12 @@ uint16_t SkRandomScalerContext::generateCharToGlyph(SkUnichar uni) { void SkRandomScalerContext::generateAdvance(SkGlyph* glyph) { fProxy->getAdvance(glyph); + + SkVector advance; + fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX), + SkFixedToScalar(glyph->fAdvanceY), &advance); + glyph->fAdvanceX = SkScalarToFixed(advance.fX); + glyph->fAdvanceY = SkScalarToFixed(advance.fY); } void SkRandomScalerContext::generateMetrics(SkGlyph* glyph) { @@ -82,8 +110,15 @@ void SkRandomScalerContext::generateMetrics(SkGlyph* glyph) { return; } if (SkMask::kARGB32_Format == format) { + SkVector advance; + fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX), + SkFixedToScalar(glyph->fAdvanceY), &advance); + glyph->fAdvanceX = SkScalarToFixed(advance.fX); + glyph->fAdvanceY = SkScalarToFixed(advance.fY); + SkPath path; fProxy->getPath(*glyph, &path); + path.transform(fMatrix); SkRect storage; const SkPaint& paint = fFace->paint(); @@ -160,6 +195,7 @@ void SkRandomScalerContext::generateImage(const SkGlyph& glyph) { SkCanvas canvas(bm); canvas.translate(-SkIntToScalar(glyph.fLeft), -SkIntToScalar(glyph.fTop)); + canvas.concat(fMatrix); canvas.drawPath(path, fFace->paint()); } else { fProxy->forceGenerateImageFromPath(); @@ -173,10 +209,23 @@ void SkRandomScalerContext::generateImage(const SkGlyph& glyph) { void SkRandomScalerContext::generatePath(const SkGlyph& glyph, SkPath* path) { fProxy->getPath(glyph, path); + path->transform(fMatrix); } void SkRandomScalerContext::generateFontMetrics(SkPaint::FontMetrics* metrics) { fProxy->getFontMetrics(metrics); + if (metrics) { + SkScalar scale = fMatrix.getScaleY(); + metrics->fTop = SkScalarMul(metrics->fTop, scale); + metrics->fAscent = SkScalarMul(metrics->fAscent, scale); + metrics->fDescent = SkScalarMul(metrics->fDescent, scale); + metrics->fBottom = SkScalarMul(metrics->fBottom, scale); + metrics->fLeading = SkScalarMul(metrics->fLeading, scale); + metrics->fAvgCharWidth = SkScalarMul(metrics->fAvgCharWidth, scale); + metrics->fXMin = SkScalarMul(metrics->fXMin, scale); + metrics->fXMax = SkScalarMul(metrics->fXMax, scale); + metrics->fXHeight = SkScalarMul(metrics->fXHeight, scale); + } } /////////////////////////////////////////////////////////////////////////////// |