Bug 537223 - Cleanup gfxColor.h; r=jrmuizel
authorAlfred Kayser <alfredkayser@gmail.com>, Ms2ger <ms2ger@gmail.com>
Thu, 25 Aug 2011 10:46:01 +0200
changeset 75847 7dfa2501f1512452d4f1870de11e66e5bb06a1a7
parent 75846 80db03383c348e81468c0d914fd897c79cc573e6
child 75848 c5b2cbf6e31be28d0b941fb12117e960a603870b
push id21063
push userMs2ger@gmail.com
push dateThu, 25 Aug 2011 08:55:46 +0000
treeherdermozilla-central@c5b2cbf6e31b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs537223
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 537223 - Cleanup gfxColor.h; r=jrmuizel
gfx/layers/Layers.cpp
gfx/layers/ReadbackProcessor.h
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxColor.h
gfx/thebes/gfxPlatform.h
layout/generic/nsTextFrameThebes.cpp
layout/style/nsFontFaceLoader.cpp
netwerk/ipc/NeckoCommon.h
widget/src/cocoa/TextInputHandler.mm
widget/src/windows/nsWindow.cpp
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -41,16 +41,17 @@
 #include "mozilla/layers/PLayers.h"
 #include "mozilla/layers/ShadowLayers.h"
 
 #include "ImageLayers.h"
 #include "Layers.h"
 #include "gfxPlatform.h"
 #include "ReadbackLayer.h"
 #include "gfxUtils.h"
+#include "nsPrintfCString.h"
 #include "mozilla/Util.h"
 
 using namespace mozilla::layers;
 using namespace mozilla::gfx;
 
 typedef FrameMetrics::ViewID ViewID;
 const ViewID FrameMetrics::NULL_SCROLL_ID = 0;
 const ViewID FrameMetrics::ROOT_SCROLL_ID = 1;
--- a/gfx/layers/ReadbackProcessor.h
+++ b/gfx/layers/ReadbackProcessor.h
@@ -35,16 +35,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef GFX_READBACKPROCESSOR_H
 #define GFX_READBACKPROCESSOR_H
 
 #include "ReadbackLayer.h"
 #include "ThebesLayerBuffer.h"
+#include "nsTArray.h"
 
 namespace mozilla {
 namespace layers {
 
 class ReadbackProcessor {
 public:
   /**
    * Called by the container before processing any child layers. Call this
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -79,16 +79,17 @@
 #include "nsComponentManagerUtils.h"
 #include "gfxContext.h"
 #include "prmem.h"
 #include "nsISupportsUtils.h"
 #include "plbase64.h"
 #include "nsCOMPtr.h"
 #include "nsIConsoleService.h"
 #include "nsServiceManagerUtils.h"
+#include "nsStringGlue.h"
 
 using mozilla::CheckedInt;
 
 static cairo_user_data_key_t gfxasurface_pointer_key;
 
 // Surfaces use refcounting that's tied to the cairo surface refcnt, to avoid
 // refcount mismatch issues.
 nsrefcnt
--- a/gfx/thebes/gfxColor.h
+++ b/gfx/thebes/gfxColor.h
@@ -33,20 +33,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef GFX_COLOR_H
 #define GFX_COLOR_H
 
-#ifdef MOZILLA_INTERNAL_API
-#include "nsPrintfCString.h"
-#endif
-
 #include "gfxTypes.h"
 
 #include "prbit.h" // for PR_ROTATE_(LEFT,RIGHT)32
 #include "prio.h"  // for ntohl
 
 #define GFX_UINT32_FROM_BPTR(pbptr,i) (((PRUint32*)(pbptr))[i])
 
 #if defined(IS_BIG_ENDIAN)
@@ -168,17 +164,16 @@ struct THEBES_API gfxRGBA {
 
     enum PackedColorType {
         PACKED_ABGR,
         PACKED_ABGR_PREMULTIPLIED,
 
         PACKED_ARGB,
         PACKED_ARGB_PREMULTIPLIED,
 
-        PACKED_XBGR,
         PACKED_XRGB
     };
 
     gfxRGBA() { }
     /**
      * Intialize this color using explicit red, green, blue and alpha
      * values.
      */
@@ -188,17 +183,16 @@ struct THEBES_API gfxRGBA {
      * Initialize this color from a packed 32-bit color.
      * The color value is interpreted based on colorType;
      * all values use the native platform endianness.
      *
      * @see gfxRGBA::Packed
      */
     gfxRGBA(PRUint32 c, PackedColorType colorType = PACKED_ABGR) {
         if (colorType == PACKED_ABGR ||
-            colorType == PACKED_XBGR ||
             colorType == PACKED_ABGR_PREMULTIPLIED)
         {
             r = ((c >> 0) & 0xff) * (1.0 / 255.0);
             g = ((c >> 8) & 0xff) * (1.0 / 255.0);
             b = ((c >> 16) & 0xff) * (1.0 / 255.0);
             a = ((c >> 24) & 0xff) * (1.0 / 255.0);
         } else if (colorType == PACKED_ARGB ||
                    colorType == PACKED_XRGB ||
@@ -213,36 +207,21 @@ struct THEBES_API gfxRGBA {
         if (colorType == PACKED_ABGR_PREMULTIPLIED ||
             colorType == PACKED_ARGB_PREMULTIPLIED)
         {
             if (a > 0.0) {
                 r /= a;
                 g /= a;
                 b /= a;
             }
-        } else if (colorType == PACKED_XBGR ||
-                   colorType == PACKED_XRGB)
-        {
+        } else if (colorType == PACKED_XRGB) {
             a = 1.0;
         }
     }
 
-    /**
-     * Initialize this color by parsing the given string.
-     * XXX implement me!
-     */
-#if 0
-    gfxRGBA(const char* str) {
-        a = 1.0;
-        // if aString[0] is a #, parse it as hex
-        // if aString[0] is a letter, parse it as a color name
-        // if aString[0] is a number, parse it loosely as hex
-    }
-#endif
-
     bool operator==(const gfxRGBA& other) const
     {
         return r == other.r && g == other.g && b == other.b && a == other.a;
     }
     bool operator!=(const gfxRGBA& other) const
     {
         return !(*this == other);
     }
@@ -256,55 +235,43 @@ struct THEBES_API gfxRGBA {
      * double d = c * 255.0; v = ((PRUint8) d) << x. 
      */
     PRUint32 Packed(PackedColorType colorType = PACKED_ABGR) const {
         gfxFloat rb = (r * 255.0);
         gfxFloat gb = (g * 255.0);
         gfxFloat bb = (b * 255.0);
         gfxFloat ab = (a * 255.0);
 
-        if (colorType == PACKED_ABGR || colorType == PACKED_XBGR) {
+        if (colorType == PACKED_ABGR) {
             return (PRUint8(ab) << 24) |
                    (PRUint8(bb) << 16) |
                    (PRUint8(gb) << 8) |
                    (PRUint8(rb) << 0);
-        } else if (colorType == PACKED_ARGB || colorType == PACKED_XRGB) {
+        }
+        if (colorType == PACKED_ARGB || colorType == PACKED_XRGB) {
             return (PRUint8(ab) << 24) |
                    (PRUint8(rb) << 16) |
                    (PRUint8(gb) << 8) |
                    (PRUint8(bb) << 0);
         }
 
-        rb = (r*a) * 255.0;
-        gb = (g*a) * 255.0;
-        bb = (b*a) * 255.0;
+        rb *= a;
+        gb *= a;
+        bb *= a;
 
         if (colorType == PACKED_ABGR_PREMULTIPLIED) {
             return (((PRUint8)(ab) << 24) |
                     ((PRUint8)(bb) << 16) |
                     ((PRUint8)(gb) << 8) |
                     ((PRUint8)(rb) << 0));
-        } else if (colorType == PACKED_ARGB_PREMULTIPLIED) {
+        }
+        if (colorType == PACKED_ARGB_PREMULTIPLIED) {
             return (((PRUint8)(ab) << 24) |
                     ((PRUint8)(rb) << 16) |
                     ((PRUint8)(gb) << 8) |
                     ((PRUint8)(bb) << 0));
         }
 
         return 0;
     }
-
-#ifdef MOZILLA_INTERNAL_API
-    /**
-     * Convert this color to a hex value. For example, for rgb(255,0,0),
-     * this will return FF0000.
-     */
-    // XXX I'd really prefer to just have this return an nsACString
-    // Does this function even make sense, since we're just ignoring the alpha value?
-    void Hex(nsACString& result) const {
-        nsPrintfCString hex(8, "%02x%02x%02x", PRUint8(r*255.0), PRUint8(g*255.0), PRUint8(b*255.0));
-        result.Assign(hex);
-    }
-#endif
-
 };
 
 #endif /* _GFX_COLOR_H */
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -37,43 +37,44 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef GFX_PLATFORM_H
 #define GFX_PLATFORM_H
 
 #include "prtypes.h"
 #include "prlog.h"
 #include "nsTArray.h"
-
+#include "nsString.h"
 #include "nsIObserver.h"
 
 #include "gfxTypes.h"
 #include "gfxASurface.h"
 #include "gfxColor.h"
 
 #include "qcms.h"
+
+#include "gfx2DGlue.h"
+#include "mozilla/RefPtr.h"
+
 #ifdef XP_OS2
 #undef OS2EMX_PLAIN_CHAR
 #endif
 
 class gfxImageSurface;
 class gfxFont;
 class gfxFontGroup;
 struct gfxFontStyle;
 class gfxUserFontSet;
 class gfxFontEntry;
 class gfxProxyFontEntry;
 class gfxPlatformFontList;
 class gfxTextRun;
 class nsIURI;
 class nsIAtom;
 
-#include "gfx2DGlue.h"
-#include "mozilla/RefPtr.h"
-
 extern cairo_user_data_key_t kDrawTarget;
 
 // pref lang id's for font prefs
 // !!! needs to match the list of pref font.default.xx entries listed in all.js !!!
 // !!! don't use as bit mask, this may grow larger !!!
 
 enum eFontPrefLang {
     eFontPrefLang_Western     =  0,
--- a/layout/generic/nsTextFrameThebes.cpp
+++ b/layout/generic/nsTextFrameThebes.cpp
@@ -101,16 +101,17 @@
 
 #include "nsIServiceManager.h"
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
 #include "nsAutoPtr.h"
 
 #include "nsBidiUtils.h"
+#include "nsPrintfCString.h"
 
 #include "gfxFont.h"
 #include "gfxContext.h"
 #include "gfxTextRunWordCache.h"
 #include "gfxImageSurface.h"
 
 #include "mozilla/dom/Element.h"
 #include "mozilla/Util.h" // for DebugOnly
--- a/layout/style/nsFontFaceLoader.cpp
+++ b/layout/style/nsFontFaceLoader.cpp
@@ -71,16 +71,17 @@
 #include "nsCrossSiteListenerProxy.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIChannelPolicy.h"
 #include "nsChannelPolicy.h"
 
 #include "nsIConsoleService.h"
 
 #include "nsStyleSet.h"
+#include "nsPrintfCString.h"
 
 using namespace mozilla;
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo *gFontDownloaderLog = PR_NewLogModule("fontdownloader");
 #endif /* PR_LOGGING */
 
 #define LOG(args) PR_LOG(gFontDownloaderLog, PR_LOG_DEBUG, args)
--- a/netwerk/ipc/NeckoCommon.h
+++ b/netwerk/ipc/NeckoCommon.h
@@ -38,16 +38,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_net_NeckoCommon_h
 #define mozilla_net_NeckoCommon_h
 
 #include "nsXULAppAPI.h"
 #include "prenv.h"
+#include "nsPrintfCString.h"
 
 #if defined(DEBUG) || defined(ENABLE_TESTS)
 # define NECKO_ERRORS_ARE_FATAL_DEFAULT true
 #else
 # define NECKO_ERRORS_ARE_FATAL_DEFAULT false
 #endif 
 
 // TODO: Eventually remove NECKO_MAYBE_ABORT and DROP_DEAD (bug 575494).
--- a/widget/src/cocoa/TextInputHandler.mm
+++ b/widget/src/cocoa/TextInputHandler.mm
@@ -44,16 +44,17 @@
 #endif // MOZ_LOGGING
 #include "prlog.h"
 
 #include "nsChildView.h"
 #include "nsObjCExceptions.h"
 #include "nsBidiUtils.h"
 #include "nsToolkit.h"
 #include "nsCocoaUtils.h"
+#include "nsPrintfCString.h"
 
 #ifdef __LP64__
 #include "ComplexTextInputPanel.h"
 #endif // __LP64__
 
 #ifndef NP_NO_CARBON
 #include <objc/runtime.h>
 #endif // NP_NO_CARBON
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -151,16 +151,17 @@
 #include "mozilla/Services.h"
 #include "nsNativeThemeWin.h"
 #include "nsWindowsDllInterceptor.h"
 #include "nsIWindowMediator.h"
 #include "nsIServiceManager.h"
 #include "nsWindowGfx.h"
 #include "gfxWindowsPlatform.h"
 #include "Layers.h"
+#include "nsPrintfCString.h"
 #include "mozilla/Preferences.h"
 
 #ifdef MOZ_ENABLE_D3D9_LAYER
 #include "LayerManagerD3D9.h"
 #endif
 
 #ifdef MOZ_ENABLE_D3D10_LAYER
 #include "LayerManagerD3D10.h"