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

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: review comments Created 6 years, 2 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 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 SVGPatternElement;
42 AffineTransform transform; 38 struct PatternData;
43 };
44 39
45 class RenderSVGResourcePattern final : public RenderSVGResourceContainer { 40 class RenderSVGResourcePattern final : public RenderSVGResourceContainer {
46 public: 41 public:
47 explicit RenderSVGResourcePattern(SVGPatternElement*); 42 explicit RenderSVGResourcePattern(SVGPatternElement*);
48 43
49 virtual const char* renderName() const override { return "RenderSVGResourceP attern"; } 44 virtual const char* renderName() const override { return "RenderSVGResourceP attern"; }
50 45
51 virtual void removeAllClientsFromCache(bool markForInvalidation = true) over ride; 46 virtual void removeAllClientsFromCache(bool markForInvalidation = true) over ride;
52 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) override; 47 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) override;
53 48
54 virtual SVGPaintServer preparePaintServer(const RenderObject&) override; 49 virtual SVGPaintServer preparePaintServer(const RenderObject&) override;
55 50
56 virtual RenderSVGResourceType resourceType() const override { return s_resou rceType; } 51 virtual RenderSVGResourceType resourceType() const override { return s_resou rceType; }
57 static const RenderSVGResourceType s_resourceType; 52 static const RenderSVGResourceType s_resourceType;
58 53
59 private: 54 private:
60 bool buildTileImageTransform(const RenderObject&, const PatternAttributes&, const SVGPatternElement*, FloatRect& patternBoundaries, AffineTransform& tileIma geTransform) const; 55 PassOwnPtr<PatternData> buildPatternData(const RenderObject&);
61 56 PassRefPtr<DisplayList> asDisplayList(const FloatRect& tileBounds, const Aff ineTransform&) const;
62 PassOwnPtr<ImageBuffer> createTileImage(const PatternAttributes&, const Floa tRect& tileBoundaries, 57 PatternData* patternForRenderer(const RenderObject&);
63 const FloatRect& absoluteTileBoundar ies, const AffineTransform& tileImageTransform) const;
64
65 PatternData* buildPattern(const RenderObject&, const SVGPatternElement*);
66 58
67 bool m_shouldCollectPatternAttributes : 1; 59 bool m_shouldCollectPatternAttributes : 1;
68 PatternAttributes m_attributes; 60 PatternAttributes m_attributes;
61
62 // FIXME: we can almost do away with this per-object map, but not quite: the tile size can be
63 // relative to the client bounding box, and it gets captured in the cached P attern shader.
64 // Hence, we need one Pattern shader per client. The display list OTOH is th e same => we
65 // should be able to cache a single display list per RenderSVGResourcePatter n + one
66 // Pattern(shader) for each client -- this would avoid re-recording when mul tiple clients
67 // share the same pattern.
69 HashMap<const RenderObject*, OwnPtr<PatternData> > m_patternMap; 68 HashMap<const RenderObject*, OwnPtr<PatternData> > m_patternMap;
70 }; 69 };
71 70
72 } 71 }
73 72
74 #endif 73 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698