Revert "Support pixel antialising in DirectWrite."
authorMike Reed <reed@google.com>
Wed, 15 Mar 2017 23:51:22 +0000 (23:51 +0000)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 15 Mar 2017 23:51:33 +0000 (23:51 +0000)
This reverts commit 34db1eee20ffea6e423284bb06824653efff645d.

Reason for revert: breaks the chrome roll

E:\b\c\b\win_clang\src\third_party\skia\src\ports\SkScalerContext_win_dw.cpp(287,49):  error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        GaspRange range{bitmapPPEM, bitmapPPEM, 0};
                                                ^
                                                {}
E:\b\c\b\win_clang\src\third_party\skia\src\ports\SkScalerContext_win_dw.cpp(287,49):  error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        GaspRange range{bitmapPPEM, bitmapPPEM, 0};
                                                ^
                                                {}
E:\b\c\b\win_clang\src\third_party\skia\src\ports\SkScalerContext_win_dw.cpp(290,59):  error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
                range = GaspRange{bitmapPPEM, bitmapPPEM, 0};
                                                          ^
                                                          {}
E:\b\c\b\win_clang\src\third_party\skia\src\ports\SkScalerContext_win_dw.cpp(290,59):  error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
                range = GaspRange{bitmapPPEM, bitmapPPEM, 0};
                                                          ^
                                                          {}
E:\b\c\b\win_clang\src\third_party\skia\src\ports\SkScalerContext_win_dw.cpp(338,39):  error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        GaspRange range = {0, 0xFFFF, 0};
                                      ^
                                      {}
E:\b\c\b\win_clang\src\third_party\skia\src\ports\SkScalerContext_win_dw.cpp(338,39):  error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        GaspRange range = {0, 0xFFFF, 0};
                                      ^
                                      {}

Original change's description:
> Support pixel antialising in DirectWrite.
>
> DirectWrite2 supports pixel antialiasing and rendering without hinting.
>
> BUG=skia:5416
>
> Change-Id: I215245b20dd403669dbccd37e34cb2fcd5e06431
> Reviewed-on: https://skia-review.googlesource.com/9145
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Ben Wagner <bungeman@google.com>
>

TBR=mtklein@google.com,bungeman@google.com,reed@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:5416

Change-Id: Ic5f09abc3be8dd85d213a007780b3fe15fc11d92
Reviewed-on: https://skia-review.googlesource.com/9747
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>

src/ports/SkScalerContext_win_dw.cpp
src/ports/SkScalerContext_win_dw.h
src/ports/SkTypeface_win_dw.cpp
src/ports/SkTypeface_win_dw.h

index b2a61cc6ab4d99f08b38217b680f157fa35a8b08..d3cea9d6421627ae1a92ab580c1dc879d688eb2b 100644 (file)
@@ -68,33 +68,35 @@ static bool is_hinted_without_gasp(DWriteFontTypeface* typeface) {
     return !gasp.fExists;
 }
 
-/** A GaspRange is inclusive, [min, max]. */
-struct GaspRange {
+/** A PPEMRange is inclusive, [min, max]. */
+struct PPEMRange {
     int min;
     int max;
-    SkOTTableGridAndScanProcedure::GaspRange::behavior flags;
 };
 
-bool get_gasp_range(DWriteFontTypeface* typeface, int size, GaspRange* range) {
+/** If the rendering mode for the specified 'size' is gridfit, then place
+ *  the gridfit range into 'range'. Otherwise, leave 'range' alone.
+ */
+static void expand_range_if_gridfit_only(DWriteFontTypeface* typeface, int size, PPEMRange* range) {
     AutoTDWriteTable<SkOTTableGridAndScanProcedure> gasp(typeface->fDWriteFontFace.get());
     if (!gasp.fExists) {
-        return false;
+        return;
     }
     if (gasp.fSize < sizeof(SkOTTableGridAndScanProcedure)) {
-        return false;
+        return;
     }
     if (gasp->version != SkOTTableGridAndScanProcedure::version0 &&
         gasp->version != SkOTTableGridAndScanProcedure::version1)
     {
-        return false;
+        return;
     }
 
     uint16_t numRanges = SkEndianSwap16(gasp->numRanges);
     if (numRanges > 1024 ||
         gasp.fSize < sizeof(SkOTTableGridAndScanProcedure) +
-        sizeof(SkOTTableGridAndScanProcedure::GaspRange) * numRanges)
+                     sizeof(SkOTTableGridAndScanProcedure::GaspRange) * numRanges)
     {
-        return false;
+        return;
     }
 
     const SkOTTableGridAndScanProcedure::GaspRange* rangeTable =
@@ -102,40 +104,58 @@ bool get_gasp_range(DWriteFontTypeface* typeface, int size, GaspRange* range) {
     int minPPEM = -1;
     for (uint16_t i = 0; i < numRanges; ++i, ++rangeTable) {
         int maxPPEM = SkEndianSwap16(rangeTable->maxPPEM);
-        if (minPPEM < size && size <= maxPPEM) {
+        // Test that the size is in range and the range is gridfit only.
+        if (minPPEM < size && size <= maxPPEM &&
+            rangeTable->flags.raw.value == SkOTTableGridAndScanProcedure::GaspRange::behavior::Raw::GridfitMask)
+        {
             range->min = minPPEM + 1;
             range->max = maxPPEM;
-            range->flags = rangeTable->flags;
-            return true;
+            return;
         }
         minPPEM = maxPPEM;
     }
-    return false;
-}
-/** If the rendering mode for the specified 'size' is gridfit, then place
- *  the gridfit range into 'range'. Otherwise, leave 'range' alone.
- */
-static bool is_gridfit_only(SkOTTableGridAndScanProcedure::GaspRange::behavior flags) {
-    return flags.raw.value == SkOTTableGridAndScanProcedure::GaspRange::behavior::Raw::GridfitMask;
 }
 
 /** If the rendering mode for the specified 'size' sets SymmetricSmoothing, return true. */
-static bool gasp_allows_cleartype_symmetric(SkOTTableGridAndScanProcedure::GaspRange::behavior flags) {
+static bool gasp_allows_cleartype_symmetric(DWriteFontTypeface* typeface, int size) {
 #ifdef SK_IGNORE_DIRECTWRITE_GASP_FIX
     return true;
 #endif
-    return flags.field.SymmetricSmoothing;
-}
+    AutoTDWriteTable<SkOTTableGridAndScanProcedure> gasp(typeface->fDWriteFontFace.get());
+    if (!gasp.fExists) {
+        return false;
+    }
+    if (gasp.fSize < sizeof(SkOTTableGridAndScanProcedure)) {
+        return false;
+    }
+    if (gasp->version != SkOTTableGridAndScanProcedure::version0 &&
+        gasp->version != SkOTTableGridAndScanProcedure::version1)
+    {
+        return false;
+    }
 
-/** If gidfitting is enabled at this size, return true. */
-static bool gasp_allows_gridfit(SkOTTableGridAndScanProcedure::GaspRange::behavior flags, DWRITE_RENDERING_MODE renderingMode) {
-    if (renderingMode == DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC) {
-        return flags.field.SymmetricGridfit;
+    uint16_t numRanges = SkEndianSwap16(gasp->numRanges);
+    if (numRanges > 1024 ||
+        gasp.fSize < sizeof(SkOTTableGridAndScanProcedure) +
+                     sizeof(SkOTTableGridAndScanProcedure::GaspRange) * numRanges)
+    {
+        return false;
+    }
+
+    const SkOTTableGridAndScanProcedure::GaspRange* rangeTable =
+        SkTAfter<const SkOTTableGridAndScanProcedure::GaspRange>(gasp.get());
+    int minPPEM = -1;
+    for (uint16_t i = 0; i < numRanges; ++i, ++rangeTable) {
+        int maxPPEM = SkEndianSwap16(rangeTable->maxPPEM);
+        if (minPPEM < size && size <= maxPPEM) {
+            return rangeTable->flags.field.SymmetricSmoothing;
+        }
+        minPPEM = maxPPEM;
     }
-    return flags.field.Gridfit;
+    return false;
 }
 
-static bool has_bitmap_strike(DWriteFontTypeface* typeface, GaspRange range) {
+static bool has_bitmap_strike(DWriteFontTypeface* typeface, PPEMRange range) {
     SkAutoExclusive l(DWriteFactoryMutex);
     {
         AutoTDWriteTable<SkOTTableEmbeddedBitmapLocation> eblc(typeface->fDWriteFontFace.get());
@@ -228,11 +248,13 @@ SkScalerContext_DW::SkScalerContext_DW(sk_sp<DWriteFontTypeface> typefaceRef,
         , fGlyphCount(-1) {
 
     DWriteFontTypeface* typeface = this->getDWriteTypeface();
-    fIsColorFont = typeface->fFactory2 &&
-                   typeface->fDWriteFontFace2 &&
-                   typeface->fDWriteFontFace2->IsColorFont();
+    typeface->fFactory->QueryInterface<IDWriteFactory2>(&fFactory2);
+
+    SkTScopedComPtr<IDWriteFontFace2> fontFace2;
+    typeface->fDWriteFontFace->QueryInterface<IDWriteFontFace2>(&fontFace2);
+    fIsColorFont = fFactory2.get() && fontFace2.get() && fontFace2->IsColorFont();
 
-    // In general, all glyphs should use NATURAL_SYMMETRIC
+    // In general, all glyphs should use CLEARTYPE_NATURAL_SYMMETRIC
     // except when bi-level rendering is requested or there are embedded
     // bi-level bitmaps (and the embedded bitmap flag is set and no rotation).
     //
@@ -284,12 +306,8 @@ SkScalerContext_DW::SkScalerContext_DW(sk_sp<DWriteFontTypeface> typefaceRef,
         // When embedded bitmaps are requested, treat the entire range like
         // a bitmap strike if the range is gridfit only and contains a bitmap.
         int bitmapPPEM = SkScalarTruncToInt(gdiTextSize);
-        GaspRange range{bitmapPPEM, bitmapPPEM, 0};
-        if (get_gasp_range(typeface, bitmapPPEM, &range)) {
-            if (!is_gridfit_only(range.flags)) {
-                range = GaspRange{bitmapPPEM, bitmapPPEM, 0};
-            }
-        }
+        PPEMRange range = { bitmapPPEM, bitmapPPEM };
+        expand_range_if_gridfit_only(typeface, bitmapPPEM, &range);
         treatLikeBitmap = has_bitmap_strike(typeface, range);
 
         axisAlignedBitmap = is_axis_aligned(fRec);
@@ -307,7 +325,7 @@ SkScalerContext_DW::SkScalerContext_DW(sk_sp<DWriteFontTypeface> typefaceRef,
     // This will not always provide a bitmap, but matches expected behavior.
     } else if (treatLikeBitmap && axisAlignedBitmap) {
         fTextSizeRender = gdiTextSize;
-        fRenderingMode = DWRITE_RENDERING_MODE_GDI_CLASSIC;
+        fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC;
         fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1;
         fTextSizeMeasure = gdiTextSize;
         fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC;
@@ -316,7 +334,7 @@ SkScalerContext_DW::SkScalerContext_DW(sk_sp<DWriteFontTypeface> typefaceRef,
     // render high quality rotated glyphs but measure using bitmap metrics.
     } else if (treatLikeBitmap) {
         fTextSizeRender = gdiTextSize;
-        fRenderingMode = DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC;
+        fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC;
         fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1;
         fTextSizeMeasure = gdiTextSize;
         fMeasuringMode = DWRITE_MEASURING_MODE_GDI_CLASSIC;
@@ -327,7 +345,7 @@ SkScalerContext_DW::SkScalerContext_DW(sk_sp<DWriteFontTypeface> typefaceRef,
     // drop out control in the y direction in order to be legible.
     } else if (is_hinted_without_gasp(typeface)) {
         fTextSizeRender = gdiTextSize;
-        fRenderingMode = DWRITE_RENDERING_MODE_NATURAL;
+        fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
         fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1;
         fTextSizeMeasure = realTextSize;
         fMeasuringMode = DWRITE_MEASURING_MODE_NATURAL;
@@ -335,37 +353,14 @@ SkScalerContext_DW::SkScalerContext_DW(sk_sp<DWriteFontTypeface> typefaceRef,
     // The normal case is to use natural symmetric rendering (if permitted) and linear metrics.
     } else {
         fTextSizeRender = realTextSize;
-        GaspRange range = {0, 0xFFFF, 0};
-        get_gasp_range(typeface, SkScalarTruncToInt(fTextSizeRender), &range);
-        fRenderingMode = gasp_allows_cleartype_symmetric(range.flags)
-                       ? DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC
-                       : DWRITE_RENDERING_MODE_NATURAL;
+        fRenderingMode = gasp_allows_cleartype_symmetric(typeface, realTextSize)
+                       ? DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC
+                       : DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
         fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1;
         fTextSizeMeasure = realTextSize;
         fMeasuringMode = DWRITE_MEASURING_MODE_NATURAL;
     }
 
-    // DirectWrite2 allows for grayscale hinting.
-    fAntiAliasMode = DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE;
-#ifndef SK_IGNORE_DW_GRAY_FIX
-    if (typeface->fFactory2 && typeface->fDWriteFontFace2 &&
-        !isLCD(fRec) && !(fRec.fFlags & SkScalerContext::kGenA8FromLCD_Flag))
-    {
-        // DWRITE_TEXTURE_ALIASED_1x1 is now misnamed, it must also be used with grayscale.
-        fTextureType = DWRITE_TEXTURE_ALIASED_1x1;
-        fAntiAliasMode = DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE;
-    }
-#endif
-
-    // DirectWrite2 allows hinting to be disabled.
-    fGridFitMode = DWRITE_GRID_FIT_MODE_ENABLED;
-    if (fRec.getHinting() == SkPaint::kNo_Hinting) {
-        fGridFitMode = DWRITE_GRID_FIT_MODE_DISABLED;
-        if (fRenderingMode != DWRITE_RENDERING_MODE_ALIASED) {
-            fRenderingMode = DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC;
-        }
-    }
-
     if (this->isSubpixel()) {
         fTextSizeMeasure = realTextSize;
         fMeasuringMode = DWRITE_MEASURING_MODE_NATURAL;
@@ -473,33 +468,16 @@ HRESULT SkScalerContext_DW::getBoundingBox(SkGlyph* glyph,
     SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis;
     {
         SkAutoExclusive l(DWriteFactoryMutex);
-        // IDWriteFactory2::CreateGlyphRunAnalysis is very bad at aliased glyphs.
-        if (this->getDWriteTypeface()->fFactory2 &&
-                (fGridFitMode == DWRITE_GRID_FIT_MODE_DISABLED ||
-                 fAntiAliasMode == DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE))
-        {
-            HRM(this->getDWriteTypeface()->fFactory2->CreateGlyphRunAnalysis(
-                    &run,
-                    &fXform,
-                    renderingMode,
-                    fMeasuringMode,
-                    fGridFitMode,
-                    fAntiAliasMode,
-                    0.0f, // baselineOriginX,
-                    0.0f, // baselineOriginY,
-                    &glyphRunAnalysis),
-                "Could not create DW2 glyph run analysis.");
-        } else {
-            HRM(this->getDWriteTypeface()->fFactory->CreateGlyphRunAnalysis(&run,
-                    1.0f, // pixelsPerDip,
-                    &fXform,
-                    renderingMode,
-                    fMeasuringMode,
-                    0.0f, // baselineOriginX,
-                    0.0f, // baselineOriginY,
-                    &glyphRunAnalysis),
-                "Could not create glyph run analysis.");
-        }
+        HRM(this->getDWriteTypeface()->fFactory->CreateGlyphRunAnalysis(
+            &run,
+            1.0f, // pixelsPerDip,
+            &fXform,
+            renderingMode,
+            fMeasuringMode,
+            0.0f, // baselineOriginX,
+            0.0f, // baselineOriginY,
+            &glyphRunAnalysis),
+            "Could not create glyph run analysis.");
     }
     {
         Shared l(DWriteFactoryMutex);
@@ -550,7 +528,7 @@ bool SkScalerContext_DW::getColorGlyphRun(const SkGlyph& glyph,
     run.isSideways = FALSE;
     run.glyphOffsets = &offset;
 
-    HRESULT hr = this->getDWriteTypeface()->fFactory2->TranslateColorGlyphRun(
+    HRESULT hr = fFactory2->TranslateColorGlyphRun(
         0, 0, &run, nullptr, fMeasuringMode, &fXform, 0, colorGlyph);
     if (hr == DWRITE_E_NOCOLOR) {
         return false;
@@ -701,22 +679,6 @@ static void bilevel_to_bw(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph)
     }
 }
 
-template<bool APPLY_PREBLEND>
-static void grayscale_to_a8(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph,
-                            const uint8_t* table8) {
-    const size_t dstRB = glyph.rowBytes();
-    const U16CPU width = glyph.fWidth;
-    uint8_t* SK_RESTRICT dst = static_cast<uint8_t*>(glyph.fImage);
-
-    for (U16CPU y = 0; y < glyph.fHeight; y++) {
-        for (U16CPU i = 0; i < width; i++) {
-            U8CPU a = *(src++);
-            dst[i] = sk_apply_lut_if<APPLY_PREBLEND>(a, table8);
-        }
-        dst = SkTAddOffset<uint8_t>(dst, dstRB);
-    }
-}
-
 template<bool APPLY_PREBLEND>
 static void rgb_to_a8(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph, const uint8_t* table8) {
     const size_t dstRB = glyph.rowBytes();
@@ -730,7 +692,7 @@ static void rgb_to_a8(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph, cons
             U8CPU b = *(src++);
             dst[i] = sk_apply_lut_if<APPLY_PREBLEND>((r + g + b) / 3, table8);
         }
-        dst = SkTAddOffset<uint8_t>(dst, dstRB);
+        dst = (uint8_t*)((char*)dst + dstRB);
     }
 }
 
@@ -755,7 +717,7 @@ static void rgb_to_lcd16(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph,
             }
             dst[i] = SkPack888ToRGB16(r, g, b);
         }
-        dst = SkTAddOffset<uint16_t>(dst, dstRB);
+        dst = (uint16_t*)((char*)dst + dstRB);
     }
 }
 
@@ -764,7 +726,7 @@ const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph,
                                            DWRITE_TEXTURE_TYPE textureType)
 {
     int sizeNeeded = glyph.fWidth * glyph.fHeight;
-    if (DWRITE_TEXTURE_CLEARTYPE_3x1 == textureType) {
+    if (DWRITE_RENDERING_MODE_ALIASED != renderingMode) {
         sizeNeeded *= 3;
     }
     if (sizeNeeded > fBits.count()) {
@@ -795,35 +757,19 @@ const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph,
     run.isSideways = FALSE;
     run.glyphOffsets = &offset;
     {
+
         SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis;
         {
             SkAutoExclusive l(DWriteFactoryMutex);
-            // IDWriteFactory2::CreateGlyphRunAnalysis is very bad at aliased glyphs.
-            if (this->getDWriteTypeface()->fFactory2 &&
-                    (fGridFitMode == DWRITE_GRID_FIT_MODE_DISABLED ||
-                     fAntiAliasMode == DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE))
-            {
-                HRNM(this->getDWriteTypeface()->fFactory2->CreateGlyphRunAnalysis(&run,
-                         &fXform,
-                         renderingMode,
-                         fMeasuringMode,
-                         fGridFitMode,
-                         fAntiAliasMode,
-                         0.0f, // baselineOriginX,
-                         0.0f, // baselineOriginY,
-                         &glyphRunAnalysis),
-                     "Could not create DW2 glyph run analysis.");
-            } else {
-                HRNM(this->getDWriteTypeface()->fFactory->CreateGlyphRunAnalysis(&run,
-                         1.0f, // pixelsPerDip,
-                         &fXform,
-                         renderingMode,
-                         fMeasuringMode,
-                         0.0f, // baselineOriginX,
-                         0.0f, // baselineOriginY,
-                         &glyphRunAnalysis),
-                     "Could not create glyph run analysis.");
-            }
+            HRNM(this->getDWriteTypeface()->fFactory->CreateGlyphRunAnalysis(&run,
+                1.0f, // pixelsPerDip,
+                &fXform,
+                renderingMode,
+                fMeasuringMode,
+                0.0f, // baselineOriginX,
+                0.0f, // baselineOriginY,
+                &glyphRunAnalysis),
+                "Could not create glyph run analysis.");
         }
         //NOTE: this assumes that the glyph has already been measured
         //with an exact same glyph run analysis.
@@ -835,9 +781,9 @@ const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph,
         {
             Shared l(DWriteFactoryMutex);
             HRNM(glyphRunAnalysis->CreateAlphaTexture(textureType,
-                    &bbox,
-                    fBits.begin(),
-                    sizeNeeded),
+                &bbox,
+                fBits.begin(),
+                sizeNeeded),
                 "Could not draw mask.");
         }
     }
@@ -937,18 +883,10 @@ void SkScalerContext_DW::generateImage(const SkGlyph& glyph) {
         bilevel_to_bw(src, glyph);
         const_cast<SkGlyph&>(glyph).fMaskFormat = SkMask::kBW_Format;
     } else if (!isLCD(fRec)) {
-        if (textureType == DWRITE_TEXTURE_ALIASED_1x1) {
-            if (fPreBlend.isApplicable()) {
-                grayscale_to_a8<true>(src, glyph, fPreBlend.fG);
-            } else {
-                grayscale_to_a8<false>(src, glyph, fPreBlend.fG);
-            }
+        if (fPreBlend.isApplicable()) {
+            rgb_to_a8<true>(src, glyph, fPreBlend.fG);
         } else {
-            if (fPreBlend.isApplicable()) {
-                rgb_to_a8<true>(src, glyph, fPreBlend.fG);
-            } else {
-                rgb_to_a8<false>(src, glyph, fPreBlend.fG);
-            }
+            rgb_to_a8<false>(src, glyph, fPreBlend.fG);
         }
     } else {
         SkASSERT(SkMask::kLCD16_Format == glyph.fMaskFormat);
index f186ea52dc36c8d77af0fe3ae738e3bf7b72459f..e13e01a61b933ae6b79fa8af290dbdd6029adbe5 100644 (file)
@@ -76,8 +76,7 @@ private:
     DWRITE_RENDERING_MODE fRenderingMode;
     DWRITE_TEXTURE_TYPE fTextureType;
     DWRITE_MEASURING_MODE fMeasuringMode;
-    DWRITE_TEXT_ANTIALIAS_MODE fAntiAliasMode;
-    DWRITE_GRID_FIT_MODE fGridFitMode;
+    SkTScopedComPtr<IDWriteFactory2> fFactory2;
     bool fIsColorFont;
 };
 
index 7d18da9d5af51ee805c9364fdbb31c81fa7cc301..3acdd213ac21fd09be76fd2e8f6ad85cbfa4a676 100644 (file)
@@ -253,7 +253,6 @@ SkScalerContext* DWriteFontTypeface::onCreateScalerContext(const SkScalerContext
 void DWriteFontTypeface::onFilterRec(SkScalerContext::Rec* rec) const {
     if (rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) {
         rec->fMaskFormat = SkMask::kA8_Format;
-        rec->fFlags |= SkScalerContext::kGenA8FromLCD_Flag;
     }
 
     unsigned flagsWeDontSupport = SkScalerContext::kVertical_Flag |
@@ -264,10 +263,8 @@ void DWriteFontTypeface::onFilterRec(SkScalerContext::Rec* rec) const {
     rec->fFlags &= ~flagsWeDontSupport;
 
     SkPaint::Hinting h = rec->getHinting();
-    // DirectWrite2 allows for hinting to be turned off. Force everything else to normal.
-    if (h != SkPaint::kNo_Hinting || !fFactory2 || !fDWriteFontFace2) {
-        h = SkPaint::kNormal_Hinting;
-    }
+    // DirectWrite does not provide for hinting hints.
+    h = SkPaint::kSlight_Hinting;
     rec->setHinting(h);
 
 #if defined(SK_FONT_HOST_USE_SYSTEM_SETTINGS)
index d7c73e269792752c506098d25dbfb03a239f5835..d4d4facab1748bbbdeff5302ae056be83a0501c1 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <dwrite.h>
 #include <dwrite_1.h>
-#include <dwrite_2.h>
 
 class SkFontDescriptor;
 struct SkScalerContextRec;
@@ -58,24 +57,16 @@ private:
             // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
             SkASSERT_RELEASE(nullptr == fDWriteFontFace1.get());
         }
-        if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace2))) {
-            SkASSERT_RELEASE(nullptr == fDWriteFontFace2.get());
-        }
-        if (!SUCCEEDED(fFactory->QueryInterface(&fFactory2))) {
-            SkASSERT_RELEASE(nullptr == fFactory2.get());
-        }
     }
 
 public:
     SkTScopedComPtr<IDWriteFactory> fFactory;
-    SkTScopedComPtr<IDWriteFactory2> fFactory2;
     SkTScopedComPtr<IDWriteFontCollectionLoader> fDWriteFontCollectionLoader;
     SkTScopedComPtr<IDWriteFontFileLoader> fDWriteFontFileLoader;
     SkTScopedComPtr<IDWriteFontFamily> fDWriteFontFamily;
     SkTScopedComPtr<IDWriteFont> fDWriteFont;
     SkTScopedComPtr<IDWriteFontFace> fDWriteFontFace;
     SkTScopedComPtr<IDWriteFontFace1> fDWriteFontFace1;
-    SkTScopedComPtr<IDWriteFontFace2> fDWriteFontFace2;
 
     static DWriteFontTypeface* Create(IDWriteFactory* factory,
                                       IDWriteFontFace* fontFace,