• 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 CachedColor_h
27 #define CachedColor_h
28 
29 #include "CachedDebug.h"
30 #include "Color.h"
31 #include "Length.h"
32 #include "SkColor.h"
33 
34 using namespace WebCore;
35 
36 namespace android {
37 
38 class CachedColor {
39 public:
CachedColor()40     CachedColor() {
41         // Initiaized to 0 in its array, so nothing to do in the
42         // constructor
43     }
44     bool operator==(const CachedColor& o) const {
45         return memcmp(&o, this, sizeof(this)) == 0; }
fillColor()46     SkColor fillColor() const { return mFillColor; }
47     void init();
innerWidth()48     int innerWidth() const { return mInnerWidth; }
outerWidth()49     int outerWidth() const { return mOuterWidth; }
outset()50     int outset() const { return mOutset; }
pressedInnerColor()51     SkColor pressedInnerColor() const { return mPressedInnerColor; }
pressedOuterColor()52     SkColor pressedOuterColor() const { return mPressedOuterColor; }
radius()53     int radius() const { return mRadius; }
selectedInnerColor()54     SkColor selectedInnerColor() const { return mSelectedInnerColor; }
selectedOuterColor()55     SkColor selectedOuterColor() const { return mSelectedOuterColor; }
setFillColor(const Color & c)56     void setFillColor(const Color& c) { mFillColor = c.rgb(); }
setInnerWidth(Length l)57     void setInnerWidth(Length l) { mInnerWidth = l.value(); }
setOuterWidth(Length l)58     void setOuterWidth(Length l) { mOuterWidth = l.value(); }
setOutset(Length l)59     void setOutset(Length l) { mOutset = l.value(); }
setPressedInnerColor(const Color & c)60     void setPressedInnerColor(const Color& c) { mPressedInnerColor = c.rgb(); }
setPressedOuterColor(const Color & c)61     void setPressedOuterColor(const Color& c) { mPressedOuterColor = c.rgb(); }
setRadius(Length l)62     void setRadius(Length l) { mRadius = l.value(); }
setSelectedInnerColor(const Color & c)63     void setSelectedInnerColor(const Color& c) { mSelectedInnerColor = c.rgb(); }
setSelectedOuterColor(const Color & c)64     void setSelectedOuterColor(const Color& c) { mSelectedOuterColor = c.rgb(); }
65 private:
66     SkColor mFillColor;
67     int mInnerWidth;
68     int mOuterWidth;
69     int mOutset;
70     SkColor mPressedInnerColor;
71     SkColor mPressedOuterColor;
72     int mRadius;
73     SkColor mSelectedInnerColor;
74     SkColor mSelectedOuterColor;
75 #if DUMP_NAV_CACHE
76 public:
77     class Debug {
78 public:
79         CachedColor* base() const;
80         void print() const;
81     } mDebug;
82 #endif
83 };
84 
85 }
86 
87 #endif
88