mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1074194 - Factor out gfxContext::SetColor()'s color management conversion into a gfxPlatform helper. r=Bas
This commit is contained in:
parent
5f8e64d177
commit
3790732f9a
@ -856,20 +856,7 @@ gfxContext::SetColor(const gfxRGBA& c)
|
||||
CurrentState().pattern = nullptr;
|
||||
CurrentState().sourceSurfCairo = nullptr;
|
||||
CurrentState().sourceSurface = nullptr;
|
||||
|
||||
if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
|
||||
|
||||
gfxRGBA cms;
|
||||
qcms_transform *transform = gfxPlatform::GetCMSRGBTransform();
|
||||
if (transform)
|
||||
gfxPlatform::TransformPixel(c, cms, transform);
|
||||
|
||||
// Use the original alpha to avoid unnecessary float->byte->float
|
||||
// conversion errors
|
||||
CurrentState().color = ToColor(cms);
|
||||
}
|
||||
else
|
||||
CurrentState().color = ToColor(c);
|
||||
CurrentState().color = gfxPlatform::MaybeTransformColor(c);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1631,6 +1631,26 @@ 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)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define GFX_PLATFORM_H
|
||||
|
||||
#include "prlog.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -158,6 +159,7 @@ GetBackendName(mozilla::gfx::BackendType aBackend)
|
||||
|
||||
class gfxPlatform {
|
||||
public:
|
||||
typedef mozilla::gfx::Color Color;
|
||||
typedef mozilla::gfx::DataSourceSurface DataSourceSurface;
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
typedef mozilla::gfx::IntSize IntSize;
|
||||
@ -493,6 +495,12 @@ public:
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* Return the output device ICC profile.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user