mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1084093, part 2 - Convert gfxPlatform::TransformPixel to Moz2D, and move gfxPlatform::MaybeTransformColor to ToDeviceColor in gfxUtils.h. r=Bas
This commit is contained in:
parent
1416cb5fce
commit
70ab7ab36f
@ -827,7 +827,7 @@ gfxContext::SetColor(const gfxRGBA& c)
|
||||
CurrentState().pattern = nullptr;
|
||||
CurrentState().sourceSurfCairo = nullptr;
|
||||
CurrentState().sourceSurface = nullptr;
|
||||
CurrentState().color = gfxPlatform::MaybeTransformColor(c);
|
||||
CurrentState().color = ToDeviceColor(c);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3,8 +3,10 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "gfxTypes.h"
|
||||
#include "gfxPattern.h"
|
||||
|
||||
#include "gfxUtils.h"
|
||||
#include "gfxTypes.h"
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfx2DGlue.h"
|
||||
@ -57,17 +59,10 @@ gfxPattern::AddColorStop(gfxFloat offset, const gfxRGBA& c)
|
||||
}
|
||||
|
||||
mStops = nullptr;
|
||||
gfxRGBA color = c;
|
||||
if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
|
||||
qcms_transform *transform = gfxPlatform::GetCMSRGBTransform();
|
||||
if (transform) {
|
||||
gfxPlatform::TransformPixel(color, color, transform);
|
||||
}
|
||||
}
|
||||
|
||||
GradientStop stop;
|
||||
stop.offset = offset;
|
||||
stop.color = ToColor(color);
|
||||
stop.color = ToDeviceColor(c);
|
||||
mStopsList.AppendElement(stop);
|
||||
}
|
||||
|
||||
|
@ -1601,28 +1601,26 @@ gfxPlatform::GetRenderingIntent()
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatform::TransformPixel(const gfxRGBA& in, gfxRGBA& out, qcms_transform *transform)
|
||||
gfxPlatform::TransformPixel(const Color& in, Color& out, qcms_transform *transform)
|
||||
{
|
||||
|
||||
if (transform) {
|
||||
/* we want the bytes in RGB order */
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
/* ABGR puts the bytes in |RGBA| order on little endian */
|
||||
uint32_t packed = in.Packed(gfxRGBA::PACKED_ABGR);
|
||||
uint32_t packed = in.ToABGR();
|
||||
qcms_transform_data(transform,
|
||||
(uint8_t *)&packed, (uint8_t *)&packed,
|
||||
1);
|
||||
out.~gfxRGBA();
|
||||
new (&out) gfxRGBA(packed, gfxRGBA::PACKED_ABGR);
|
||||
out = Color::FromABGR(packed);
|
||||
#else
|
||||
/* ARGB puts the bytes in |ARGB| order on big endian */
|
||||
uint32_t packed = in.Packed(gfxRGBA::PACKED_ARGB);
|
||||
uint32_t packed = in.ToARGB();
|
||||
/* add one to move past the alpha byte */
|
||||
qcms_transform_data(transform,
|
||||
(uint8_t *)&packed + 1, (uint8_t *)&packed + 1,
|
||||
1);
|
||||
out.~gfxRGBA();
|
||||
new (&out) gfxRGBA(packed, gfxRGBA::PACKED_ARGB);
|
||||
out = Color::FromARGB(packed);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1630,26 +1628,6 @@ gfxPlatform::TransformPixel(const gfxRGBA& in, gfxRGBA& out, qcms_transform *tra
|
||||
out = in;
|
||||
}
|
||||
|
||||
Color
|
||||
gfxPlatform::MaybeTransformColor(const gfxRGBA& aColor)
|
||||
{
|
||||
// We only return this object to get some return value optimization goodness:
|
||||
Color color;
|
||||
if (GetCMSMode() == eCMSMode_All) {
|
||||
gfxRGBA cms;
|
||||
qcms_transform *transform = GetCMSRGBTransform();
|
||||
if (transform) {
|
||||
TransformPixel(aColor, cms, transform);
|
||||
// Use the original alpha to avoid unnecessary float->byte->float
|
||||
// conversion errors
|
||||
color = ToColor(cms);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
color = ToColor(aColor);
|
||||
return color;
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatform::GetPlatformCMSOutputProfile(void *&mem, size_t &size)
|
||||
{
|
||||
|
@ -493,13 +493,7 @@ public:
|
||||
*
|
||||
* Sets 'out' to 'in' if transform is nullptr.
|
||||
*/
|
||||
static void TransformPixel(const gfxRGBA& in, gfxRGBA& out, qcms_transform *transform);
|
||||
|
||||
/**
|
||||
* Converts the color using the GetCMSRGBTransform() transform if the
|
||||
* CMS mode is eCMSMode_All, else just returns the color.
|
||||
*/
|
||||
static Color MaybeTransformColor(const gfxRGBA& aColor);
|
||||
static void TransformPixel(const Color& in, Color& out, qcms_transform *transform);
|
||||
|
||||
/**
|
||||
* Return the output device ICC profile.
|
||||
|
@ -1349,3 +1349,36 @@ bool gfxUtils::sDumpPainting = getenv("MOZ_DUMP_PAINT") != 0;
|
||||
bool gfxUtils::sDumpPaintingToFile = getenv("MOZ_DUMP_PAINT_TO_FILE") != 0;
|
||||
FILE *gfxUtils::sDumpPaintFile = nullptr;
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
Color ToDeviceColor(Color aColor)
|
||||
{
|
||||
// aColor is pass-by-value since to get return value optimization goodness we
|
||||
// need to return the same object from all return points in this function. We
|
||||
// could declare a local Color variable and use that, but we might as well
|
||||
// just use aColor.
|
||||
if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
|
||||
qcms_transform *transform = gfxPlatform::GetCMSRGBTransform();
|
||||
if (transform) {
|
||||
gfxPlatform::TransformPixel(aColor, aColor, transform);
|
||||
// Use the original alpha to avoid unnecessary float->byte->float
|
||||
// conversion errors
|
||||
}
|
||||
}
|
||||
return aColor;
|
||||
}
|
||||
|
||||
Color ToDeviceColor(nscolor aColor)
|
||||
{
|
||||
return ToDeviceColor(Color::FromABGR(aColor));
|
||||
}
|
||||
|
||||
Color ToDeviceColor(const gfxRGBA& aColor)
|
||||
{
|
||||
return ToDeviceColor(ToColor(aColor));
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "imgIContainer.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
class gfxASurface;
|
||||
@ -309,6 +310,16 @@ public:
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
/**
|
||||
* If the CMS mode is eCMSMode_All, these functions transform the passed
|
||||
* color to a device color using the transform returened by gfxPlatform::
|
||||
* GetCMSRGBTransform(). If the CMS mode is some other value, the color is
|
||||
* returned unchanged (other than a type change to Moz2D Color, if
|
||||
* applicable).
|
||||
*/
|
||||
Color ToDeviceColor(Color aColor);
|
||||
Color ToDeviceColor(nscolor aColor);
|
||||
Color ToDeviceColor(const gfxRGBA& aColor);
|
||||
|
||||
/* These techniques are suggested by "Bit Twiddling Hacks"
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user