Use bitfield for bool data members in BitmapImage.
https://bugs.webkit.org/show_bug.cgi?id=74102

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2011-12-08
Reviewed by Darin Adler.

Class BitmapImage and FrameData has bool data members, we can use bitfield for those data
members to reduce the BitmapImage's memory footprint.

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::BitmapImage):
* platform/graphics/BitmapImage.h:
(WebCore::FrameData::FrameData):
* platform/graphics/cairo/ImageCairo.cpp:
(WebCore::BitmapImage::BitmapImage):
* platform/graphics/cg/ImageCG.cpp:
(WebCore::BitmapImage::BitmapImage):
* platform/graphics/openvg/ImageOpenVG.cpp:
(WebCore::BitmapImage::BitmapImage):
* platform/graphics/qt/ImageQt.cpp:
(WebCore::BitmapImage::BitmapImage):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@102404 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/platform/graphics/BitmapImage.cpp b/Source/WebCore/platform/graphics/BitmapImage.cpp
index 7e6f686..a895760 100644
--- a/Source/WebCore/platform/graphics/BitmapImage.cpp
+++ b/Source/WebCore/platform/graphics/BitmapImage.cpp
@@ -52,6 +52,9 @@
     , m_repetitionCountStatus(Unknown)
     , m_repetitionsComplete(0)
     , m_desiredFrameStartTime(0)
+    , m_decodedSize(0)
+    , m_decodedPropertiesSize(0)
+    , m_frameCount(0)
     , m_isSolidColor(false)
     , m_checkedForSolidColor(false)
     , m_animationFinished(false)
@@ -59,10 +62,7 @@
     , m_haveSize(false)
     , m_sizeAvailable(false)
     , m_hasUniformFrameSize(true)
-    , m_decodedSize(0)
-    , m_decodedPropertiesSize(0)
     , m_haveFrameCount(false)
-    , m_frameCount(0)
 {
     initPlatformData();
 }
diff --git a/Source/WebCore/platform/graphics/BitmapImage.h b/Source/WebCore/platform/graphics/BitmapImage.h
index bcd3497..f4d50ce 100644
--- a/Source/WebCore/platform/graphics/BitmapImage.h
+++ b/Source/WebCore/platform/graphics/BitmapImage.h
@@ -69,9 +69,9 @@
 public:
     FrameData()
         : m_frame(0)
+        , m_duration(0)
         , m_haveMetadata(false)
         , m_isComplete(false)
-        , m_duration(0)
         , m_hasAlpha(true) 
     {
     }
@@ -86,10 +86,10 @@
     bool clear(bool clearMetadata);
 
     NativeImagePtr m_frame;
-    bool m_haveMetadata;
-    bool m_isComplete;
     float m_duration;
-    bool m_hasAlpha;
+    bool m_haveMetadata : 1;
+    bool m_isComplete : 1;
+    bool m_hasAlpha : 1;
 };
 
 // =================================================
@@ -275,22 +275,21 @@
 #endif
 
     Color m_solidColor;  // If we're a 1x1 solid color, this is the color to use to fill.
-    bool m_isSolidColor;  // Whether or not we are a 1x1 solid image.
-    bool m_checkedForSolidColor; // Whether we've checked the frame for solid color.
-
-    bool m_animationFinished;  // Whether or not we've completed the entire animation.
-
-    bool m_allDataReceived;  // Whether or not we've received all our data.
-
-    mutable bool m_haveSize; // Whether or not our |m_size| member variable has the final overall image size yet.
-    bool m_sizeAvailable; // Whether or not we can obtain the size of the first image frame yet from ImageIO.
-    mutable bool m_hasUniformFrameSize;
 
     unsigned m_decodedSize; // The current size of all decoded frames.
     mutable unsigned m_decodedPropertiesSize; // The size of data decoded by the source to determine image properties (e.g. size, frame count, etc).
-
-    mutable bool m_haveFrameCount;
     size_t m_frameCount;
+
+    bool m_isSolidColor : 1; // Whether or not we are a 1x1 solid image.
+    bool m_checkedForSolidColor : 1; // Whether we've checked the frame for solid color.
+
+    bool m_animationFinished : 1; // Whether or not we've completed the entire animation.
+
+    bool m_allDataReceived : 1; // Whether or not we've received all our data.
+    mutable bool m_haveSize : 1; // Whether or not our |m_size| member variable has the final overall image size yet.
+    bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the first image frame yet from ImageIO.
+    mutable bool m_hasUniformFrameSize : 1;
+    mutable bool m_haveFrameCount : 1;
 };
 
 }
diff --git a/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp
index 05c094f..0084b42 100644
--- a/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp
@@ -66,15 +66,15 @@
     , m_repetitionCount(cAnimationNone)
     , m_repetitionCountStatus(Unknown)
     , m_repetitionsComplete(0)
+    , m_decodedSize(0)
+    , m_frameCount(1)
     , m_isSolidColor(false)
     , m_checkedForSolidColor(false)
     , m_animationFinished(true)
     , m_allDataReceived(true)
     , m_haveSize(true)
     , m_sizeAvailable(true)
-    , m_decodedSize(0)
     , m_haveFrameCount(true)
-    , m_frameCount(1)
 {
     initPlatformData();
 
diff --git a/Source/WebCore/platform/graphics/cg/ImageCG.cpp b/Source/WebCore/platform/graphics/cg/ImageCG.cpp
index 0236b4e..d81c780 100644
--- a/Source/WebCore/platform/graphics/cg/ImageCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/ImageCG.cpp
@@ -74,15 +74,15 @@
     , m_repetitionCount(cAnimationNone)
     , m_repetitionCountStatus(Unknown)
     , m_repetitionsComplete(0)
+    , m_decodedSize(0)
+    , m_frameCount(1)
     , m_isSolidColor(false)
     , m_checkedForSolidColor(false)
     , m_animationFinished(true)
     , m_allDataReceived(true)
     , m_haveSize(true)
     , m_sizeAvailable(true)
-    , m_decodedSize(0)
     , m_haveFrameCount(true)
-    , m_frameCount(1)
 {
     initPlatformData();
     
diff --git a/Source/WebCore/platform/graphics/openvg/ImageOpenVG.cpp b/Source/WebCore/platform/graphics/openvg/ImageOpenVG.cpp
index 4c1932a..8636edf 100644
--- a/Source/WebCore/platform/graphics/openvg/ImageOpenVG.cpp
+++ b/Source/WebCore/platform/graphics/openvg/ImageOpenVG.cpp
@@ -60,6 +60,7 @@
     , m_repetitionCountStatus(Unknown)
     , m_repetitionsComplete(0)
     , m_desiredFrameStartTime(0)
+    , m_frameCount(1)
     , m_isSolidColor(false)
     , m_checkedForSolidColor(false)
     , m_animationFinished(false)
@@ -68,7 +69,6 @@
     , m_sizeAvailable(true)
     , m_hasUniformFrameSize(true)
     , m_haveFrameCount(true)
-    , m_frameCount(1)
 {
     initPlatformData();
 
diff --git a/Source/WebCore/platform/graphics/qt/ImageQt.cpp b/Source/WebCore/platform/graphics/qt/ImageQt.cpp
index 0f26fa4..2960bed 100644
--- a/Source/WebCore/platform/graphics/qt/ImageQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageQt.cpp
@@ -198,15 +198,15 @@
     , m_repetitionCount(cAnimationNone)
     , m_repetitionCountStatus(Unknown)
     , m_repetitionsComplete(0)
+    , m_decodedSize(0)
+    , m_frameCount(1)
     , m_isSolidColor(false)
     , m_checkedForSolidColor(false)
     , m_animationFinished(true)
     , m_allDataReceived(true)
     , m_haveSize(true)
     , m_sizeAvailable(true)
-    , m_decodedSize(0)
     , m_haveFrameCount(true)
-    , m_frameCount(1)
 {
     initPlatformData();