Changeset 51322 in webkit


Ignore:
Timestamp:
Nov 23, 2009 2:36:42 PM (14 years ago)
Author:
krit@webkit.org
Message:

2009-11-23 Dirk Schulze <krit@webkit.org>

Reviewed by Oliver Hunt.

[Cairo] support blurred test-shadow
https://bugs.webkit.org/show_bug.cgi?id=31797

Support for blurred text-shadows on Cairo. This patch
reuses the code of blurred box-shadows, introduced in
bug 26102. For a full textshadow support, a filters enabled
build is needed.

  • platform/graphics/cairo/FontCairo.cpp: (WebCore::Font::drawGlyphs):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51321 r51322  
     12009-11-23  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        [Cairo] support blurred test-shadow
     6        [https://bugs.webkit.org/show_bug.cgi?id=31797]
     7
     8        Support for blurred text-shadows on Cairo. This patch
     9        reuses the code of blurred box-shadows, introduced in
     10        bug 26102. For a full textshadow support, a filters enabled
     11        build is needed.
     12
     13        * platform/graphics/cairo/FontCairo.cpp:
     14        (WebCore::Font::drawGlyphs):
     15
    1162009-11-23  Jens Alfke  <snej@chromium.org>
    217
  • trunk/WebCore/platform/graphics/cairo/FontCairo.cpp

    r50854 r51322  
    3333#include "Gradient.h"
    3434#include "GraphicsContext.h"
     35#include "ImageBuffer.h"
    3536#include "Pattern.h"
    3637#include "SimpleFontData.h"
     
    8687        cairo_set_source_rgba(cr, red, green, blue, alpha);
    8788
     89#if ENABLE(FILTERS)
     90        cairo_text_extents_t extents;
     91        cairo_scaled_font_glyph_extents(font->platformData().scaledFont(), glyphs, numGlyphs, &extents);
     92
     93        FloatRect rect(FloatPoint(), FloatSize(extents.width, extents.height));
     94        IntSize shadowBufferSize;
     95        FloatRect shadowRect;
     96        float kernelSize = 0.f;
     97        GraphicsContext::calculateShadowBufferDimensions(shadowBufferSize, shadowRect, kernelSize, rect, shadowSize, shadowBlur);
     98
     99        // Draw shadow into a new ImageBuffer
     100        OwnPtr<ImageBuffer> shadowBuffer = ImageBuffer::create(shadowBufferSize);
     101        GraphicsContext* shadowContext = shadowBuffer->context();
     102        cairo_t* shadowCr = shadowContext->platformContext();
     103
     104        cairo_translate(shadowCr, kernelSize, extents.height + kernelSize);
     105
     106        cairo_set_scaled_font(shadowCr, font->platformData().scaledFont());
     107        cairo_show_glyphs(shadowCr, glyphs, numGlyphs);
     108        if (font->syntheticBoldOffset()) {
     109            cairo_save(shadowCr);
     110            cairo_translate(shadowCr, font->syntheticBoldOffset(), 0);
     111            cairo_show_glyphs(shadowCr, glyphs, numGlyphs);
     112            cairo_restore(shadowCr);
     113        }
     114        cairo_translate(cr, 0.0, -extents.height);
     115        context->createPlatformShadow(shadowBuffer.release(), shadowColor, shadowRect, kernelSize);
     116#else
    88117        cairo_translate(cr, shadowSize.width(), shadowSize.height());
    89118        cairo_show_glyphs(cr, glyphs, numGlyphs);
     
    94123            cairo_restore(cr);
    95124        }
     125#endif
    96126
    97127        cairo_restore(cr);
Note: See TracChangeset for help on using the changeset viewer.