Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: Source/core/rendering/svg/RenderSVGResourcePattern.h

Issue 453653003: [SVG] DisplayList-based patterns. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 9 tests marked for rebaseline Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 (C) 2014 Google Inc. 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;
42 AffineTransform transform; 38 class ImageBuffer;
43 }; 39 class SVGPatternElement;
40 struct PatternData;
44 41
45 class RenderSVGResourcePattern FINAL : public RenderSVGResourceContainer { 42 class RenderSVGResourcePattern FINAL : public RenderSVGResourceContainer {
46 public: 43 public:
47 explicit RenderSVGResourcePattern(SVGPatternElement*); 44 explicit RenderSVGResourcePattern(SVGPatternElement*);
48 45
49 virtual const char* renderName() const OVERRIDE { return "RenderSVGResourceP attern"; } 46 virtual const char* renderName() const OVERRIDE { return "RenderSVGResourceP attern"; }
50 47
51 virtual void removeAllClientsFromCache(bool markForInvalidation = true) OVER RIDE; 48 virtual void removeAllClientsFromCache(bool markForInvalidation = true) OVER RIDE;
52 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) OVERRIDE; 49 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) OVERRIDE;
53 50
54 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, u nsigned short resourceMode) OVERRIDE; 51 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, u nsigned short resourceMode) OVERRIDE;
55 virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned sh ort resourceMode, const Path*, const RenderSVGShape*) OVERRIDE; 52 virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned sh ort resourceMode, const Path*, const RenderSVGShape*) OVERRIDE;
56 53
57 virtual RenderSVGResourceType resourceType() const OVERRIDE { return s_resou rceType; } 54 virtual RenderSVGResourceType resourceType() const OVERRIDE { return s_resou rceType; }
58 static const RenderSVGResourceType s_resourceType; 55 static const RenderSVGResourceType s_resourceType;
59 56
60 private: 57 private:
61 bool buildTileImageTransform(RenderObject*, const PatternAttributes&, const SVGPatternElement*, FloatRect& patternBoundaries, AffineTransform& tileImageTran sform) const; 58 bool computeTileMetrics(const RenderObject&, const SVGPatternElement&, Float Rect& bounds,
62 59 AffineTransform&) const;
63 PassOwnPtr<ImageBuffer> createTileImage(const PatternAttributes&, const Floa tRect& tileBoundaries, 60 PassOwnPtr<PatternData> buildPatternData(GraphicsContext&, RenderObject&);
64 const FloatRect& absoluteTileBoundar ies, const AffineTransform& tileImageTransform) const; 61 PassRefPtr<DisplayList> asDisplayList(GraphicsContext&, const FloatRect& til eBounds,
65 62 const AffineTransform&) const;
66 PatternData* buildPattern(RenderObject*, unsigned short resourceMode); 63 PatternData* patternForRenderer(GraphicsContext&, RenderObject&);
67 64
68 bool m_shouldCollectPatternAttributes : 1; 65 bool m_shouldCollectPatternAttributes : 1;
69 PatternAttributes m_attributes; 66 PatternAttributes m_attributes;
67
68 // FIXME: we can almost do away with this per-object map, but not quite: the tile size can be
69 // relative to the client bounding box, and it gets captured in the cached P attern shader.
70 // Hence, we need one Pattern shader per client. The display list OTOH is th e same => we
71 // should be able to cache a single display list per RenderSVGResourcePatter n + one
72 // Pattern(shader) for each client -- this would avoid re-recording when mul tiple clients
73 // share the same pattern.
70 HashMap<RenderObject*, OwnPtr<PatternData> > m_patternMap; 74 HashMap<RenderObject*, OwnPtr<PatternData> > m_patternMap;
71 }; 75 };
72 76
73 } 77 }
74 78
75 #endif 79 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698