Changeset 26595 in webkit


Ignore:
Timestamp:
Oct 14, 2007 10:45:09 AM (16 years ago)
Author:
zimmermann
Message:

Reviewed by Eric.

Fix bad abstraction in ImageBuffer class.
While the class itself is platform-aware and thus it's location in platform/graphics
is fine, it contains the "renderSubtreeToImage" method which operates on RenderObject.

As it's SVG specific I decided to move this method into SVGRenderSupport, to avoid
implicit platform/ <-> rendering/ dependencies.

Location:
trunk/WebCore
Files:
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r26591 r26595  
     12007-10-14  Nikolas Zimmermann  <zimmermann@kde.org>
     2
     3        Reviewed by Eric.
     4
     5        Fix bad abstraction in ImageBuffer class.
     6        While the class itself is platform-aware and thus it's location in platform/graphics
     7        is fine, it contains the "renderSubtreeToImage" method which operates on RenderObject.
     8
     9        As it's SVG specific I decided to move this method into SVGRenderSupport, to avoid
     10        implicit platform/ <-> rendering/ dependencies.
     11
     12        * WebCore.pro:
     13        * WebCore.vcproj/WebCore.vcproj:
     14        * WebCore.xcodeproj/project.pbxproj:
     15        * ksvg2/svg/SVGMaskElement.cpp:
     16        (WebCore::SVGMaskElement::drawMaskerContent):
     17        * ksvg2/svg/SVGPatternElement.cpp:
     18        (WebCore::SVGPatternElement::buildPattern):
     19        * platform/graphics/ImageBuffer.cpp: Removed.
     20        * platform/graphics/ImageBuffer.h:
     21        (WebCore::ImageBuffer::size):
     22        * platform/graphics/svg/SVGImage.cpp:
     23        (WebCore::SVGImage::nativeImageForCurrentFrame):
     24        * rendering/SVGRenderSupport.cpp:
     25        (WebCore::renderSubtreeToImage):
     26        * rendering/SVGRenderSupport.h:
     27
    1282007-10-14  Peter Kasting  <zerodpx@gmail.com>
    229
  • trunk/WebCore/WebCore.pro

    r26545 r26595  
    640640    platform/graphics/GraphicsContext.cpp \
    641641    platform/graphics/GraphicsTypes.cpp \
    642     platform/graphics/ImageBuffer.cpp \
    643642    platform/graphics/Image.cpp \
    644643    platform/graphics/IntRect.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r26569 r26595  
    38673867                                <File
    38683868                                        RelativePath="..\platform\graphics\Image.h"
    3869                                         >
    3870                                 </File>
    3871                                 <File
    3872                                         RelativePath="..\platform\graphics\ImageBuffer.cpp"
    38733869                                        >
    38743870                                </File>
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r26558 r26595  
    27722772                B2310B770B1F46A200D55D87 /* CgSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = B2310B740B1F46A200D55D87 /* CgSupport.h */; };
    27732773                B2310B780B1F46A300D55D87 /* RenderPathCg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2310B750B1F46A200D55D87 /* RenderPathCg.cpp */; };
    2774                 B23BCCE50B3829C9005B2415 /* ImageBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B23BCCE40B3829C9005B2415 /* ImageBuffer.cpp */; };
    27752774                B24055650B5BE640002A28C0 /* DOMSVGElementInstanceInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = B24055630B5BE640002A28C0 /* DOMSVGElementInstanceInternal.h */; };
    27762775                B24055660B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = B24055640B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h */; };
     
    64766475                B2310B740B1F46A200D55D87 /* CgSupport.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CgSupport.h; sourceTree = "<group>"; };
    64776476                B2310B750B1F46A200D55D87 /* RenderPathCg.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderPathCg.cpp; sourceTree = "<group>"; };
    6478                 B23BCCE40B3829C9005B2415 /* ImageBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBuffer.cpp; sourceTree = "<group>"; };
    64796477                B24055630B5BE640002A28C0 /* DOMSVGElementInstanceInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGElementInstanceInternal.h; sourceTree = "<group>"; };
    64806478                B24055640B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGElementInstanceListInternal.h; sourceTree = "<group>"; };
     
    1037310371                                B27535410B053814002CE64F /* Image.cpp */,
    1037410372                                B27535420B053814002CE64F /* Image.h */,
    10375                                 B23BCCE40B3829C9005B2415 /* ImageBuffer.cpp */,
    1037610373                                B2A10B910B3818BD00099AA4 /* ImageBuffer.h */,
    1037710374                                BC7F44A70B9E324E00A9D081 /* ImageObserver.h */,
     
    1452914526                                E12EDBEA0B308E0B002704B6 /* EventTarget.cpp in Sources */,
    1453014527                                B2A10B940B3818D700099AA4 /* ImageBufferCG.cpp in Sources */,
    14531                                 B23BCCE50B3829C9005B2415 /* ImageBuffer.cpp in Sources */,
    1453214528                                B2C96D8D0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp in Sources */,
    1453314529                                B297BC700B3C14CF0045A590 /* JSSVGPathSegListCustom.cpp in Sources */,
  • trunk/WebCore/ksvg2/svg/SVGMaskElement.cpp

    r26497 r26595  
    3333#include "SVGLength.h"
    3434#include "SVGNames.h"
     35#include "SVGRenderSupport.h"
    3536#include "SVGUnitTypes.h"
    3637#include <math.h>
     
    159160            continue;
    160161
    161         ImageBuffer::renderSubtreeToImage(maskImage.get(), item);
     162        renderSubtreeToImage(maskImage.get(), item);
    162163    }
    163164
  • trunk/WebCore/ksvg2/svg/SVGPatternElement.cpp

    r26497 r26595  
    3636#include "SVGNames.h"
    3737#include "SVGPaintServerPattern.h"
     38#include "SVGRenderSupport.h"
    3839#include "SVGStyledTransformableElement.h"
    3940#include "SVGSVGElement.h"
     
    226227            continue;
    227228
    228         ImageBuffer::renderSubtreeToImage(patternImage.get(), item);
     229        renderSubtreeToImage(patternImage.get(), item);
    229230    }
    230231
  • trunk/WebCore/platform/graphics/ImageBuffer.h

    r21974 r26595  
    5555        ~ImageBuffer();
    5656
    57         IntSize size() const;
     57        IntSize size() const { return m_size; }
    5858        GraphicsContext* context() const;
    59 
    60         // This offers a way to render parts of a WebKit rendering tree into this ImageBuffer class.
    61         // FIXME: This doesn't belong in the platform directory.
    62         // Bad layering that this knows about the render tree.
    63         // We need to move it into RenderObject or somewhere in the SVG world.
    64         static void renderSubtreeToImage(ImageBuffer*, RenderObject*);
    6559
    6660#if PLATFORM(CG)
  • trunk/WebCore/platform/graphics/svg/SVGImage.cpp

    r26494 r26595  
    4242#include "SVGImage.h"
    4343#include "SVGLength.h"
     44#include "SVGRenderSupport.h"
    4445#include "SVGSVGElement.h"
    4546
     
    117118        if (!m_frameCache) // failed to allocate image
    118119            return 0;
    119         ImageBuffer::renderSubtreeToImage(m_frameCache.get(), m_frame->renderer());
     120        renderSubtreeToImage(m_frameCache.get(), m_frame->renderer());
    120121    }
    121122#if PLATFORM(CG)
  • trunk/WebCore/rendering/SVGRenderSupport.cpp

    r26531 r26595  
    2626
    2727#if ENABLE(SVG)
    28 
    2928#include "SVGRenderSupport.h"
    3029
    3130#include "AffineTransform.h"
     31#include "ImageBuffer.h"
    3232#include "RenderObject.h"
     33#include "RenderSVGContainer.h"
    3334#include "SVGResourceClipper.h"
    3435#include "SVGResourceFilter.h"
     
    122123}
    123124
     125void renderSubtreeToImage(ImageBuffer* image, RenderObject* item)
     126{
     127    ASSERT(item);
     128    ASSERT(image);
     129    ASSERT(image->context());
     130    RenderObject::PaintInfo info(image->context(), IntRect(), PaintPhaseForeground, 0, 0, 0);
     131
     132    RenderSVGContainer* svgContainer = 0;
     133    if (item && item->isSVGContainer())
     134        svgContainer = static_cast<RenderSVGContainer*>(item);
     135
     136    bool drawsContents = svgContainer ? svgContainer->drawsContents() : false;
     137    if (svgContainer && !drawsContents)
     138        svgContainer->setDrawsContents(true);
     139
     140    item->paint(info, 0, 0);
     141
     142    if (svgContainer && !drawsContents)
     143        svgContainer->setDrawsContents(false);
     144}
     145
    124146} // namespace WebCore
    125147
  • trunk/WebCore/rendering/SVGRenderSupport.h

    r26446 r26595  
    2424
    2525#if ENABLE(SVG)
    26 
    2726#include "RenderObject.h"
    2827
     
    3332void finishRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, const FloatRect& boundingBox, SVGResourceFilter*&, GraphicsContext* savedContext);
    3433
     34// This offers a way to render parts of a WebKit rendering tree into a ImageBuffer.
     35class ImageBuffer;
     36void renderSubtreeToImage(ImageBuffer*, RenderObject*);
     37
    3538}
    3639
Note: See TracChangeset for help on using the changeset viewer.