Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(875)

Unified Diff: src/ports/SkFontHost_FreeType_common.cpp

Issue 2139703002: Rotate emoji with FreeType. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove whitespace. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_FreeType_common.cpp
diff --git a/src/ports/SkFontHost_FreeType_common.cpp b/src/ports/SkFontHost_FreeType_common.cpp
index 245ded1283572362da007c6837caf4e9d9486e0a..26e02fd1b9a4d00777c29a17e9304281ce5d2397 100644
--- a/src/ports/SkFontHost_FreeType_common.cpp
+++ b/src/ports/SkFontHost_FreeType_common.cpp
@@ -177,8 +177,18 @@ static void copyFT2LCD16(const FT_Bitmap& bitmap, const SkMask& mask, int lcdIsB
* TODO: All of these N need to be Y or otherwise ruled out.
*/
static void copyFTBitmap(const FT_Bitmap& srcFTBitmap, SkMask& dstMask) {
- SkASSERT(dstMask.fBounds.width() == static_cast<int>(srcFTBitmap.width));
- SkASSERT(dstMask.fBounds.height() == static_cast<int>(srcFTBitmap.rows));
+ SkASSERTF(dstMask.fBounds.width() == static_cast<int>(srcFTBitmap.width),
+ "dstMask.fBounds.width() = %d\n"
+ "static_cast<int>(srcFTBitmap.width) = %d",
+ dstMask.fBounds.width(),
+ static_cast<int>(srcFTBitmap.width)
+ );
+ SkASSERTF(dstMask.fBounds.height() == static_cast<int>(srcFTBitmap.rows),
+ "dstMask.fBounds.height() = %d\n"
+ "static_cast<int>(srcFTBitmap.rows) = %d",
+ dstMask.fBounds.height(),
+ static_cast<int>(srcFTBitmap.rows)
+ );
const uint8_t* src = reinterpret_cast<const uint8_t*>(srcFTBitmap.buffer);
const FT_Pixel_Mode srcFormat = static_cast<FT_Pixel_Mode>(srcFTBitmap.pixel_mode);
@@ -334,7 +344,11 @@ inline SkColorType SkColorType_for_SkMaskFormat(SkMask::Format format) {
}
}
-void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGlyph& glyph) {
+void SkScalerContext_FreeType_Base::generateGlyphImage(
+ FT_Face face,
+ const SkGlyph& glyph,
+ const SkMatrix& bitmapTransform)
+{
const bool doBGR = SkToBool(fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag);
const bool doVert = SkToBool(fRec.fFlags & SkScalerContext::kLCD_Vertical_Flag);
@@ -402,20 +416,8 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly
SkMask::kARGB32_Format == maskFormat ||
SkMask::kLCD16_Format == maskFormat);
- if (fRec.fFlags & SkScalerContext::kEmbolden_Flag &&
- !(face->style_flags & FT_STYLE_FLAG_BOLD))
- {
- FT_GlyphSlot_Own_Bitmap(face->glyph);
- FT_Bitmap_Embolden(face->glyph->library, &face->glyph->bitmap,
- kBitmapEmboldenStrength, 0);
- }
-
// If no scaling needed, directly copy glyph bitmap.
- if (glyph.fWidth == face->glyph->bitmap.width &&
- glyph.fHeight == face->glyph->bitmap.rows &&
- glyph.fTop == -face->glyph->bitmap_top &&
- glyph.fLeft == face->glyph->bitmap_left)
- {
+ if (bitmapTransform.isIdentity()) {
SkMask dstMask;
glyph.toMask(&dstMask);
copyFTBitmap(face->glyph->bitmap, dstMask);
@@ -426,6 +428,7 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly
// Copy the FT_Bitmap into an SkBitmap (either A8 or ARGB)
SkBitmap unscaledBitmap;
+ // TODO: mark this as sRGB when the blits will be sRGB.
unscaledBitmap.allocPixels(SkImageInfo::Make(face->glyph->bitmap.width,
face->glyph->bitmap.rows,
SkColorType_for_FTPixelMode(pixel_mode),
@@ -447,6 +450,7 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly
bitmapRowBytes = glyph.rowBytes();
}
SkBitmap dstBitmap;
+ // TODO: mark this as sRGB when the blits will be sRGB.
dstBitmap.setInfo(SkImageInfo::Make(glyph.fWidth, glyph.fHeight,
SkColorType_for_SkMaskFormat(maskFormat),
kPremul_SkAlphaType),
@@ -459,9 +463,15 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly
// Scale unscaledBitmap into dstBitmap.
SkCanvas canvas(dstBitmap);
+#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
+ canvas.clear(0x33FF0000);
+#else
canvas.clear(SK_ColorTRANSPARENT);
- canvas.scale(SkIntToScalar(glyph.fWidth) / SkIntToScalar(face->glyph->bitmap.width),
- SkIntToScalar(glyph.fHeight) / SkIntToScalar(face->glyph->bitmap.rows));
+#endif
+ canvas.translate(-glyph.fLeft, -glyph.fTop);
+ canvas.concat(bitmapTransform);
+ canvas.translate(face->glyph->bitmap_left, -face->glyph->bitmap_top);
+
SkPaint paint;
paint.setFilterQuality(kMedium_SkFilterQuality);
canvas.drawBitmap(unscaledBitmap, 0, 0, &paint);
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698