Show
Ignore:
Timestamp:
02/08/07 14:15:36 (2 years ago)
Author:
kjk
Message:

Reviewed by Adam Roben.

Linux/gdk build fixes for cairo.

  • platform/graphics/GraphicsContext.cpp:
  • platform/graphics/cairo/GraphicsContextCairo.cpp: (WebCore::GraphicsContext::GraphicsContext): (WebCore::GraphicsContext::strokeArc): (WebCore::GraphicsContext::drawFocusRing): (WebCore::GraphicsContext::setFocusRingClip): (WebCore::GraphicsContext::clearFocusRingClip): (WebCore::GraphicsContext::drawLineForMisspellingOrBadGrammar): (WebCore::GraphicsContext::origin): (WebCore::GraphicsContext::setPlatformFillColor): (WebCore::GraphicsContext::setPlatformStrokeColor): (WebCore::GraphicsContext::setPlatformStrokeThickness): (WebCore::GraphicsContext::setPlatformStrokeStyle): (WebCore::GraphicsContext::setPlatformFont): (WebCore::GraphicsContext::setURLForRect): (WebCore::GraphicsContext::addRoundedRectClip): (WebCore::GraphicsContext::addInnerRoundedRectClip): (WebCore::GraphicsContext::setShadow): (WebCore::GraphicsContext::clearShadow): (WebCore::GraphicsContext::beginTransparencyLayer): (WebCore::GraphicsContext::endTransparencyLayer): (WebCore::GraphicsContext::clearRect): (WebCore::GraphicsContext::strokeRect): (WebCore::GraphicsContext::setLineCap): (WebCore::GraphicsContext::setLineJoin): (WebCore::GraphicsContext::setMiterLimit): (WebCore::GraphicsContext::setAlpha): (WebCore::toCairoOperator): (WebCore::GraphicsContext::setCompositeOperation): (WebCore::GraphicsContext::clip): (WebCore::GraphicsContext::rotate): (WebCore::GraphicsContext::scale): (WebCore::GraphicsContext::clipOut): (WebCore::GraphicsContext::clipOutEllipseInRect): (WebCore::GraphicsContext::fillRoundedRect):
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r18579 r19508  
    3131#include "FloatRect.h" 
    3232#include "Font.h" 
     33#include "FontData.h" 
    3334#include "IntRect.h" 
    3435#include <cairo.h> 
    3536#include <math.h> 
     37#include <stdio.h> 
    3638#include <wtf/MathExtras.h> 
    37 #if WIN32 
     39#if PLATFORM(WIN) 
    3840#include <cairo-win32.h> 
     41#endif 
     42 
     43#if COMPILER(GCC) 
     44#define notImplemented() do { fprintf(stderr, "FIXME: UNIMPLEMENTED %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); } while(0) 
     45#endif 
     46 
     47#if COMPILER(MSVC) 
     48#define notImplemented() do { \ 
     49    char buf[256] = {0}; \ 
     50    _snprintf(buf, sizeof(buf), "FIXME: UNIMPLEMENTED: %s:%d\n", __FILE__, __LINE__); \ 
     51    OutputDebugStringA(buf); \ 
     52} while (0) 
    3953#endif 
    4054 
     
    7993} 
    8094 
    81 #if WIN32 
     95#if PLATFORM(WIN) 
    8296GraphicsContext::GraphicsContext(HDC dc) 
    8397    : m_common(createGraphicsContextPrivate()) 
     
    89103#endif 
    90104 
    91 #if PLATFORM(GDK) || WIN32 
    92105GraphicsContext::GraphicsContext(PlatformGraphicsContext* context) 
    93106    : m_common(createGraphicsContextPrivate()) 
     
    96109    m_data->context = cairo_reference(context); 
    97110} 
    98 #endif 
    99111 
    100112GraphicsContext::~GraphicsContext() 
     
    298310    int y = rect.y(); 
    299311    float w = (float)rect.width(); 
     312#if 0 // FIXME: unused so far 
    300313    float h = (float)rect.height(); 
    301314    float scaleFactor = h / w; 
    302315    float reverseScaleFactor = w / h; 
    303      
     316#endif 
    304317    cairo_t* context = m_data->context; 
    305318    if (strokeStyle() != NoStroke) {         
     
    378391    if (paintingDisabled()) 
    379392        return; 
     393 
    380394    int radius = (focusRingWidth() - 1) / 2; 
    381395    int offset = radius + focusRingOffset(); 
     
    400414void GraphicsContext::setFocusRingClip(const IntRect&) 
    401415{ 
     416    // hopefully a no-op. Comment in CG version says that it exists 
     417    // to work around bugs in Mac focus ring clipping 
    402418} 
    403419 
    404420void GraphicsContext::clearFocusRingClip() 
    405421{ 
     422    // hopefully a no-op. Comment in CG version says that it exists 
     423    // to work around bugs in Mac focus ring clipping 
    406424} 
    407425 
     
    418436void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint&, int width, bool grammar) 
    419437{ 
    420     // FIXME: Implement. 
     438    notImplemented(); 
    421439} 
    422440 
     
    455473    cairo_t* context = m_data->context; 
    456474    cairo_get_matrix(context, &matrix); 
    457     return IntPoint(matrix.x0, matrix.y0); 
     475    return IntPoint((int)matrix.x0, (int)matrix.y0); 
     476} 
     477 
     478void GraphicsContext::setPlatformFillColor(const Color& col) 
     479{ 
     480    // FIXME: this is probably a no-op but I'm not sure 
     481    notImplemented(); 
     482} 
     483 
     484void GraphicsContext::setPlatformStrokeColor(const Color& col) 
     485{ 
     486    // FIXME: this is probably a no-op but I'm not sure 
     487    notImplemented(); 
     488} 
     489 
     490void GraphicsContext::setPlatformStrokeThickness(float strokeThickness) 
     491{ 
     492    cairo_set_line_width(m_data->context, strokeThickness); 
     493} 
     494 
     495void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle& strokeStyle) 
     496{ 
     497    static double dashPattern[] = {5.0, 5.0}; 
     498    static double dotPattern[] = {1.0, 1.0}; 
     499 
     500    if (paintingDisabled()) 
     501        return; 
     502 
     503    switch (strokeStyle) { 
     504    case NoStroke: 
     505        // FIXME: is it the right way to emulate NoStroke? 
     506        cairo_set_line_width(m_data->context, 0); 
     507        break; 
     508    case SolidStroke: 
     509        cairo_set_dash(m_data->context, 0, 0, 0); 
     510        break; 
     511    case DottedStroke: 
     512        cairo_set_dash(m_data->context, dotPattern, 2, 0); 
     513        break; 
     514    case DashedStroke: 
     515        cairo_set_dash(m_data->context, dashPattern, 2, 0); 
     516        break; 
     517    default: 
     518        notImplemented(); 
     519        break; 
     520    } 
     521} 
     522 
     523void GraphicsContext::setPlatformFont(const Font& font) 
     524{ 
     525    if (paintingDisabled()) 
     526        return; 
     527 
     528#if PLATFORM(GDK) 
     529    // FIXME: is it the right thing to do? Also, doesn't work on Win because 
     530    // there FontData doesn't have ::setFont() 
     531    const FontData *fontData = font.primaryFont(); 
     532    fontData->setFont(m_data->context); 
     533#endif 
    458534} 
    459535 
    460536void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect) 
    461537{ 
     538    notImplemented(); 
     539} 
     540 
     541void GraphicsContext::addRoundedRectClip(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, 
     542        const IntSize& bottomLeft, const IntSize& bottomRight)  
     543{ 
     544    notImplemented();  
     545} 
     546 
     547void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)  
     548{  
     549    notImplemented();  
     550} 
     551 
     552void GraphicsContext::setShadow(IntSize const&, int, Color const&) 
     553{ 
     554    notImplemented(); 
     555} 
     556 
     557void GraphicsContext::clearShadow() 
     558{ 
     559    notImplemented(); 
     560} 
     561 
     562void GraphicsContext::beginTransparencyLayer(float) 
     563{ 
     564    notImplemented(); 
     565} 
     566 
     567void GraphicsContext::endTransparencyLayer() 
     568{ 
     569    notImplemented(); 
     570} 
     571 
     572void GraphicsContext::clearRect(const FloatRect&) 
     573{ 
     574    notImplemented(); 
     575} 
     576 
     577void GraphicsContext::strokeRect(const FloatRect&, float) 
     578{ 
     579    notImplemented(); 
     580} 
     581 
     582void GraphicsContext::setLineCap(LineCap) 
     583{ 
     584    notImplemented(); 
     585} 
     586 
     587void GraphicsContext::setLineJoin(LineJoin) 
     588{ 
     589    notImplemented(); 
     590} 
     591 
     592void GraphicsContext::setMiterLimit(float) 
     593{ 
     594    notImplemented(); 
     595} 
     596 
     597void GraphicsContext::setAlpha(float) 
     598{ 
     599    notImplemented(); 
     600} 
     601 
     602static inline cairo_operator_t toCairoOperator(CompositeOperator op) 
     603{ 
     604    switch (op) { 
     605        case CompositeClear: 
     606            return CAIRO_OPERATOR_CLEAR; 
     607        case CompositeCopy: 
     608            return CAIRO_OPERATOR_SOURCE; 
     609        case CompositeSourceOver: 
     610            return CAIRO_OPERATOR_OVER; 
     611        case CompositeSourceIn: 
     612            return CAIRO_OPERATOR_IN; 
     613        case CompositeSourceOut: 
     614            return CAIRO_OPERATOR_OUT; 
     615        case CompositeSourceAtop: 
     616            return CAIRO_OPERATOR_ATOP; 
     617        case CompositeDestinationOver: 
     618            return CAIRO_OPERATOR_DEST_OVER; 
     619        case CompositeDestinationIn: 
     620            return CAIRO_OPERATOR_DEST_IN; 
     621        case CompositeDestinationOut: 
     622            return CAIRO_OPERATOR_DEST_OUT; 
     623        case CompositeDestinationAtop: 
     624            return CAIRO_OPERATOR_DEST_ATOP; 
     625        case CompositeXOR: 
     626            return CAIRO_OPERATOR_XOR; 
     627        case CompositePlusDarker: 
     628            return CAIRO_OPERATOR_OVER; 
     629        case CompositeHighlight: 
     630            return CAIRO_OPERATOR_OVER; 
     631        case CompositePlusLighter: 
     632            return CAIRO_OPERATOR_OVER; 
     633    } 
     634 
     635    return CAIRO_OPERATOR_OVER; 
     636} 
     637 
     638void GraphicsContext::setCompositeOperation(CompositeOperator op) 
     639{ 
     640    cairo_set_operator(m_data->context, toCairoOperator(op)); 
     641} 
     642 
     643void GraphicsContext::clip(const Path&) 
     644{ 
     645    notImplemented(); 
     646} 
     647 
     648void GraphicsContext::rotate(float) 
     649{ 
     650    notImplemented(); 
     651} 
     652 
     653void GraphicsContext::scale(const FloatSize&) 
     654{ 
     655    notImplemented(); 
     656} 
     657 
     658void GraphicsContext::clipOut(const IntRect&) 
     659{ 
     660    notImplemented(); 
     661} 
     662 
     663void GraphicsContext::clipOutEllipseInRect(const IntRect&) 
     664{ 
     665    notImplemented(); 
     666} 
     667 
     668void GraphicsContext::fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&) 
     669{ 
     670    notImplemented(); 
    462671} 
    463672