mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 924679. Part 7: Remove gfxAlphaRecovery::Analysis since no-one uses it. r=mattwoodrow
--HG-- extra : rebase_source : f0481abfa3e5c4855f71cec66eea5c4501fd8565
This commit is contained in:
parent
aa07fb8924
commit
971539a169
@ -12,8 +12,7 @@
|
||||
|
||||
/* static */ bool
|
||||
gfxAlphaRecovery::RecoverAlpha(gfxImageSurface* blackSurf,
|
||||
const gfxImageSurface* whiteSurf,
|
||||
Analysis* analysis)
|
||||
const gfxImageSurface* whiteSurf)
|
||||
{
|
||||
gfxIntSize size = blackSurf->GetSize();
|
||||
|
||||
@ -25,7 +24,7 @@ gfxAlphaRecovery::RecoverAlpha(gfxImageSurface* blackSurf,
|
||||
return false;
|
||||
|
||||
#ifdef MOZILLA_MAY_SUPPORT_SSE2
|
||||
if (!analysis && mozilla::supports_sse2() &&
|
||||
if (mozilla::supports_sse2() &&
|
||||
RecoverAlphaSSE2(blackSurf, whiteSurf)) {
|
||||
return true;
|
||||
}
|
||||
@ -37,56 +36,18 @@ gfxAlphaRecovery::RecoverAlpha(gfxImageSurface* blackSurf,
|
||||
unsigned char* blackData = blackSurf->Data();
|
||||
unsigned char* whiteData = whiteSurf->Data();
|
||||
|
||||
/* Get the alpha value of 'first' */
|
||||
uint32_t first;
|
||||
if (size.width == 0 || size.height == 0) {
|
||||
first = 0;
|
||||
} else {
|
||||
if (!blackData || !whiteData)
|
||||
return false;
|
||||
|
||||
first = RecoverPixel(*reinterpret_cast<uint32_t*>(blackData),
|
||||
*reinterpret_cast<uint32_t*>(whiteData));
|
||||
}
|
||||
|
||||
uint32_t deltas = 0;
|
||||
for (int32_t i = 0; i < size.height; ++i) {
|
||||
uint32_t* blackPixel = reinterpret_cast<uint32_t*>(blackData);
|
||||
const uint32_t* whitePixel = reinterpret_cast<uint32_t*>(whiteData);
|
||||
for (int32_t j = 0; j < size.width; ++j) {
|
||||
uint32_t recovered = RecoverPixel(blackPixel[j], whitePixel[j]);
|
||||
blackPixel[j] = recovered;
|
||||
deltas |= (first ^ recovered);
|
||||
}
|
||||
blackData += blackSurf->Stride();
|
||||
whiteData += whiteSurf->Stride();
|
||||
}
|
||||
|
||||
blackSurf->MarkDirty();
|
||||
|
||||
if (analysis) {
|
||||
analysis->uniformAlpha = (deltas >> 24) == 0;
|
||||
analysis->uniformColor = false;
|
||||
if (analysis->uniformAlpha) {
|
||||
double d_first_alpha = first >> 24;
|
||||
analysis->alpha = d_first_alpha/255.0;
|
||||
/* we only set uniformColor when the alpha is already uniform.
|
||||
it's only useful in that case ... and if the alpha was nonuniform
|
||||
then computing whether the color is uniform would require unpremultiplying
|
||||
every pixel */
|
||||
analysis->uniformColor = deltas == 0;
|
||||
if (analysis->uniformColor) {
|
||||
if (d_first_alpha == 0.0) {
|
||||
/* can't unpremultiply, this is OK */
|
||||
analysis->r = analysis->g = analysis->b = 0.0;
|
||||
} else {
|
||||
analysis->r = (first & 0xFF)/d_first_alpha;
|
||||
analysis->g = ((first >> 8) & 0xFF)/d_first_alpha;
|
||||
analysis->b = ((first >> 16) & 0xFF)/d_first_alpha;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -15,13 +15,6 @@ class gfxImageSurface;
|
||||
|
||||
class gfxAlphaRecovery {
|
||||
public:
|
||||
struct Analysis {
|
||||
bool uniformColor;
|
||||
bool uniformAlpha;
|
||||
gfxFloat alpha;
|
||||
gfxFloat r, g, b;
|
||||
};
|
||||
|
||||
/**
|
||||
* Some SIMD fast-paths only can be taken if the relative
|
||||
* byte-alignment of images' pointers and strides meets certain
|
||||
@ -39,8 +32,7 @@ public:
|
||||
* Returns true on success.
|
||||
*/
|
||||
static bool RecoverAlpha (gfxImageSurface *blackSurface,
|
||||
const gfxImageSurface *whiteSurface,
|
||||
Analysis *analysis = nullptr);
|
||||
const gfxImageSurface *whiteSurface);
|
||||
|
||||
#ifdef MOZILLA_MAY_SUPPORT_SSE2
|
||||
/* This does the same as the previous function, but uses SSE2
|
||||
|
@ -611,7 +611,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size,
|
||||
|
||||
if (blackImage->CairoStatus() == CAIRO_STATUS_SUCCESS &&
|
||||
whiteImage->CairoStatus() == CAIRO_STATUS_SUCCESS) {
|
||||
if (!gfxAlphaRecovery::RecoverAlpha(blackImage, whiteImage, nullptr)) {
|
||||
if (!gfxAlphaRecovery::RecoverAlpha(blackImage, whiteImage)) {
|
||||
cairo_surface_destroy(tempXlibSurface);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user