Bug 1208300 (part 4) - Remove gfxRGBA and some related things. r=jwatt.

Hooray!
This commit is contained in:
Nicholas Nethercote 2015-09-24 19:24:16 -07:00
parent d1522c8949
commit 61bcd9b78c
33 changed files with 7 additions and 253 deletions

View File

@ -11,6 +11,7 @@
#include "WebMDemuxer.h"
#include "WebMBufferedParser.h"
#include "gfx2DGlue.h"
#include "mozilla/Endian.h"
#include "mozilla/Preferences.h"
#include "mozilla/SharedThreadPool.h"
#include "MediaDataDemuxer.h"

View File

@ -31,7 +31,6 @@
#include "gfxXlibSurface.h"
#endif
#include "gfxContext.h"
#include "gfxColor.h"
#include "gfxUtils.h"
#include "mozilla/gfx/2D.h"
#include "Layers.h"

View File

@ -39,7 +39,6 @@
#ifdef XP_MACOSX
#include <CoreServices/CoreServices.h>
#include "gfxColor.h"
#endif
#if defined(MOZ_WIDGET_COCOA)

View File

@ -7,6 +7,7 @@
#include "GLReadTexImageHelper.h"
#include "gfx2DGlue.h"
#include "gfxColor.h"
#include "gfxTypes.h"
#include "GLContext.h"
#include "OGLShaderProgram.h"

View File

@ -13,7 +13,6 @@
#include <stdint.h>
#include "gfxColor.h"
#include "mozilla/gfx/Matrix.h"
#include "GraphicsFilter.h"
#include "gfxPoint.h"
@ -293,28 +292,6 @@ struct ParamTraits<mozilla::PixelFormat>
{};
*/
template<>
struct ParamTraits<gfxRGBA>
{
typedef gfxRGBA paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.r);
WriteParam(msg, param.g);
WriteParam(msg, param.b);
WriteParam(msg, param.a);
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
return (ReadParam(msg, iter, &result->r) &&
ReadParam(msg, iter, &result->g) &&
ReadParam(msg, iter, &result->b) &&
ReadParam(msg, iter, &result->a));
}
};
template<>
struct ParamTraits<mozilla::gfx::Color>
{

View File

@ -13,7 +13,6 @@
#include "mozilla/gfx/Rect.h" // for RoundedIn
#include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
#include "mozilla/gfx/Logging.h" // for Log
#include "gfxColor.h"
#include "nsString.h"
namespace IPC {

View File

@ -21,7 +21,6 @@
#include "mozilla/layers/LayerManagerComposite.h"
#include "mozilla/layers/TextureHostOGL.h"
#include "gfxColor.h"
#include "gfxContext.h"
#include "gfxUtils.h"
#include "gfxPrefs.h"

View File

@ -10,7 +10,6 @@
#include "ImageLayers.h" // for ImageLayer, etc
#include "Layers.h" // for Layer, ContainerLayer, etc
#include "Units.h" // for ParentLayerIntRect
#include "gfxColor.h" // for gfxRGBA
#include "GraphicsFilter.h" // for GraphicsFilter
#include "gfxRect.h" // for gfxRect
#include "gfxUtils.h" // for gfxUtils

View File

@ -13,7 +13,6 @@
#include "Units.h" // for LayerMargin, LayerPoint, ParentLayerIntRect
#include "gfxContext.h"
#include "gfxTypes.h"
#include "gfxColor.h" // for gfxRGBA
#include "GraphicsFilter.h" // for GraphicsFilter
#include "gfxPoint.h" // for gfxPoint
#include "gfxRect.h" // for gfxRect

View File

@ -7,7 +7,6 @@
#include "LayersLogging.h"
#include <stdint.h> // for uint8_t
#include "gfxColor.h" // for gfxRGBA
#include "ImageTypes.h" // for ImageFormat
#include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix
#include "mozilla/gfx/Point.h" // for IntSize
@ -57,17 +56,6 @@ AppendToString(std::stringstream& aStream, FrameMetrics::ViewID n,
aStream << sfx;
}
void
AppendToString(std::stringstream& aStream, const gfxRGBA& c,
const char* pfx, const char* sfx)
{
aStream << pfx;
aStream << nsPrintfCString(
"rgba(%d, %d, %d, %g)",
uint8_t(c.r*255.0), uint8_t(c.g*255.0), uint8_t(c.b*255.0), c.a).get();
aStream << sfx;
}
void
AppendToString(std::stringstream& aStream, const Color& c,
const char* pfx, const char* sfx)

View File

@ -16,8 +16,6 @@
#include "nsRegion.h" // for nsRegion, nsIntRegion
#include "nscore.h" // for nsACString, etc
struct gfxRGBA;
namespace mozilla {
namespace gfx {
class Matrix4x4;
@ -40,10 +38,6 @@ void
AppendToString(std::stringstream& aStream, FrameMetrics::ViewID n,
const char* pfx="", const char* sfx="");
void
AppendToString(std::stringstream& aStream, const gfxRGBA& c,
const char* pfx="", const char* sfx="");
void
AppendToString(std::stringstream& aStream, const gfx::Color& c,
const char* pfx="", const char* sfx="");

View File

@ -8,9 +8,8 @@
#include <stdint.h> // for uint64_t
#include "Layers.h" // for Layer, etc
#include "gfxColor.h" // for gfxRGBA
#include "mozilla/gfx/Rect.h" // for gfxRect
#include "mozilla/gfx/Point.h" // for gfxRect
#include "mozilla/gfx/Point.h" // for IntPoint
#include "mozilla/mozalloc.h" // for operator delete
#include "nsAutoPtr.h" // for nsAutoPtr
#include "nsCOMPtr.h" // for already_AddRefed

View File

@ -9,7 +9,6 @@
#include "ReadbackLayer.h" // for ReadbackLayer, ReadbackSink
#include "UnitTransforms.h" // for ViewAs
#include "Units.h" // for ParentLayerIntRect
#include "gfxColor.h" // for gfxRGBA
#include "gfxContext.h" // for gfxContext
#include "gfxUtils.h"
#include "gfxRect.h" // for gfxRect

View File

@ -17,7 +17,6 @@
#include "basic/BasicImplData.h" // for BasicImplData
#include "basic/BasicLayers.h" // for BasicLayerManager, etc
#include "gfxASurface.h" // for gfxASurface, etc
#include "gfxColor.h" // for gfxRGBA
#include "gfxContext.h" // for gfxContext, etc
#include "gfxImageSurface.h" // for gfxImageSurface
#include "gfxMatrix.h" // for gfxMatrix

View File

@ -5,7 +5,6 @@
#include "mozilla/layers/ContentClient.h"
#include "BasicLayers.h" // for BasicLayerManager
#include "gfxColor.h" // for gfxRGBA
#include "gfxContext.h" // for gfxContext, etc
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPrefs.h" // for gfxPrefs

View File

@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ColorLayerComposite.h"
#include "gfxColor.h" // for gfxRGBA
#include "mozilla/RefPtr.h" // for RefPtr
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/gfx/Point.h" // for Point

View File

@ -10,7 +10,6 @@
#include "mozilla/layers/Compositor.h"
#include "mozilla/layers/Effects.h"
#include "mozilla/TimeStamp.h"
#include "gfxColor.h"
#include "gfxPrefs.h"
#include <math.h>
#include "GeckoProfiler.h"

View File

@ -14,8 +14,6 @@
#include "Layers.h"
#include "GLContext.h"
struct gfxRGBA;
namespace mozilla {
namespace layers {

View File

@ -20,8 +20,6 @@
#include <string>
struct gfxRGBA;
namespace mozilla {
namespace layers {
@ -435,10 +433,6 @@ public:
SetUniform(KnownUniform::MaskTexture, aUnit);
}
void SetRenderColor(const gfxRGBA& aColor) {
SetUniform(KnownUniform::RenderColor, aColor);
}
void SetRenderColor(const gfx::Color& aColor) {
SetUniform(KnownUniform::RenderColor, aColor);
}
@ -507,17 +501,6 @@ protected:
}
}
void SetUniform(KnownUniform::KnownUniformName aKnownUniform, const gfxRGBA& aColor)
{
ASSERT_THIS_PROGRAM;
NS_ASSERTION(aKnownUniform >= 0 && aKnownUniform < KnownUniform::KnownUniformCount, "Invalid known uniform");
KnownUniform& ku(mProfile.mUniforms[aKnownUniform]);
if (ku.UpdateUniform(aColor.r, aColor.g, aColor.b, aColor.a)) {
mGL->fUniform4fv(ku.mLocation, 1, ku.mValue.f16v);
}
}
void SetUniform(KnownUniform::KnownUniformName aKnownUniform, const gfx::Color& aColor) {
ASSERT_THIS_PROGRAM;
NS_ASSERTION(aKnownUniform >= 0 && aKnownUniform < KnownUniform::KnownUniformCount, "Invalid known uniform");

View File

@ -27,10 +27,6 @@ typedef uint32_t nscolor;
#define NS_RGBA(_r,_g,_b,_a) \
((nscolor) (((_a) << 24) | ((_b)<<16) | ((_g)<<8) | (_r)))
// Make a color out of a gfxRGBA.
#define NS_RGBA_FROM_GFXRGBA(gfxColor) \
((nscolor) (gfxColor.Packed()))
// Extract color components from nscolor
#define NS_GET_R(_rgba) ((uint8_t) ((_rgba) & 0xff))
#define NS_GET_G(_rgba) ((uint8_t) (((_rgba) >> 8) & 0xff))

View File

@ -13,7 +13,6 @@
#include "mozilla/gfx/Matrix.h"
#include "mozilla/gfx/Rect.h"
#include "mozilla/gfx/2D.h"
#include "gfxColor.h"
namespace mozilla {
namespace gfx {
@ -34,17 +33,6 @@ inline Rect ToRect(const IntRect &aRect)
return Rect(aRect.x, aRect.y, aRect.width, aRect.height);
}
inline Color ToColor(const gfxRGBA &aRGBA)
{
return Color(Float(aRGBA.r), Float(aRGBA.g),
Float(aRGBA.b), Float(aRGBA.a));
}
inline gfxRGBA ThebesColor(const Color &aColor)
{
return gfxRGBA(aColor.r, aColor.g, aColor.b, aColor.a);
}
inline Matrix ToMatrix(const gfxMatrix &aMatrix)
{
return Matrix(Float(aMatrix._11), Float(aMatrix._12), Float(aMatrix._21),
@ -138,11 +126,6 @@ inline gfxRect ThebesRect(const RectDouble &aRect)
return gfxRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
inline gfxRGBA ThebesRGBA(const Color &aColor)
{
return gfxRGBA(aColor.r, aColor.g, aColor.b, aColor.a);
}
inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
{
switch (aFormat) {

View File

@ -15,7 +15,6 @@
class gfxContext;
struct gfxRect;
struct gfxRGBA;
namespace mozilla {
namespace gfx {

View File

@ -6,29 +6,9 @@
#ifndef GFX_COLOR_H
#define GFX_COLOR_H
#include "gfxTypes.h"
#include "mozilla/Attributes.h" // for MOZ_ALWAYS_INLINE
#include "mozilla/Endian.h" // for mozilla::NativeEndian::swapToBigEndian
#define GFX_UINT32_FROM_BPTR(pbptr,i) (((uint32_t*)(pbptr))[i])
/**
* GFX_0XFF_PPIXEL_FROM_BPTR(x)
*
* Avoid tortured construction of 32-bit ARGB pixel from 3 individual bytes
* of memory plus constant 0xFF. RGB bytes are already contiguous!
* Equivalent to: GFX_PACKED_PIXEL(0xff,r,g,b)
*
* Attempt to use fast byte-swapping instruction(s), e.g. bswap on x86, in
* preference to a sequence of shift/or operations.
*/
#define GFX_0XFF_PPIXEL_FROM_UINT32(x) \
( (mozilla::NativeEndian::swapToBigEndian(uint32_t(x)) >> 8) | (0xFFU << 24) )
#define GFX_0XFF_PPIXEL_FROM_BPTR(x) \
( GFX_0XFF_PPIXEL_FROM_UINT32(GFX_UINT32_FROM_BPTR((x),0)) )
/**
* GFX_BLOCK_RGB_TO_FRGB(from,to)
* sizeof(*from) == sizeof(char)
@ -39,9 +19,9 @@
*/
#define GFX_BLOCK_RGB_TO_FRGB(from,to) \
PR_BEGIN_MACRO \
uint32_t m0 = GFX_UINT32_FROM_BPTR(from,0), \
m1 = GFX_UINT32_FROM_BPTR(from,1), \
m2 = GFX_UINT32_FROM_BPTR(from,2), \
uint32_t m0 = ((uint32_t*)from)[0], \
m1 = ((uint32_t*)from)[1], \
m2 = ((uint32_t*)from)[2], \
rgbr = mozilla::NativeEndian::swapToBigEndian(m0), \
gbrg = mozilla::NativeEndian::swapToBigEndian(m1), \
brgb = mozilla::NativeEndian::swapToBigEndian(m2), \
@ -100,128 +80,4 @@ gfxPackedPixel(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
}
}
/**
* A color value, storing red, green, blue and alpha components.
* This class does not use premultiplied alpha.
*
* XXX should this use doubles (instead of gfxFloat), for consistency with
* cairo?
*/
struct gfxRGBA {
gfxFloat r, g, b, a;
enum PackedColorType {
PACKED_ABGR,
PACKED_ABGR_PREMULTIPLIED,
PACKED_ARGB,
PACKED_ARGB_PREMULTIPLIED,
PACKED_XRGB
};
gfxRGBA() { }
/**
* Intialize this color using explicit red, green, blue and alpha
* values.
*/
MOZ_CONSTEXPR gfxRGBA(gfxFloat _r, gfxFloat _g, gfxFloat _b, gfxFloat _a=1.0) : r(_r), g(_g), b(_b), a(_a) {}
/**
* Initialize this color from a packed 32-bit color.
* The color value is interpreted based on colorType;
* all values use the native platform endianness.
*
* Resulting gfxRGBA stores non-premultiplied data.
*
* @see gfxRGBA::Packed
*/
MOZ_IMPLICIT gfxRGBA(uint32_t c, PackedColorType colorType = PACKED_ABGR) {
if (colorType == PACKED_ABGR ||
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 ||
colorType == PACKED_ARGB_PREMULTIPLIED)
{
b = ((c >> 0) & 0xff) * (1.0 / 255.0);
g = ((c >> 8) & 0xff) * (1.0 / 255.0);
r = ((c >> 16) & 0xff) * (1.0 / 255.0);
a = ((c >> 24) & 0xff) * (1.0 / 255.0);
}
if (colorType == PACKED_ABGR_PREMULTIPLIED ||
colorType == PACKED_ARGB_PREMULTIPLIED)
{
if (a > 0.0) {
r /= a;
g /= a;
b /= a;
}
} else if (colorType == PACKED_XRGB) {
a = 1.0;
}
}
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);
}
/**
* Returns this color value as a packed 32-bit integer. This reconstructs
* the int32_t based on the given colorType, always in the native byte order.
*
* Note: gcc 4.2.3 on at least Ubuntu (x86) does something strange with
* (uint8_t)(c * 255.0) << x, where the result is different than
* double d = c * 255.0; v = ((uint8_t) d) << x.
*/
uint32_t 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) {
return (uint8_t(ab) << 24) |
(uint8_t(bb) << 16) |
(uint8_t(gb) << 8) |
(uint8_t(rb) << 0);
}
if (colorType == PACKED_ARGB || colorType == PACKED_XRGB) {
return (uint8_t(ab) << 24) |
(uint8_t(rb) << 16) |
(uint8_t(gb) << 8) |
(uint8_t(bb) << 0);
}
rb *= a;
gb *= a;
bb *= a;
if (colorType == PACKED_ABGR_PREMULTIPLIED) {
return (((uint8_t)(ab) << 24) |
((uint8_t)(bb) << 16) |
((uint8_t)(gb) << 8) |
((uint8_t)(rb) << 0));
}
if (colorType == PACKED_ARGB_PREMULTIPLIED) {
return (((uint8_t)(ab) << 24) |
((uint8_t)(rb) << 16) |
((uint8_t)(gb) << 8) |
((uint8_t)(bb) << 0));
}
return 0;
}
};
#endif /* _GFX_COLOR_H */

View File

@ -14,7 +14,6 @@
#include "gfxContext.h"
#include "gfxColor.h"
#include "gfxMatrix.h"
#include "gfxUtils.h"
#include "gfxASurface.h"

View File

@ -7,7 +7,6 @@
#include "gfxASurface.h"
#include "gfxContext.h"
#include "gfxPlatform.h"
#include "gfxColor.h"
#include "gfx2DGlue.h"
#ifdef MOZ_X11
#include "cairo.h"

View File

@ -7,7 +7,6 @@
#include "mozilla/BinarySearch.h"
#include "gfxFontUtils.h"
#include "gfxColor.h"
#include "nsServiceManagerUtils.h"

View File

@ -6,7 +6,6 @@
#ifndef GFXQTNATIVERENDER_H_
#define GFXQTNATIVERENDER_H_
#include "gfxColor.h"
#include "gfxContext.h"
#include "gfxXlibSurface.h"
#include "mozilla/gfx/Rect.h"

View File

@ -28,7 +28,6 @@
#include "gfxFont.h"
#include "nsSMILAnimationController.h"
#include "gfxContext.h"
#include "gfxColor.h"
#include "harfbuzz/hb.h"
#define SVG_CONTENT_TYPE NS_LITERAL_CSTRING("image/svg+xml")

View File

@ -6,7 +6,6 @@
#ifndef GFX_UTILS_H
#define GFX_UTILS_H
#include "gfxColor.h"
#include "gfxTypes.h"
#include "GraphicsFilter.h"
#include "imgIContainer.h"

View File

@ -54,7 +54,6 @@
#include "ImageContainer.h"
#include "mozilla/Telemetry.h"
#include "gfxUtils.h"
#include "gfxColor.h"
#include "gfxGradientCache.h"
#include "GraphicsFilter.h"
#include "nsInlineFrame.h"

View File

@ -14,7 +14,6 @@
#include "nsContentUtils.h"
#include "nsSVGEffects.h"
#include "nsSVGAnimatedTransformList.h"
#include "gfxColor.h"
// XXX Tight coupling with content classes ahead!

View File

@ -23,7 +23,6 @@
#include "nsSVGUtils.h"
#include "nsSVGAnimatedTransformList.h"
#include "SVGContentUtils.h"
#include "gfxColor.h"
using namespace mozilla;
using namespace mozilla::dom;

View File

@ -42,7 +42,6 @@
#include "imgIEncoder.h"
#include "nsIThread.h"
#include "MainThreadUtils.h"
#include "gfxColor.h"
#include "nsLookAndFeel.h"
#ifdef NS_ENABLE_TSF