| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (C) 2007 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007 Rob Buis <buis@kde.org> |
| 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
| 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2009 Google, Inc. All rights reserved. | 5 * Copyright (C) 2009 Google, Inc. All rights reserved. |
| 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 7 * Copyright (C) 2012 Zoltan Herczeg <zherczeg@webkit.org>. | 7 * Copyright (C) 2012 Zoltan Herczeg <zherczeg@webkit.org>. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #define SVGRenderingContext_h | 26 #define SVGRenderingContext_h |
| 27 | 27 |
| 28 #include "core/platform/graphics/ImageBuffer.h" | 28 #include "core/platform/graphics/ImageBuffer.h" |
| 29 #include "core/rendering/PaintInfo.h" | 29 #include "core/rendering/PaintInfo.h" |
| 30 | 30 |
| 31 namespace WebCore { | 31 namespace WebCore { |
| 32 | 32 |
| 33 class AffineTransform; | 33 class AffineTransform; |
| 34 class RenderObject; | 34 class RenderObject; |
| 35 class FloatRect; | 35 class FloatRect; |
| 36 class RenderSVGResourceClipper; |
| 36 class RenderSVGResourceFilter; | 37 class RenderSVGResourceFilter; |
| 38 class RenderSVGResourceMasker; |
| 37 | 39 |
| 38 // SVGRenderingContext | 40 // SVGRenderingContext |
| 39 class SVGRenderingContext { | 41 class SVGRenderingContext { |
| 40 public: | 42 public: |
| 41 enum NeedsGraphicsContextSave { | 43 enum NeedsGraphicsContextSave { |
| 42 SaveGraphicsContext, | 44 SaveGraphicsContext, |
| 43 DontSaveGraphicsContext, | 45 DontSaveGraphicsContext, |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 // Does not start rendering. | 48 // Does not start rendering. |
| 47 SVGRenderingContext() | 49 SVGRenderingContext() |
| 48 : m_renderingFlags(0) | 50 : m_renderingFlags(0) |
| 49 , m_object(0) | 51 , m_object(0) |
| 50 , m_paintInfo(0) | 52 , m_paintInfo(0) |
| 51 , m_savedContext(0) | 53 , m_savedContext(0) |
| 52 , m_filter(0) | 54 , m_filter(0) |
| 55 , m_clipper(0) |
| 56 , m_masker(0) |
| 53 { | 57 { |
| 54 } | 58 } |
| 55 | 59 |
| 56 SVGRenderingContext(RenderObject* object, PaintInfo& paintinfo, NeedsGraphic
sContextSave needsGraphicsContextSave = DontSaveGraphicsContext) | 60 SVGRenderingContext(RenderObject* object, PaintInfo& paintinfo, NeedsGraphic
sContextSave needsGraphicsContextSave = DontSaveGraphicsContext) |
| 57 : m_renderingFlags(0) | 61 : m_renderingFlags(0) |
| 58 , m_object(0) | 62 , m_object(0) |
| 59 , m_paintInfo(0) | 63 , m_paintInfo(0) |
| 60 , m_savedContext(0) | 64 , m_savedContext(0) |
| 61 , m_filter(0) | 65 , m_filter(0) |
| 66 , m_clipper(0) |
| 67 , m_masker(0) |
| 62 { | 68 { |
| 63 prepareToRenderSVGContent(object, paintinfo, needsGraphicsContextSave); | 69 prepareToRenderSVGContent(object, paintinfo, needsGraphicsContextSave); |
| 64 } | 70 } |
| 65 | 71 |
| 66 // Automatically finishes context rendering. | 72 // Automatically finishes context rendering. |
| 67 ~SVGRenderingContext(); | 73 ~SVGRenderingContext(); |
| 68 | 74 |
| 69 // Used by all SVG renderers who apply clip/filter/etc. resources to the ren
derer content. | 75 // Used by all SVG renderers who apply clip/filter/etc. resources to the ren
derer content. |
| 70 void prepareToRenderSVGContent(RenderObject*, PaintInfo&, NeedsGraphicsConte
xtSave = DontSaveGraphicsContext); | 76 void prepareToRenderSVGContent(RenderObject*, PaintInfo&, NeedsGraphicsConte
xtSave = DontSaveGraphicsContext); |
| 71 bool isRenderingPrepared() const { return m_renderingFlags & RenderingPrepar
ed; } | 77 bool isRenderingPrepared() const { return m_renderingFlags & RenderingPrepar
ed; } |
| 72 | 78 |
| 73 static bool createImageBuffer(const FloatRect& paintRect, const AffineTransf
orm& absoluteTransform, OwnPtr<ImageBuffer>&, RenderingMode); | 79 static bool createImageBuffer(const FloatRect& paintRect, const AffineTransf
orm& absoluteTransform, OwnPtr<ImageBuffer>&, RenderingMode); |
| 74 // Patterns need a different float-to-integer coordinate mapping. | 80 // Patterns need a different float-to-integer coordinate mapping. |
| 75 static bool createImageBufferForPattern(const FloatRect& absoluteTargetRect,
const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&, RenderingMode
); | 81 static bool createImageBufferForPattern(const FloatRect& absoluteTargetRect,
const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&, RenderingMode
); |
| 76 | 82 |
| 77 static void renderSubtreeToImageBuffer(ImageBuffer*, RenderObject*, const Af
fineTransform&); | 83 static void renderSubtree(GraphicsContext*, RenderObject*, const AffineTrans
form&); |
| 78 static void clipToImageBuffer(GraphicsContext*, const AffineTransform& absol
uteTransform, const FloatRect& targetRect, OwnPtr<ImageBuffer>&, bool safeToClea
r); | |
| 79 | 84 |
| 80 static float calculateScreenFontSizeScalingFactor(const RenderObject*); | 85 static float calculateScreenFontSizeScalingFactor(const RenderObject*); |
| 81 static void calculateTransformationToOutermostCoordinateSystem(const RenderO
bject*, AffineTransform& absoluteTransform); | 86 static void calculateTransformationToOutermostCoordinateSystem(const RenderO
bject*, AffineTransform& absoluteTransform); |
| 82 static IntSize clampedAbsoluteSize(const IntSize&); | 87 static IntSize clampedAbsoluteSize(const IntSize&); |
| 83 static FloatRect clampedAbsoluteTargetRect(const FloatRect& absoluteTargetRe
ct); | 88 static FloatRect clampedAbsoluteTargetRect(const FloatRect& absoluteTargetRe
ct); |
| 84 static void clear2DRotation(AffineTransform&); | 89 static void clear2DRotation(AffineTransform&); |
| 85 | 90 |
| 86 static IntRect calculateImageBufferRect(const FloatRect& targetRect, const A
ffineTransform& absoluteTransform) | 91 static IntRect calculateImageBufferRect(const FloatRect& targetRect, const A
ffineTransform& absoluteTransform) |
| 87 { | 92 { |
| 88 return enclosingIntRect(absoluteTransform.mapRect(targetRect)); | 93 return enclosingIntRect(absoluteTransform.mapRect(targetRect)); |
| 89 } | 94 } |
| 90 | 95 |
| 91 // Support for the buffered-rendering hint. | 96 // Support for the buffered-rendering hint. |
| 92 bool bufferForeground(OwnPtr<ImageBuffer>&); | 97 bool bufferForeground(OwnPtr<ImageBuffer>&); |
| 93 | 98 |
| 94 private: | 99 private: |
| 95 // To properly revert partially successful initializtions in the destructor,
we record all successful steps. | 100 // To properly revert partially successful initializtions in the destructor,
we record all successful steps. |
| 96 enum RenderingFlags { | 101 enum RenderingFlags { |
| 97 RenderingPrepared = 1, | 102 RenderingPrepared = 1, |
| 98 RestoreGraphicsContext = 1 << 1, | 103 RestoreGraphicsContext = 1 << 1, |
| 99 EndOpacityLayer = 1 << 2, | 104 EndOpacityLayer = 1 << 2, |
| 100 EndFilterLayer = 1 << 3, | 105 PostApplyResources = 1 << 3, |
| 101 PrepareToRenderSVGContentWasCalled = 1 << 4 | 106 PrepareToRenderSVGContentWasCalled = 1 << 4 |
| 102 }; | 107 }; |
| 103 | 108 |
| 104 // List of those flags which require actions during the destructor. | 109 // List of those flags which require actions during the destructor. |
| 105 const static int ActionsNeeded = RestoreGraphicsContext | EndOpacityLayer |
EndFilterLayer; | 110 const static int ActionsNeeded = RestoreGraphicsContext | EndOpacityLayer |
PostApplyResources; |
| 106 | 111 |
| 107 int m_renderingFlags; | 112 int m_renderingFlags; |
| 108 RenderObject* m_object; | 113 RenderObject* m_object; |
| 109 PaintInfo* m_paintInfo; | 114 PaintInfo* m_paintInfo; |
| 110 GraphicsContext* m_savedContext; | 115 GraphicsContext* m_savedContext; |
| 111 IntRect m_savedPaintRect; | 116 IntRect m_savedPaintRect; |
| 112 RenderSVGResourceFilter* m_filter; | 117 RenderSVGResourceFilter* m_filter; |
| 118 RenderSVGResourceClipper* m_clipper; |
| 119 RenderSVGResourceMasker* m_masker; |
| 113 }; | 120 }; |
| 114 | 121 |
| 115 } // namespace WebCore | 122 } // namespace WebCore |
| 116 | 123 |
| 117 #endif // SVGRenderingContext_h | 124 #endif // SVGRenderingContext_h |
| OLD | NEW |