Changeset 41279 in webkit


Ignore:
Timestamp:
Feb 27, 2009 12:20:15 AM (15 years ago)
Author:
krit@webkit.org
Message:

2009-02-26 Dirk Schulze <krit@webkit.org>

Reviewed by Oliver Hunt.

Added support for Gradients and Patterns on filled or stroked Fonts
in Cairo. I also added support for globalAlpha on FontCairo.

[CAIRO] SVG/Canvas fonts miss gradients/pattern support
https://bugs.webkit.org/show_bug.cgi?id=18617

  • html/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::drawTextInternal):
  • platform/graphics/cairo/FontCairo.cpp: (WebCore::Font::drawGlyphs):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r41274 r41279  
     12009-02-26  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Added support for Gradients and Patterns on filled or stroked Fonts
     6        in Cairo. I also added support for globalAlpha on FontCairo.
     7
     8        [CAIRO] SVG/Canvas fonts miss gradients/pattern support
     9        https://bugs.webkit.org/show_bug.cgi?id=18617
     10
     11        * html/CanvasRenderingContext2D.cpp:
     12        (WebCore::CanvasRenderingContext2D::drawTextInternal):
     13        * platform/graphics/cairo/FontCairo.cpp:
     14        (WebCore::Font::drawGlyphs):
     15
    1162009-02-26  Stephen White  <senorblanco@chromium.org>
    217
  • trunk/WebCore/html/CanvasRenderingContext2D.cpp

    r40761 r41279  
    14191419   
    14201420    CanvasStyle* drawStyle = fill ? state().m_fillStyle.get() : state().m_strokeStyle.get();
     1421#if PLATFORM(CG)
    14211422    if (drawStyle->canvasGradient() || drawStyle->canvasPattern()) {
    14221423        // FIXME: The rect is not big enough for miters on stroked text.
     
    14471448        return;
    14481449    }
     1450#endif
    14491451
    14501452    c->setTextDrawingMode(fill ? cTextFill : cTextStroke);
  • trunk/WebCore/platform/graphics/cairo/FontCairo.cpp

    r36070 r41279  
    33 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
    44 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
     5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
    56 *
    67 * Redistribution and use in source and binary forms, with or without
     
    3031
    3132#include "GlyphBuffer.h"
     33#include "Gradient.h"
    3234#include "GraphicsContext.h"
     35#include "Pattern.h"
    3336#include "SimpleFontData.h"
     37#include "TransformationMatrix.h"
    3438
    3539namespace WebCore {
     
    7983
    8084    if (context->textDrawingMode() & cTextFill) {
    81         float red, green, blue, alpha;
    82         fillColor.getRGBA(red, green, blue, alpha);
    83         cairo_set_source_rgba(cr, red, green, blue, alpha);
    84 
     85        if (context->fillGradient()) {
     86            cairo_set_source(cr, context->fillGradient()->platformGradient());
     87            if (context->getAlpha() < 1.0f) {
     88                cairo_push_group(cr);
     89                cairo_paint_with_alpha(cr, context->getAlpha());
     90                cairo_pop_group_to_source(cr);
     91            }
     92        } else if (context->fillPattern()) {
     93            TransformationMatrix affine;
     94            cairo_set_source(cr, context->fillPattern()->createPlatformPattern(affine));
     95            if (context->getAlpha() < 1.0f) {
     96                cairo_push_group(cr);
     97                cairo_paint_with_alpha(cr, context->getAlpha());
     98                cairo_pop_group_to_source(cr);
     99            }
     100        } else {
     101            float red, green, blue, alpha;
     102            fillColor.getRGBA(red, green, blue, alpha);
     103            cairo_set_source_rgba(cr, red, green, blue, alpha * context->getAlpha());
     104        }
    85105        cairo_show_glyphs(cr, glyphs, numGlyphs);
    86106    }
    87107
    88108    if (context->textDrawingMode() & cTextStroke) {
    89         Color strokeColor = context->strokeColor();
    90         float red, green, blue, alpha;
    91         strokeColor.getRGBA(red, green, blue, alpha);
    92         cairo_set_source_rgba(cr, red, green, blue, alpha);       
     109        if (context->strokeGradient()) {
     110            cairo_set_source(cr, context->strokeGradient()->platformGradient());
     111            if (context->getAlpha() < 1.0f) {
     112                cairo_push_group(cr);
     113                cairo_paint_with_alpha(cr, context->getAlpha());
     114                cairo_pop_group_to_source(cr);
     115            }
     116        } else if (context->strokePattern()) {
     117            TransformationMatrix affine;
     118            cairo_set_source(cr, context->strokePattern()->createPlatformPattern(affine));
     119            if (context->getAlpha() < 1.0f) {
     120                cairo_push_group(cr);
     121                cairo_paint_with_alpha(cr, context->getAlpha());
     122                cairo_pop_group_to_source(cr);
     123            }
     124        } else {
     125            Color strokeColor = context->strokeColor();
     126            float red, green, blue, alpha;
     127            strokeColor.getRGBA(red, green, blue, alpha);
     128            cairo_set_source_rgba(cr, red, green, blue, alpha * context->getAlpha());
     129        }
    93130        cairo_glyph_path(cr, glyphs, numGlyphs);
    94131        cairo_set_line_width(cr, context->strokeThickness());
Note: See TracChangeset for help on using the changeset viewer.