• 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 LayerAndroid;
36 }
37 
38 using namespace WebCore;
39 
40 namespace android {
41 
42 class CachedLayer {
43 public:
44 #if USE(ACCELERATED_COMPOSITING)
45     bool operator<(const CachedLayer& l) const {
46         return mCachedNodeIndex < l.mCachedNodeIndex;
47     }
48     // FIXME: adjustBounds should be renamed globalBounds or toGlobal
49     IntRect adjustBounds(const LayerAndroid* root, const IntRect& bounds) const;
cachedNodeIndex()50     int cachedNodeIndex() const { return mCachedNodeIndex; }
getOffset()51     const IntPoint& getOffset() const { return mOffset; }
52     const LayerAndroid* layer(const LayerAndroid* root) const;
53     IntRect localBounds(const IntRect& bounds) const;
54     SkPicture* picture(const LayerAndroid* root) const;
reset()55     void reset() { mLayer = 0; }
setCachedNodeIndex(int index)56     void setCachedNodeIndex(int index) { mCachedNodeIndex = index; }
setOffset(const IntPoint & offset)57     void setOffset(const IntPoint& offset) { mOffset = offset; }
setUniqueId(int uniqueId)58     void setUniqueId(int uniqueId) { mUniqueId = uniqueId; }
uniqueId()59     int uniqueId() const { return mUniqueId; }
60 private:
61     int mCachedNodeIndex;
62     mutable const LayerAndroid* mLayer;
63     IntPoint mOffset;
64     int mUniqueId;
65 
66 #if DUMP_NAV_CACHE
67 public:
68     class Debug {
69 public:
70         CachedLayer* base() const;
71         void print() const;
72         static void printLayerAndroid(const LayerAndroid* );
73         static void printRootLayerAndroid(const LayerAndroid* );
74         static int spaces;
75     } mDebug;
76 #endif
77 #endif // USE(ACCELERATED_COMPOSITING)
78 };
79 
80 }
81 
82 #endif
83