Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ObjectPaintProperties_h | 5 #ifndef ObjectPaintProperties_h |
| 6 #define ObjectPaintProperties_h | 6 #define ObjectPaintProperties_h |
| 7 | 7 |
| 8 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 8 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 9 #include "wtf/HashMap.h" | |
| 10 #include "wtf/OwnPtr.h" | |
| 11 #include "wtf/PassOwnPtr.h" | |
| 9 #include "wtf/PassRefPtr.h" | 12 #include "wtf/PassRefPtr.h" |
| 10 #include "wtf/RefPtr.h" | 13 #include "wtf/RefPtr.h" |
| 11 | 14 |
| 12 namespace blink { | 15 namespace blink { |
| 13 | 16 |
| 14 // The minimal set of paint properties created by a |LayoutObject|. These | 17 // The minimal set of paint properties created by a |LayoutObject|. These |
| 15 // properties encode a hierachy of transforms, clips, effects, etc, both between | 18 // properties encode a hierachy of transforms, clips, effects, etc, both between |
| 16 // LayoutObjects (each property has a parent) and among the properties of a | 19 // LayoutObjects (each property has a parent) and among the properties of a |
| 17 // single LayoutObject (e.g., transform and perspective with the correct parent | 20 // single LayoutObject (e.g., transform and perspective with the correct parent |
| 18 // relationship to represent ordering). | 21 // relationship to represent ordering). |
| 19 // | 22 // |
| 20 // This differs from |PaintChunkProperties| because it can store multiple | 23 // This differs from |PaintChunkProperties| because it can store multiple |
| 21 // properties of the same type (e.g., transform and perspective which are both | 24 // properties of the same type (e.g., transform and perspective which are both |
| 22 // transforms). | 25 // transforms). |
| 23 class ObjectPaintProperties { | 26 class ObjectPaintProperties { |
| 24 WTF_MAKE_NONCOPYABLE(ObjectPaintProperties); | 27 WTF_MAKE_NONCOPYABLE(ObjectPaintProperties); |
| 25 WTF_MAKE_FAST_ALLOCATED(ObjectPaintProperties); | 28 WTF_MAKE_FAST_ALLOCATED(ObjectPaintProperties); |
| 26 public: | 29 public: |
| 30 // This is intended to be inherited by FrameView and LayoutObject to hold ow nership to | |
| 31 // ObjectPaintProperties. Ideally we should simply use an OwnPtr but at this moment we | |
| 32 // use a global HashMap to avoid regressing non-SPv2 memory use. Thus we nee d this class | |
| 33 // to maintain RAII. | |
| 34 class Owner { | |
|
jbroman
2015/10/14 15:11:58
So this exists because we don't want to pay sizeof
pdr.
2015/10/14 17:52:06
I like your approach of putting these functions on
trchen
2015/10/14 22:51:13
This is because LayoutSVGModelObject can't have la
| |
| 35 public: | |
| 36 ObjectPaintProperties* objectPaintProperties() const; | |
| 37 ObjectPaintProperties& ensureObjectPaintProperties(); | |
| 38 void setObjectPaintProperties(PassOwnPtr<ObjectPaintProperties>); | |
|
jbroman
2015/10/14 15:11:58
It looks like this is only used for clearing. If s
trchen
2015/10/14 22:51:13
Makes sense. Done.
| |
| 39 protected: | |
| 40 ~Owner(); | |
| 41 private: | |
| 42 typedef HashMap<const ObjectPaintProperties::Owner*, OwnPtr<ObjectPaintP roperties>> NodeMapping; | |
|
pdr.
2015/10/14 17:52:06
For now, I think we can increase the size of Paint
trchen
2015/10/14 22:51:13
See explanation above.
| |
| 43 static NodeMapping* s_nodeMapping; | |
| 44 }; | |
| 45 | |
| 27 static PassOwnPtr<ObjectPaintProperties> create() | 46 static PassOwnPtr<ObjectPaintProperties> create() |
| 28 { | 47 { |
| 29 return adoptPtr(new ObjectPaintProperties()); | 48 return adoptPtr(new ObjectPaintProperties()); |
| 30 } | 49 } |
| 31 | 50 |
| 32 bool hasTransform() const { return m_transform; } | 51 void setTransformNodeForSelf(PassRefPtr<TransformPaintPropertyNode> node) { m_transformNodeForSelf = node; } |
|
jbroman
2015/10/14 15:11:58
Any reason to make this more abstract? For Depreca
pdr.
2015/10/14 17:52:06
I think the goal was to avoid leaking paint inform
trchen
2015/10/14 22:51:13
The real question is who will be using this data?
pdr.
2015/10/15 04:53:51
We're thinking in the same way wrt the subsequence
jbroman
2015/10/15 14:29:10
This class is in core/; the merge algorithm, which
trchen
2015/10/15 23:24:31
Done.
| |
| 33 void setTransform(PassRefPtr<TransformPaintPropertyNode> transform) { m_tran sform = transform; } | 52 const TransformPaintPropertyNode* transformNodeForSelf() const { return m_tr ansformNodeForSelf.get(); } |
| 34 const TransformPaintPropertyNode* transform() const { return m_transform.get (); } | |
| 35 | 53 |
| 36 bool hasPerspective() const { return m_perspective; } | 54 void setTransformNodeForDescendants(PassRefPtr<TransformPaintPropertyNode> n ode) { m_transformNodeForDescendants = node; } |
| 37 void setPerspective(PassRefPtr<TransformPaintPropertyNode> perspective) { m_ perspective = perspective; } | 55 const TransformPaintPropertyNode* transformNodeForDescendants() const { retu rn m_transformNodeForDescendants.get(); } |
| 38 const TransformPaintPropertyNode* perspective() const { return m_perspective .get(); } | |
| 39 | 56 |
| 40 private: | 57 private: |
| 41 ObjectPaintProperties() { } | 58 ObjectPaintProperties() { } |
| 42 | 59 |
| 43 RefPtr<TransformPaintPropertyNode> m_transform; | 60 RefPtr<TransformPaintPropertyNode> m_transformNodeForSelf; |
| 44 RefPtr<TransformPaintPropertyNode> m_perspective; | 61 RefPtr<TransformPaintPropertyNode> m_transformNodeForDescendants; |
| 45 }; | 62 }; |
| 46 | 63 |
| 47 } // namespace blink | 64 } // namespace blink |
| 48 | 65 |
| 49 #endif // ObjectPaintProperties_h | 66 #endif // ObjectPaintProperties_h |
| OLD | NEW |