Changeset 21415 in webkit


Ignore:
Timestamp:
May 11, 2007 1:27:19 PM (17 years ago)
Author:
bdash
Message:

2007-05-11 Holger Hans Peter Freyther <zecke@selfish.org>

Reviewed by Maciej.

Bug 13676: [cairo/gdk] Provide implementation for ImageBufferCairo
http://bugs.webkit.org/show_bug.cgi?id=13676

There are no test cases that explicitly cover platform/graphics at present.

  • platform/graphics/ImageBuffer.h: Add cairo bits
  • platform/graphics/cairo/ImageBufferCairo.cpp: Untested implementation of the ImagerBuffer using the image_surface (WebCore::ImageBuffer::create): Create a reasonable sized surface (WebCore::ImageBuffer::ImageBuffer): Use a cairo_surface and create a GraphicsContext. GraphicsContext takes the cairo_t ownership (WebCore::ImageBuffer::~ImageBuffer): Unref the surface (WebCore::ImageBuffer::context): simply return the GraphicsContext, it should be possible to directly draw on it.
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r21414 r21415  
     12007-05-11  Holger Hans Peter Freyther  <zecke@selfish.org>
     2
     3        Reviewed by Maciej.
     4
     5        Bug 13676: [cairo/gdk] Provide implementation for ImageBufferCairo
     6        http://bugs.webkit.org/show_bug.cgi?id=13676
     7
     8        There are no test cases that explicitly cover platform/graphics at present.
     9
     10        * platform/graphics/ImageBuffer.h: Add cairo bits
     11        * platform/graphics/cairo/ImageBufferCairo.cpp: Untested implementation of the ImagerBuffer using the image_surface
     12        (WebCore::ImageBuffer::create): Create a reasonable sized surface
     13        (WebCore::ImageBuffer::ImageBuffer): Use a cairo_surface and create a GraphicsContext. GraphicsContext takes the cairo_t ownership
     14        (WebCore::ImageBuffer::~ImageBuffer): Unref the surface
     15        (WebCore::ImageBuffer::context): simply return the GraphicsContext, it should be possible to directly draw on it.
     16
    1172007-05-11  Mitz Pettel  <mitz@webkit.org>
    218
  • trunk/WebCore/platform/graphics/ImageBuffer.h

    r19290 r21415  
    4040#endif
    4141
     42#if PLATFORM(CAIRO)
     43struct _cairo_surface;
     44#endif
     45
    4246namespace WebCore {
    4347
     
    7882        mutable QPixmap m_pixmap;
    7983        mutable QPainter* m_painter;
     84#elif PLATFORM(CAIRO)
     85        ImageBuffer(_cairo_surface* surface);
     86        mutable _cairo_surface *m_surface;
    8087#endif
    8188    };
  • trunk/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp

    r21340 r21415  
    2929
    3030#include "GraphicsContext.h"
     31#include <cairo.h>
    3132
    3233#define notImplemented() do { fprintf(stderr, "FIXME: UNIMPLEMENTED %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); } while(0)
     
    3637namespace WebCore {
    3738
    38 auto_ptr<ImageBuffer> ImageBuffer::create(const IntSize& size, bool grayScale)
     39auto_ptr<ImageBuffer> ImageBuffer::create(const IntSize& size, bool)
    3940{
    40     return auto_ptr<ImageBuffer>();
     41    cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
     42                                                          size.width(), size.height());
     43    if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS)
     44        return auto_ptr<ImageBuffer>();
     45
     46    return auto_ptr<ImageBuffer>(new ImageBuffer(surface));
    4147}
    4248
     49ImageBuffer::ImageBuffer(_cairo_surface* surface)
     50    : m_surface(surface)
     51{
     52    cairo_t* context = cairo_create(m_surface);
     53    m_context.set(new GraphicsContext(context));
     54
     55    /*
     56     * The context is now owned by the GraphicsContext
     57     */
     58    cairo_destroy(context);
     59}
    4360
    4461ImageBuffer::~ImageBuffer()
    4562{
     63    cairo_surface_destroy(m_surface);
    4664}
    4765
    4866GraphicsContext* ImageBuffer::context() const
    4967{
    50     return 0;
     68    return m_context.get();
    5169}
    5270
Note: See TracChangeset for help on using the changeset viewer.