Bug 537223 - Cleanup gfxColor.h; r=jrmuizel

This commit is contained in:
Alfred Kayser ext:(%2C%20Ms2ger%20%3Cms2ger%40gmail.com%3E) 2011-08-25 10:46:01 +02:00
parent 467aabd2aa
commit 40a50219ea
10 changed files with 22 additions and 46 deletions

View File

@ -46,6 +46,7 @@
#include "gfxPlatform.h"
#include "ReadbackLayer.h"
#include "gfxUtils.h"
#include "nsPrintfCString.h"
#include "mozilla/Util.h"
using namespace mozilla::layers;

View File

@ -40,6 +40,7 @@
#include "ReadbackLayer.h"
#include "ThebesLayerBuffer.h"
#include "nsTArray.h"
namespace mozilla {
namespace layers {

View File

@ -84,6 +84,7 @@
#include "nsCOMPtr.h"
#include "nsIConsoleService.h"
#include "nsServiceManagerUtils.h"
#include "nsStringGlue.h"
using mozilla::CheckedInt;

View File

@ -38,10 +38,6 @@
#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
@ -173,7 +169,6 @@ struct THEBES_API gfxRGBA {
PACKED_ARGB,
PACKED_ARGB_PREMULTIPLIED,
PACKED_XBGR,
PACKED_XRGB
};
@ -193,7 +188,6 @@ struct THEBES_API gfxRGBA {
*/
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);
@ -218,26 +212,11 @@ struct THEBES_API gfxRGBA {
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;
@ -261,28 +240,30 @@ struct THEBES_API gfxRGBA {
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) |
@ -291,20 +272,6 @@ struct THEBES_API gfxRGBA {
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 */

View File

@ -42,7 +42,7 @@
#include "prtypes.h"
#include "prlog.h"
#include "nsTArray.h"
#include "nsString.h"
#include "nsIObserver.h"
#include "gfxTypes.h"
@ -50,6 +50,10 @@
#include "gfxColor.h"
#include "qcms.h"
#include "gfx2DGlue.h"
#include "mozilla/RefPtr.h"
#ifdef XP_OS2
#undef OS2EMX_PLAIN_CHAR
#endif
@ -66,9 +70,6 @@ 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

View File

@ -106,6 +106,7 @@
#include "nsAutoPtr.h"
#include "nsBidiUtils.h"
#include "nsPrintfCString.h"
#include "gfxFont.h"
#include "gfxContext.h"

View File

@ -76,6 +76,7 @@
#include "nsIConsoleService.h"
#include "nsStyleSet.h"
#include "nsPrintfCString.h"
using namespace mozilla;

View File

@ -43,6 +43,7 @@
#include "nsXULAppAPI.h"
#include "prenv.h"
#include "nsPrintfCString.h"
#if defined(DEBUG) || defined(ENABLE_TESTS)
# define NECKO_ERRORS_ARE_FATAL_DEFAULT true

View File

@ -49,6 +49,7 @@
#include "nsBidiUtils.h"
#include "nsToolkit.h"
#include "nsCocoaUtils.h"
#include "nsPrintfCString.h"
#ifdef __LP64__
#include "ComplexTextInputPanel.h"

View File

@ -156,6 +156,7 @@
#include "nsWindowGfx.h"
#include "gfxWindowsPlatform.h"
#include "Layers.h"
#include "nsPrintfCString.h"
#include "mozilla/Preferences.h"
#ifdef MOZ_ENABLE_D3D9_LAYER