• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010, The Android Open Source Project
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *  * Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef CachedLayer_h
27 #define CachedLayer_h
28 
29 #include "CachedDebug.h"
30 #include "IntRect.h"
31 
32 class SkPicture;
33 
34 namespace WebCore {
35     class FloatPoint;
36     class LayerAndroid;
37 }
38 
39 using namespace WebCore;
40 
41 namespace android {
42 
43 class CachedLayer {
44 public:
45 #if USE(ACCELERATED_COMPOSITING)
46     bool operator<(const CachedLayer& l) const {
47         return mCachedNodeIndex < l.mCachedNodeIndex;
48     }
49     // FIXME: adjustBounds should be renamed globalBounds or toGlobal
50     IntRect adjustBounds(const LayerAndroid* root, const IntRect& bounds) const;
cachedNodeIndex()51     int cachedNodeIndex() const { return mCachedNodeIndex; }
52     FloatPoint getGlobalPosition(const LayerAndroid* ) const;
53     const LayerAndroid* layer(const LayerAndroid* root) const;
54     IntRect localBounds(const LayerAndroid* root, const IntRect& bounds) const;
55     SkPicture* picture(const LayerAndroid* root) const;
56     void toLocal(const LayerAndroid* root, int* xPtr, int* yPtr) const;
setCachedNodeIndex(int index)57     void setCachedNodeIndex(int index) { mCachedNodeIndex = index; }
58     // Set the global position of the layer.  This is recorded by the nav cache
59     // and corresponds to RenderLayer::absoluteBoundingBox() which is in
60     // document coordinates.  This can be different from the global position of
61     // the layer if the layer is fixed positioned or scrollable.
setOffset(const IntPoint & offset)62     void setOffset(const IntPoint& offset) { mOffset = offset; }
setUniqueId(int uniqueId)63     void setUniqueId(int uniqueId) { mUniqueId = uniqueId; }
uniqueId()64     int uniqueId() const { return mUniqueId; }
65 private:
66     int mCachedNodeIndex;
67     IntPoint mOffset;
68     int mUniqueId;
69 
70 #if DUMP_NAV_CACHE
71 public:
72     class Debug {
73 public:
74         CachedLayer* base() const;
75         void print() const;
76         static void printLayerAndroid(const LayerAndroid* );
77         static void printRootLayerAndroid(const LayerAndroid* );
78         static int spaces;
79     } mDebug;
80 #endif
81 #endif // USE(ACCELERATED_COMPOSITING)
82 };
83 
84 }
85 
86 #endif
87