Changeset 80386 in webkit


Ignore:
Timestamp:
Mar 4, 2011 4:00:40 PM (13 years ago)
Author:
jamesr@google.com
Message:

2011-03-04 Mike Reed <reed@google.com>

Reviewed by James Robinson.

Option to use skia's native text drawing APIs when drawing text
on Windows, rather than from outlines using drawPath(). This will
only have a significant effect when the skia-gpu backend is enabled.
https://bugs.webkit.org/show_bug.cgi?id=55609

No new tests. This is disabled by default. When enabled, it will draw
essentially the same, but with slightly different antialiased edges, due
to differences between the current scanconverter and GDI's font scaler.
When enabled, we will have to recalibrate layouttest image results.

  • platform/graphics/skia/SkiaFontWin.cpp: (WebCore::skiaDrawText): (WebCore::setupPaintForFont): (WebCore::paintSkiaText):
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r80384 r80386  
     12011-03-04  Mike Reed  <reed@google.com>
     2
     3        Reviewed by James Robinson.
     4
     5        Option to use skia's native text drawing APIs when drawing text
     6        on Windows, rather than from outlines using drawPath(). This will
     7        only have a significant effect when the skia-gpu backend is enabled.
     8        https://bugs.webkit.org/show_bug.cgi?id=55609
     9
     10        No new tests. This is disabled by default. When enabled, it will draw
     11        essentially the same, but with slightly different antialiased edges, due
     12        to differences between the current scanconverter and GDI's font scaler.
     13        When enabled, we will have to recalibrate layouttest image results.
     14
     15        * platform/graphics/skia/SkiaFontWin.cpp:
     16        (WebCore::skiaDrawText):
     17        (WebCore::setupPaintForFont):
     18        (WebCore::paintSkiaText):
     19
    1202011-03-04  Adrienne Walker  <enne@google.com>
    221
  • trunk/Source/WebCore/platform/graphics/skia/SkiaFontWin.cpp

    r74463 r80386  
    3939#include "SkPaint.h"
    4040#include "SkShader.h"
     41#include "SkTemplates.h"
     42#include "SkTypeface.h"
    4143
    4244#include <wtf/ListHashSet.h>
    4345#include <wtf/Vector.h>
     46
     47#if ENABLE(SKIA_TEXT)
     48// FIXME: a future role of skia will have this in a proper header
     49extern SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT&);
     50#endif
    4451
    4552namespace WebCore {
     
    274281                         int numGlyphs)
    275282{
     283#if ENABLE(SKIA_TEXT)
     284    SkASSERT(sizeof(WORD) == sizeof(uint16_t));
     285
     286    // Reserve space for 64 glyphs on the stack. If numGlyphs is larger, the array
     287    // will dynamically allocate it space for numGlyph glyphs.
     288    static const size_t kLocalGlyphMax = 64;
     289    SkAutoSTArray<kLocalGlyphMax, SkPoint> posStorage(numGlyphs);
     290    SkPoint* pos = posStorage.get();
     291    SkScalar x = point.fX;
     292    SkScalar y = point.fY;
     293    for (int i = 0; i < numGlyphs; i++) {
     294        pos[i].set(x + (offsets ? offsets[i].du : 0),
     295                   y + (offsets ? offsets[i].dv : 0));
     296        x += SkIntToScalar(advances[i]);
     297    }
     298    canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, *paint);
     299#else
    276300    float x = point.fX, y = point.fY;
    277301
     
    293317        x += advances[i];
    294318    }
    295 
     319#endif
    296320    return true;
    297321}
     322
     323#if ENABLE(SKIA_TEXT)
     324static void setupPaintForFont(HFONT hfont, SkPaint* paint)
     325{
     326    //  FIXME:
     327    //  Much of this logic could also happen in
     328    //  FontCustomPlatformData::fontPlatformData and be cached,
     329    //  allowing us to avoid talking to GDI at this point.
     330    //
     331    LOGFONT info;
     332    GetObject(hfont, sizeof(info), &info);
     333    int size = info.lfHeight;
     334    if (size < 0)
     335        size = -size; // We don't let GDI dpi-scale us (see SkFontHost_win.cpp).
     336    paint->setTextSize(SkIntToScalar(size));
     337
     338    SkTypeface* face = SkCreateTypefaceFromLOGFONT(info);
     339    paint->setTypeface(face);
     340    SkSafeUnref(face);
     341}
     342#endif
    298343
    299344bool paintSkiaText(GraphicsContext* context,
     
    315360    platformContext->setupPaintForFilling(&paint);
    316361    paint.setFlags(SkPaint::kAntiAlias_Flag);
     362#if ENABLE(SKIA_TEXT)
     363    paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
     364    setupPaintForFont(hfont, &paint);
     365#endif
    317366    bool didFill = false;
    318367
Note: See TracChangeset for help on using the changeset viewer.