Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #define RenderSVGResourceClipper_h | 21 #define RenderSVGResourceClipper_h |
| 22 | 22 |
| 23 #include "core/rendering/svg/RenderSVGResourceContainer.h" | 23 #include "core/rendering/svg/RenderSVGResourceContainer.h" |
| 24 #include "core/svg/SVGClipPathElement.h" | 24 #include "core/svg/SVGClipPathElement.h" |
| 25 | 25 |
| 26 namespace WebCore { | 26 namespace WebCore { |
| 27 | 27 |
| 28 struct ClipperData { | 28 struct ClipperData { |
| 29 WTF_MAKE_FAST_ALLOCATED; | 29 WTF_MAKE_FAST_ALLOCATED; |
| 30 public: | 30 public: |
| 31 OwnPtr<ImageBuffer> clipMaskImage; | 31 ClipperData() |
| 32 : pathOnly(false) | |
| 33 { | |
| 34 } | |
| 35 | |
| 36 // We should eventually cache the combined clip path here, when switching to path ops clipping. | |
| 37 // For now we only cache a marker to let postApply know whether it needs to perform any work. | |
| 38 bool pathOnly : 1; | |
|
pdr.
2013/08/28 03:32:36
Using an enum may make this easier to understand.
f(malita)
2013/08/28 19:54:38
Done.
| |
| 32 }; | 39 }; |
| 33 | 40 |
| 34 class RenderSVGResourceClipper FINAL : public RenderSVGResourceContainer { | 41 class RenderSVGResourceClipper FINAL : public RenderSVGResourceContainer { |
| 35 public: | 42 public: |
| 36 RenderSVGResourceClipper(SVGClipPathElement*); | 43 RenderSVGResourceClipper(SVGClipPathElement*); |
| 37 virtual ~RenderSVGResourceClipper(); | 44 virtual ~RenderSVGResourceClipper(); |
| 38 | 45 |
| 39 virtual const char* renderName() const { return "RenderSVGResourceClipper"; } | 46 virtual const char* renderName() const { return "RenderSVGResourceClipper"; } |
| 40 | 47 |
| 41 virtual void removeAllClientsFromCache(bool markForInvalidation = true); | 48 virtual void removeAllClientsFromCache(bool markForInvalidation = true); |
| 42 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true); | 49 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true); |
| 43 | 50 |
| 44 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, u nsigned short resourceMode); | 51 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, u nsigned short resourceMode) OVERRIDE; |
| 52 virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned sh ort, const Path*, const RenderSVGShape*) OVERRIDE; | |
| 45 // clipPath can be clipped too, but don't have a boundingBox or repaintRect. So we can't call | 53 // clipPath can be clipped too, but don't have a boundingBox or repaintRect. So we can't call |
|
pdr.
2013/08/28 03:32:36
Not your fault, but this comment is more confusing
| |
| 46 // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources | 54 // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources |
| 47 // FIXME: We made applyClippingToContext public because we cannot call apply Resource on HTML elements (it asserts on RenderObject::objectBoundingBox) | 55 // FIXME: We made applyClippingToContext public because we cannot call apply Resource on HTML elements (it asserts on RenderObject::objectBoundingBox) |
| 48 bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect &, GraphicsContext*); | 56 bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect &, GraphicsContext*); |
| 57 | |
| 49 virtual FloatRect resourceBoundingBox(RenderObject*); | 58 virtual FloatRect resourceBoundingBox(RenderObject*); |
| 50 | 59 |
| 51 virtual RenderSVGResourceType resourceType() const { return ClipperResourceT ype; } | 60 virtual RenderSVGResourceType resourceType() const { return ClipperResourceT ype; } |
| 52 | 61 |
| 53 bool hitTestClipContent(const FloatRect&, const FloatPoint&); | 62 bool hitTestClipContent(const FloatRect&, const FloatPoint&); |
| 54 | 63 |
| 55 SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElemen t(node())->clipPathUnitsCurrentValue(); } | 64 SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElemen t(node())->clipPathUnitsCurrentValue(); } |
| 56 | 65 |
| 57 static RenderSVGResourceType s_resourceType; | 66 static RenderSVGResourceType s_resourceType; |
| 58 private: | 67 private: |
| 59 bool pathOnlyClipping(GraphicsContext*, const AffineTransform&, const FloatR ect&); | 68 bool pathOnlyClipping(GraphicsContext*, const AffineTransform&, const FloatR ect&); |
| 60 bool drawContentIntoMaskImage(ClipperData*, const FloatRect& objectBoundingB ox); | 69 void drawMaskContent(GraphicsContext*, const FloatRect& targetBoundingBox); |
| 61 void calculateClipContentRepaintRect(); | 70 void calculateClipContentRepaintRect(); |
| 62 | 71 |
| 63 FloatRect m_clipBoundaries; | 72 FloatRect m_clipBoundaries; |
| 64 HashMap<RenderObject*, ClipperData*> m_clipper; | 73 HashMap<const RenderObject*, OwnPtr<ClipperData> > m_clipperMap; |
|
pdr.
2013/08/28 03:32:36
<bikeshed> m_rendererToClipperMap?
f(malita)
2013/08/28 19:54:38
Done.
| |
| 74 | |
| 75 // Reference cycle detection. | |
| 76 bool m_inClipExpansion; | |
| 65 }; | 77 }; |
| 66 | 78 |
| 67 } | 79 } |
| 68 | 80 |
| 69 #endif | 81 #endif |
| OLD | NEW |