| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 CC_LAYER_TREE_HOST_COMMON_H_ | 5 #ifndef CC_LAYER_TREE_HOST_COMMON_H_ |
| 6 #define CC_LAYER_TREE_HOST_COMMON_H_ | 6 #define CC_LAYER_TREE_HOST_COMMON_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "cc/cc_export.h" | 9 #include "cc/cc_export.h" |
| 10 #include "cc/scoped_ptr_vector.h" | 10 #include "cc/scoped_ptr_vector.h" |
| 11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
| 12 #include "ui/gfx/transform.h" | 12 #include "ui/gfx/transform.h" |
| 13 #include "ui/gfx/vector2d.h" | 13 #include "ui/gfx/vector2d.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 | 16 |
| 17 class LayerImpl; | 17 class LayerImpl; |
| 18 class Layer; | 18 class Layer; |
| 19 | 19 |
| 20 class CC_EXPORT LayerTreeHostCommon { | 20 class CC_EXPORT LayerTreeHostCommon { |
| 21 public: | 21 public: |
| 22 static gfx::Rect calculateVisibleRect(const gfx::Rect& targetSurfaceRect, co
nst gfx::Rect& layerBoundRect, const gfx::Transform&); | 22 static gfx::Rect calculateVisibleRect(const gfx::Rect& targetSurfaceRect, co
nst gfx::Rect& layerBoundRect, const gfx::Transform&); |
| 23 | 23 |
| 24 static void calculateDrawProperties(Layer* rootLayer, const gfx::Size& devic
eViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSiz
e, bool canUseLCDText, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerLis
t); | 24 static void calculateDrawProperties(Layer* rootLayer, const gfx::Size& devic
eViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSiz
e, bool canUseLCDText, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerLis
t); |
| 25 static void calculateDrawProperties(LayerImpl* rootLayer, const gfx::Size& d
eviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextur
eSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayerList); | 25 static void calculateDrawProperties(LayerImpl* rootLayer, const gfx::Size& d
eviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextur
eSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayerList, bool
updateTilePriorities); |
| 26 | 26 |
| 27 // Performs hit testing for a given renderSurfaceLayerList. | 27 // Performs hit testing for a given renderSurfaceLayerList. |
| 28 static LayerImpl* findLayerThatIsHitByPoint(const gfx::PointF& screenSpacePo
int, const std::vector<LayerImpl*>& renderSurfaceLayerList); | 28 static LayerImpl* findLayerThatIsHitByPoint(const gfx::PointF& screenSpacePo
int, const std::vector<LayerImpl*>& renderSurfaceLayerList); |
| 29 | 29 |
| 30 static LayerImpl* findLayerThatIsHitByPointInTouchHandlerRegion(const gfx::P
ointF& screenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList); | 30 static LayerImpl* findLayerThatIsHitByPointInTouchHandlerRegion(const gfx::P
ointF& screenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList); |
| 31 | 31 |
| 32 static bool layerHasTouchEventHandlersAt(const gfx::PointF& screenSpacePoint
, LayerImpl* layerImpl); | 32 static bool layerHasTouchEventHandlersAt(const gfx::PointF& screenSpacePoint
, LayerImpl* layerImpl); |
| 33 | 33 |
| 34 template<typename LayerType> static bool renderSurfaceContributesToTarget(La
yerType*, int targetSurfaceLayerID); | 34 template<typename LayerType> static bool renderSurfaceContributesToTarget(La
yerType*, int targetSurfaceLayerID); |
| 35 | 35 |
| 36 template<class Function, typename LayerType> static void callFunctionForSubt
ree(LayerType* rootLayer); |
| 37 |
| 36 // Returns a layer with the given id if one exists in the subtree starting | 38 // Returns a layer with the given id if one exists in the subtree starting |
| 37 // from the given root layer (including mask and replica layers). | 39 // from the given root layer (including mask and replica layers). |
| 38 template<typename LayerType> static LayerType* findLayerInSubtree(LayerType*
rootLayer, int layerId); | 40 template<typename LayerType> static LayerType* findLayerInSubtree(LayerType*
rootLayer, int layerId); |
| 39 | 41 |
| 40 static Layer* getChildAsRawPtr(const std::vector<scoped_refptr<Layer> >& chi
ldren, size_t index) | 42 static Layer* getChildAsRawPtr(const std::vector<scoped_refptr<Layer> >& chi
ldren, size_t index) |
| 41 { | 43 { |
| 42 return children[index].get(); | 44 return children[index].get(); |
| 43 } | 45 } |
| 44 | 46 |
| 45 static LayerImpl* getChildAsRawPtr(const ScopedPtrVector<LayerImpl>& childre
n, size_t index) | 47 static LayerImpl* getChildAsRawPtr(const ScopedPtrVector<LayerImpl>& childre
n, size_t index) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 if (rootLayer->replicaLayer() && rootLayer->replicaLayer()->id() == layerId) | 89 if (rootLayer->replicaLayer() && rootLayer->replicaLayer()->id() == layerId) |
| 88 return rootLayer->replicaLayer(); | 90 return rootLayer->replicaLayer(); |
| 89 | 91 |
| 90 for (size_t i = 0; i < rootLayer->children().size(); ++i) { | 92 for (size_t i = 0; i < rootLayer->children().size(); ++i) { |
| 91 if (LayerType* found = findLayerInSubtree(getChildAsRawPtr(rootLayer->ch
ildren(), i), layerId)) | 93 if (LayerType* found = findLayerInSubtree(getChildAsRawPtr(rootLayer->ch
ildren(), i), layerId)) |
| 92 return found; | 94 return found; |
| 93 } | 95 } |
| 94 return 0; | 96 return 0; |
| 95 } | 97 } |
| 96 | 98 |
| 99 template<class Function, typename LayerType> |
| 100 void LayerTreeHostCommon::callFunctionForSubtree(LayerType* rootLayer) |
| 101 { |
| 102 Function()(rootLayer); |
| 103 |
| 104 if (rootLayer->maskLayer()) |
| 105 Function()(rootLayer->maskLayer()); |
| 106 if (rootLayer->replicaLayer()) |
| 107 Function()(rootLayer->replicaLayer()); |
| 108 |
| 109 for (size_t i = 0; i < rootLayer->children().size(); ++i) |
| 110 callFunctionForSubtree<Function>(getChildAsRawPtr(rootLayer->children(),
i)); |
| 111 } |
| 112 |
| 97 } // namespace cc | 113 } // namespace cc |
| 98 | 114 |
| 99 #endif // CC_LAYER_TREE_HOST_COMMON_H_ | 115 #endif // CC_LAYER_TREE_HOST_COMMON_H_ |
| OLD | NEW |