Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 4 * Copyright 2014 The Chromium Authors. All rights reserved. | |
| 4 * | 5 * |
| 5 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 9 * | 10 * |
| 10 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 14 * | 15 * |
| 15 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 19 */ | 20 */ |
| 20 | 21 |
| 21 #ifndef RenderSVGResourcePattern_h | 22 #ifndef RenderSVGResourcePattern_h |
| 22 #define RenderSVGResourcePattern_h | 23 #define RenderSVGResourcePattern_h |
| 23 | 24 |
| 24 #include "core/rendering/svg/RenderSVGResourceContainer.h" | 25 #include "core/rendering/svg/RenderSVGResourceContainer.h" |
| 25 #include "core/svg/PatternAttributes.h" | 26 #include "core/svg/PatternAttributes.h" |
| 26 #include "core/svg/SVGPatternElement.h" | |
| 27 #include "core/svg/SVGUnitTypes.h" | |
| 28 #include "platform/geometry/FloatRect.h" | |
| 29 #include "platform/graphics/ImageBuffer.h" | |
| 30 #include "platform/graphics/Pattern.h" | |
| 31 #include "platform/transforms/AffineTransform.h" | |
| 32 | 27 |
| 33 #include "wtf/HashMap.h" | 28 #include "wtf/HashMap.h" |
| 34 #include "wtf/OwnPtr.h" | 29 #include "wtf/OwnPtr.h" |
| 30 #include "wtf/RefPtr.h" | |
| 35 | 31 |
| 36 namespace blink { | 32 namespace blink { |
| 37 | 33 |
| 38 struct PatternData { | 34 class AffineTransform; |
| 39 WTF_MAKE_FAST_ALLOCATED; | 35 class DisplayList; |
| 40 public: | 36 class FloatRect; |
| 41 RefPtr<Pattern> pattern; | 37 class GraphicsContext; |
|
fs
2014/10/21 20:12:35
Nit: Not used in the header AFAICS
f(malita)
2014/10/21 22:16:33
Done.
| |
| 42 AffineTransform transform; | 38 class SVGPatternElement; |
| 43 }; | 39 struct PatternData; |
| 44 | 40 |
| 45 class RenderSVGResourcePattern final : public RenderSVGResourceContainer { | 41 class RenderSVGResourcePattern final : public RenderSVGResourceContainer { |
| 46 public: | 42 public: |
| 47 explicit RenderSVGResourcePattern(SVGPatternElement*); | 43 explicit RenderSVGResourcePattern(SVGPatternElement*); |
| 48 | 44 |
| 49 virtual const char* renderName() const override { return "RenderSVGResourceP attern"; } | 45 virtual const char* renderName() const override { return "RenderSVGResourceP attern"; } |
| 50 | 46 |
| 51 virtual void removeAllClientsFromCache(bool markForInvalidation = true) over ride; | 47 virtual void removeAllClientsFromCache(bool markForInvalidation = true) over ride; |
| 52 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) override; | 48 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) override; |
| 53 | 49 |
| 54 virtual SVGPaintServer preparePaintServer(const RenderObject&) override; | 50 virtual SVGPaintServer preparePaintServer(const RenderObject&) override; |
| 55 | 51 |
| 56 virtual RenderSVGResourceType resourceType() const override { return s_resou rceType; } | 52 virtual RenderSVGResourceType resourceType() const override { return s_resou rceType; } |
| 57 static const RenderSVGResourceType s_resourceType; | 53 static const RenderSVGResourceType s_resourceType; |
| 58 | 54 |
| 59 private: | 55 private: |
| 60 bool buildTileImageTransform(const RenderObject&, const PatternAttributes&, const SVGPatternElement*, FloatRect& patternBoundaries, AffineTransform& tileIma geTransform) const; | 56 PassOwnPtr<PatternData> buildPatternData(const RenderObject&); |
| 61 | 57 PassRefPtr<DisplayList> asDisplayList(const FloatRect& tileBounds, const Aff ineTransform&) const; |
| 62 PassOwnPtr<ImageBuffer> createTileImage(const PatternAttributes&, const Floa tRect& tileBoundaries, | 58 PatternData* patternForRenderer(const RenderObject&); |
| 63 const FloatRect& absoluteTileBoundar ies, const AffineTransform& tileImageTransform) const; | |
| 64 | |
| 65 PatternData* buildPattern(const RenderObject&, const SVGPatternElement*); | |
| 66 | 59 |
| 67 bool m_shouldCollectPatternAttributes : 1; | 60 bool m_shouldCollectPatternAttributes : 1; |
| 68 PatternAttributes m_attributes; | 61 PatternAttributes m_attributes; |
| 62 | |
| 63 // FIXME: we can almost do away with this per-object map, but not quite: the tile size can be | |
|
fs
2014/10/21 20:12:35
I think viewBox might might throw a larger spanner
f(malita)
2014/10/21 22:16:33
Acknowledged.
| |
| 64 // relative to the client bounding box, and it gets captured in the cached P attern shader. | |
| 65 // Hence, we need one Pattern shader per client. The display list OTOH is th e same => we | |
| 66 // should be able to cache a single display list per RenderSVGResourcePatter n + one | |
| 67 // Pattern(shader) for each client -- this would avoid re-recording when mul tiple clients | |
| 68 // share the same pattern. | |
| 69 HashMap<const RenderObject*, OwnPtr<PatternData> > m_patternMap; | 69 HashMap<const RenderObject*, OwnPtr<PatternData> > m_patternMap; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 } | 72 } |
| 73 | 73 |
| 74 #endif | 74 #endif |
| OLD | NEW |