Changeset 206597 in webkit


Ignore:
Timestamp:
Sep 29, 2016 11:45:08 AM (8 years ago)
Author:
Brent Fulgham
Message:

[Win][Direct2D] Add D2D Font handling code
https://bugs.webkit.org/show_bug.cgi?id=162712

Reviewed by Brent Fulgham.

This patch lands a set of new files that implement

No new tests until complete backend lands.

  • platform/graphics/Font.h:
  • platform/graphics/FontCascade.h:

(WebCore::FontCascade::syntheticObliqueAngle): Added helper function.

  • platform/graphics/FontPlatformData.h:

(WebCore::FontPlatformData::dwFont): Added.
(WebCore::FontPlatformData::dwFontFace): Ditto.

  • platform/graphics/GlyphBuffer.h:
  • platform/graphics/cocoa/FontCascadeCocoa.mm:

(WebCore::FontCascade::drawGlyphs): Use helper function.

  • platform/graphics/win/FontCGWin.cpp:

(WebCore::FontCascade::drawGlyphs): Ditto.

  • platform/graphics/win/FontCacheWin.cpp:

(WebCore::FontCache::createFontPlatformData): Add case for Direct2D.

  • platform/graphics/win/FontCascadeDirect2D.cpp: Added.
  • platform/graphics/win/FontCustomPlatformData.cpp:

(WebCore::FontCustomPlatformData::~FontCustomPlatformData): Fix whitespace.
(WebCore::FontCustomPlatformData::fontPlatformData): Add Direct2D case.

  • platform/graphics/win/FontPlatformDataCGWin.cpp:

(WebCore::FontPlatformData::FontPlatformData): Clean up C++ initializers.

  • platform/graphics/win/FontPlatformDataCairoWin.cpp:

(WebCore::FontPlatformData::FontPlatformData): Ditto.

  • platform/graphics/win/FontPlatformDataDirect2D.cpp: Added.
  • platform/graphics/win/FontPlatformDataWin.cpp:

(WebCore::FontPlatformData::FontPlatformData): Clean up C++ initializers.

  • platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp: Added.
  • platform/graphics/win/SimpleFontDataDirect2D.cpp: Added.
  • platform/graphics/win/TextAnalyzerHelper.cpp: Added.
  • platform/graphics/win/TextAnalyzerHelper.h: Added.
Location:
trunk/Source/WebCore
Files:
6 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206593 r206597  
     12016-09-29  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Win][Direct2D] Add D2D Font handling code
     4        https://bugs.webkit.org/show_bug.cgi?id=162712
     5
     6        Reviewed by Brent Fulgham.
     7
     8        This patch lands a set of new files that implement
     9
     10        No new tests until complete backend lands.
     11
     12        * platform/graphics/Font.h:
     13        * platform/graphics/FontCascade.h:
     14        (WebCore::FontCascade::syntheticObliqueAngle): Added helper function.
     15        * platform/graphics/FontPlatformData.h:
     16        (WebCore::FontPlatformData::dwFont): Added.
     17        (WebCore::FontPlatformData::dwFontFace): Ditto.
     18        * platform/graphics/GlyphBuffer.h:
     19        * platform/graphics/cocoa/FontCascadeCocoa.mm:
     20        (WebCore::FontCascade::drawGlyphs): Use helper function.
     21        * platform/graphics/win/FontCGWin.cpp:
     22        (WebCore::FontCascade::drawGlyphs): Ditto.
     23        * platform/graphics/win/FontCacheWin.cpp:
     24        (WebCore::FontCache::createFontPlatformData): Add case for Direct2D.
     25        * platform/graphics/win/FontCascadeDirect2D.cpp: Added.
     26        * platform/graphics/win/FontCustomPlatformData.cpp:
     27        (WebCore::FontCustomPlatformData::~FontCustomPlatformData): Fix whitespace.
     28        (WebCore::FontCustomPlatformData::fontPlatformData): Add Direct2D case.
     29        * platform/graphics/win/FontPlatformDataCGWin.cpp:
     30        (WebCore::FontPlatformData::FontPlatformData): Clean up C++ initializers.
     31        * platform/graphics/win/FontPlatformDataCairoWin.cpp:
     32        (WebCore::FontPlatformData::FontPlatformData): Ditto.
     33        * platform/graphics/win/FontPlatformDataDirect2D.cpp: Added.
     34        * platform/graphics/win/FontPlatformDataWin.cpp:
     35        (WebCore::FontPlatformData::FontPlatformData): Clean up C++ initializers.
     36        * platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp: Added.
     37        * platform/graphics/win/SimpleFontDataDirect2D.cpp: Added.
     38        * platform/graphics/win/TextAnalyzerHelper.cpp: Added.
     39        * platform/graphics/win/TextAnalyzerHelper.h: Added.
     40
    1412016-09-29  Alex Christensen  <achristensen@webkit.org>
    242
  • trunk/Source/WebCore/platform/graphics/Font.h

    r205703 r206597  
    22 * This file is part of the internal font implementation.
    33 *
    4  * Copyright (C) 2006, 2008, 2010, 2015 Apple Inc. All rights reserved.
     4 * Copyright (C) 2006, 2008, 2010, 2015-2016 Apple Inc. All rights reserved.
    55 * Copyright (C) 2007-2008 Torch Mobile, Inc.
    66 *
     
    5656#if USE(CG)
    5757#include "CoreGraphicsSPI.h"
     58#endif
     59
     60#if USE(DIRECT2D)
     61interface IDWriteFactory;
     62interface IDWriteGdiInterop;
    5863#endif
    5964
     
    144149    }
    145150
    146 #if USE(CG) || USE(CAIRO)
     151#if USE(CG) || USE(DIRECT2D) || USE(CAIRO)
    147152    float syntheticBoldOffset() const { return m_syntheticBoldOffset; }
    148153#endif
     
    197202    static bool shouldApplyMacAscentHack();
    198203    static float ascentConsideringMacAscentHack(const WCHAR*, float ascent, float descent);
     204#endif
     205
     206#if USE(DIRECT2D)
     207    WEBCORE_EXPORT static IDWriteFactory* systemDWriteFactory();
     208    WEBCORE_EXPORT static IDWriteGdiInterop* systemDWriteGdiInterop();
    199209#endif
    200210
     
    268278    mutable std::unique_ptr<DerivedFonts> m_derivedFontData;
    269279
    270 #if USE(CG) || USE(CAIRO)
     280#if USE(CG) || USE(DIRECT2D) || USE(CAIRO)
    271281    float m_syntheticBoldOffset;
    272282#endif
     
    339349#if ENABLE(OPENTYPE_VERTICAL)
    340350    if (m_verticalData) {
    341 #if USE(CG) || USE(CAIRO)
     351#if USE(CG) || USE(DIRECT2D) || USE(CAIRO)
    342352        width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffset;
    343353#else
  • trunk/Source/WebCore/platform/graphics/FontCascade.h

    r206395 r206597  
    33 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
     5 * Copyright (C) 2003, 2006, 2007, 2010, 2011-2016 Apple Inc. All rights reserved.
    66 * Copyright (C) 2008 Holger Hans Peter Freyther
    77 *
     
    321321    }
    322322
     323    static int syntheticObliqueAngle() { return 14; }
     324
    323325    FontCascadeDescription m_fontDescription;
    324326    mutable RefPtr<FontCascadeFonts> m_fonts;
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.h

    r205883 r206597  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2010, 2013 Apple Inc.
     2 * Copyright (C) 2006, 2007, 2008, 2010, 2013-2016 Apple Inc.
    33 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
    44 * Copyright (C) 2007 Holger Hans Peter Freyther
     
    2929
    3030#if PLATFORM(WIN)
     31#include "COMPtr.h"
    3132#include "SharedGDIObject.h"
    3233#endif
     
    6667#include <wtf/win/GDIObject.h>
    6768typedef struct HFONT__* HFONT;
     69interface IDWriteFont;
     70interface IDWriteFontFace;
    6871#endif
    6972
     
    104107#if USE(CG)
    105108    FontPlatformData(GDIObject<HFONT>, CGFontRef, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
     109#elif USE(DIRECT2D)
     110    FontPlatformData(GDIObject<HFONT>, IDWriteFont*, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
    106111#elif USE(CAIRO)
    107112    FontPlatformData(GDIObject<HFONT>, cairo_font_face_t*, float size, bool bold, bool italic);
     
    136141#if USE(CG) && (PLATFORM(WIN) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 100000))
    137142    CGFontRef cgFont() const { return m_cgFont.get(); }
     143#endif
     144
     145#if USE(DIRECT2D)
     146    IDWriteFont* dwFont() const { return m_dwFont.get(); }
     147    IDWriteFontFace* dwFontFace() const { return m_dwFontFace.get(); }
    138148#endif
    139149
     
    242252    RetainPtr<CGFontRef> m_cgFont;
    243253#endif
     254#if USE(DIRECT2D)
     255    COMPtr<IDWriteFont> m_dwFont;
     256    COMPtr<IDWriteFontFace> m_dwFontFace;
     257#endif
    244258#if USE(CAIRO)
    245259    RefPtr<cairo_scaled_font_t> m_scaledFont;
  • trunk/Source/WebCore/platform/graphics/GlyphBuffer.h

    r205775 r206597  
    11/*
    2  * Copyright (C) 2006, 2009, 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2009, 2011, 2016 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007-2008 Torch Mobile Inc.
    44 *
     
    9797    const GlyphBufferGlyph* glyphs(unsigned from) const { return m_glyphs.data() + from; }
    9898    const GlyphBufferAdvance* advances(unsigned from) const { return m_advances.data() + from; }
     99    size_t advancesCount() const { return m_advances.size(); }
    99100
    100101    const Font* fontAt(unsigned index) const { return m_font[index]; }
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm

    r206422 r206597  
    33 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
     5 * Copyright (C) 2003, 2006-2011, 2016 Apple Inc.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    5151#endif
    5252
    53 #define SYNTHETIC_OBLIQUE_ANGLE 14
    54 
    5553#ifdef __LP64__
    5654#define URefCon void*
     
    245243    matrix.d = -matrix.d;
    246244    if (platformData.syntheticOblique()) {
    247         static float obliqueSkew = tanf(SYNTHETIC_OBLIQUE_ANGLE * piFloat / 180);
     245        static float obliqueSkew = tanf(syntheticObliqueAngle() * piFloat / 180);
    248246        if (platformData.orientation() == Vertical)
    249247            matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, obliqueSkew, 0, 1, 0, 0));
  • trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp

    r204858 r206597  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006-2009, 2013, 2016 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4141namespace WebCore {
    4242
    43 const int syntheticObliqueAngle = 14;
    44 
    4543static inline CGFloat toCGFloat(FIXED f)
    4644{
     
    169167
    170168    if (platformData.syntheticOblique()) {
    171         static float skew = -tanf(syntheticObliqueAngle * piFloat / 180.0f);
     169        static float skew = -tanf(syntheticObliqueAngle() * piFloat / 180.0f);
    172170        matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, skew, 1, 0, 0));
    173171    }
  • trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp

    r204558 r206597  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2013-2014 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006-2008, 2013-2014 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4646#include <ApplicationServices/ApplicationServices.h>
    4747#include <WebKitSystemInterface/WebKitSystemInterface.h>
     48#endif
     49
     50#if USE(DIRECT2D)
     51#include <dwrite.h>
    4852#endif
    4953
     
    550554    return 1;
    551555}
     556
    552557Vector<FontTraitsMask> FontCache::getTraitsInFamily(const AtomicString& familyName)
    553558{
     
    600605#if USE(CG)
    601606    bool fontCreationFailed = !result->cgFont();
     607#elif USE(DIRECT2D)
     608    bool fontCreationFailed = !result->dwFont();
    602609#elif USE(CAIRO)
    603610    bool fontCreationFailed = !result->scaledFont();
  • trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp

    r195743 r206597  
    11/*
    2  * Copyright (C) 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007-2010, 2013, 2016 Apple Inc. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    2626#include "OpenTypeUtilities.h"
    2727#include "SharedBuffer.h"
    28 #include <ApplicationServices/ApplicationServices.h>
    29 #include <WebKitSystemInterface/WebKitSystemInterface.h>
    3028#include <wtf/RetainPtr.h>
    3129#include <wtf/text/Base64.h>
    3230#include <wtf/win/GDIObject.h>
    3331
     32#if USE(CG)
     33#include <ApplicationServices/ApplicationServices.h>
     34#include <WebKitSystemInterface/WebKitSystemInterface.h>
     35#endif
     36
     37#if USE(DIRECT2D)
     38#include "Font.h"
     39#include <dwrite.h>
     40#endif
     41
    3442namespace WebCore {
    35 
    36 using namespace std;
    3743
    3844FontCustomPlatformData::~FontCustomPlatformData()
    3945{
    4046    if (m_fontReference)
    41             RemoveFontMemResourceEx(m_fontReference);
     47        RemoveFontMemResourceEx(m_fontReference);
    4248}
    4349
     
    6975    auto hfont = adoptGDIObject(::CreateFontIndirect(&logFont));
    7076
     77#if USE(CG)
    7178    RetainPtr<CGFontRef> cgFont = adoptCF(CGFontCreateWithPlatformFont(&logFont));
    7279    return FontPlatformData(WTFMove(hfont), cgFont.get(), size, bold, italic, renderingMode == FontRenderingMode::Alternate);
     80#else
     81    COMPtr<IDWriteFont> dwFont;
     82    HRESULT hr = Font::systemDWriteGdiInterop()->CreateFontFromLOGFONT(&logFont, &dwFont);
     83    RELEASE_ASSERT(SUCCEEDED(hr));
     84    return FontPlatformData(WTFMove(hfont), dwFont.get(), size, bold, italic, renderingMode == FontRenderingMode::Alternate);
     85#endif
    7386}
    7487
  • trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h

    r188130 r206597  
    11/*
    2  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007-2008, 2016 Apple Inc. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
  • trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp

    r195743 r206597  
    11/*
    2  * Copyright (C) 2007, 2008, 2013 Apple Inc.
     2 * Copyright (C) 2007-2008, 2013, 2016 Apple Inc.
    33 *
    44 * This library is free software; you can redistribute it and/or
  • trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp

    r200104 r206597  
    33 * FontMac.cpp, FontWin.cpp and Font.cpp.
    44 *
    5  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc.
     5 * Copyright (C) 2006-2009, 2016 Apple Inc.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    121121    : m_syntheticBold(bold)
    122122    , m_syntheticOblique(oblique)
    123     , m_orientation(Horizontal)
    124123    , m_size(size)
    125     , m_widthVariant(RegularWidth)
    126124    , m_font(SharedGDIObject<HFONT>::create(WTFMove(hfont)))
    127125    , m_cgFont(font)
    128     , m_isColorBitmapFont(false)
    129126    , m_useGDI(useGDI)
    130127{
  • trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp

    r200104 r206597  
    33 * FontMac.cpp, FontWin.cpp and Font.cpp.
    44 *
    5  * Copyright (C) 2006, 2007, 2008 Apple Inc.
     5 * Copyright (C) 2006-2008, 2016 Apple Inc.
    66 * Copyright (C) 2007 Alp Toker
    77 * Copyright (C) 2008, 2010, 2011 Brent Fulgham
     
    6363    : m_font(SharedGDIObject<HFONT>::create(WTFMove(font)))
    6464    , m_size(size)
    65     , m_orientation(Horizontal)
    66     , m_widthVariant(RegularWidth)
    67     , m_isColorBitmapFont(false)
    68     , m_syntheticBold(bold)
    6965    , m_syntheticOblique(oblique)
    70     , m_useGDI(false)
    7166{
    7267    cairo_matrix_t fontMatrix;
  • trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp

    r200104 r206597  
    33 * FontMac.cpp, FontWin.cpp and Font.cpp.
    44 *
    5  * Copyright (C) 2006, 2007, 2008 Apple Inc.
     5 * Copyright (C) 2006-2008, 2016 Apple Inc.
    66 * Copyright (C) 2008 Brent Fulgham
    77 *
     
    4141    : m_font(SharedGDIObject<HFONT>::create(WTFMove(font)))
    4242    , m_size(size)
    43     , m_orientation(Horizontal)
    44     , m_widthVariant(RegularWidth)
    45     , m_isColorBitmapFont(false)
    4643    , m_syntheticBold(bold)
    4744    , m_syntheticOblique(oblique)
  • trunk/Source/WebCore/platform/graphics/win/FontWin.cpp

    r204400 r206597  
    11/*
    2  * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006-2008, 2016 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
Note: See TracChangeset for help on using the changeset viewer.