Don't consider a Bluetooth adapter present until it has an address.
[chromium-blink-merge.git] / cc / CCLayerTreeHostCommon.h
blobb0c56b08113bc8ee55038cfd76ff7098dde58709
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
3 // found in the LICENSE file.
5 #ifndef CCLayerTreeHostCommon_h
6 #define CCLayerTreeHostCommon_h
8 #include "IntRect.h"
9 #include "IntSize.h"
10 #include <public/WebTransformationMatrix.h>
11 #include <wtf/RefPtr.h>
12 #include <wtf/Vector.h>
14 namespace WebCore {
16 class CCLayerImpl;
17 class CCLayerSorter;
18 class LayerChromium;
20 class CCLayerTreeHostCommon {
21 public:
22 static IntRect calculateVisibleRect(const IntRect& targetSurfaceRect, const IntRect& layerBoundRect, const WebKit::WebTransformationMatrix&);
24 static void calculateDrawTransforms(LayerChromium* rootLayer, const IntSize& deviceViewportSize, float deviceScaleFactor, int maxTextureSize, Vector<RefPtr<LayerChromium> >& renderSurfaceLayerList);
25 static void calculateDrawTransforms(CCLayerImpl* rootLayer, const IntSize& deviceViewportSize, float deviceScaleFactor, CCLayerSorter*, int maxTextureSize, Vector<CCLayerImpl*>& renderSurfaceLayerList);
27 static void calculateVisibleRects(Vector<CCLayerImpl*>& renderSurfaceLayerList);
28 static void calculateVisibleRects(Vector<RefPtr<LayerChromium> >& renderSurfaceLayerList);
30 // Performs hit testing for a given renderSurfaceLayerList.
31 static CCLayerImpl* findLayerThatIsHitByPoint(const IntPoint& viewportPoint, Vector<CCLayerImpl*>& renderSurfaceLayerList);
33 template<typename LayerType> static bool renderSurfaceContributesToTarget(LayerType*, int targetSurfaceLayerID);
35 // Returns a layer with the given id if one exists in the subtree starting
36 // from the given root layer (including mask and replica layers).
37 template<typename LayerType> static LayerType* findLayerInSubtree(LayerType* rootLayer, int layerId);
39 struct ScrollUpdateInfo {
40 int layerId;
41 IntSize scrollDelta;
45 struct CCScrollAndScaleSet {
46 Vector<CCLayerTreeHostCommon::ScrollUpdateInfo> scrolls;
47 float pageScaleDelta;
50 template<typename LayerType>
51 bool CCLayerTreeHostCommon::renderSurfaceContributesToTarget(LayerType* layer, int targetSurfaceLayerID)
53 // A layer will either contribute its own content, or its render surface's content, to
54 // the target surface. The layer contributes its surface's content when both the
55 // following are true:
56 // (1) The layer actually has a renderSurface, and
57 // (2) The layer's renderSurface is not the same as the targetSurface.
59 // Otherwise, the layer just contributes itself to the target surface.
61 return layer->renderSurface() && layer->id() != targetSurfaceLayerID;
64 template<typename LayerType>
65 LayerType* CCLayerTreeHostCommon::findLayerInSubtree(LayerType* rootLayer, int layerId)
67 if (rootLayer->id() == layerId)
68 return rootLayer;
70 if (rootLayer->maskLayer() && rootLayer->maskLayer()->id() == layerId)
71 return rootLayer->maskLayer();
73 if (rootLayer->replicaLayer() && rootLayer->replicaLayer()->id() == layerId)
74 return rootLayer->replicaLayer();
76 for (size_t i = 0; i < rootLayer->children().size(); ++i) {
77 if (LayerType* found = findLayerInSubtree(rootLayer->children()[i].get(), layerId))
78 return found;
80 return 0;
83 } // namespace WebCore
85 #endif