mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1006198 - Remove a bunch of dead Thebes code. r=jgilbert
This commit is contained in:
parent
7c56899084
commit
6f4fe5f50f
@ -327,188 +327,6 @@ GuessAlignment(int width, int pixelSize, int rowStride)
|
||||
return alignment;
|
||||
}
|
||||
|
||||
void
|
||||
ReadPixelsIntoImageSurface(GLContext* gl, gfxImageSurface* dest) {
|
||||
gl->MakeCurrent();
|
||||
MOZ_ASSERT(dest->GetSize() != gfxIntSize(0, 0));
|
||||
|
||||
/* gfxImageFormat::ARGB32:
|
||||
* RGBA+UByte: be[RGBA], le[ABGR]
|
||||
* RGBA+UInt: be[ABGR], le[RGBA]
|
||||
* BGRA+UInt: be[ARGB], le[BGRA]
|
||||
* BGRA+UIntRev: be[BGRA], le[ARGB]
|
||||
*
|
||||
* gfxImageFormat::RGB16_565:
|
||||
* RGB+UShort: le[rrrrrggg,gggbbbbb]
|
||||
*/
|
||||
bool hasAlpha = dest->Format() == gfxImageFormat::ARGB32;
|
||||
|
||||
int destPixelSize;
|
||||
GLenum destFormat;
|
||||
GLenum destType;
|
||||
|
||||
switch (dest->Format()) {
|
||||
case gfxImageFormat::RGB24: // XRGB
|
||||
case gfxImageFormat::ARGB32:
|
||||
destPixelSize = 4;
|
||||
// Needs host (little) endian ARGB.
|
||||
destFormat = LOCAL_GL_BGRA;
|
||||
destType = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
break;
|
||||
|
||||
case gfxImageFormat::RGB16_565:
|
||||
destPixelSize = 2;
|
||||
destFormat = LOCAL_GL_RGB;
|
||||
destType = LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV;
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Bad format.");
|
||||
}
|
||||
MOZ_ASSERT(dest->Width() * destPixelSize <= dest->Stride());
|
||||
|
||||
GLenum readFormat = destFormat;
|
||||
GLenum readType = destType;
|
||||
bool needsTempSurf = !GetActualReadFormats(gl,
|
||||
destFormat, destType,
|
||||
readFormat, readType);
|
||||
|
||||
nsAutoPtr<gfxImageSurface> tempSurf;
|
||||
gfxImageSurface* readSurf = nullptr;
|
||||
|
||||
// Figure out alignment. We don't need to know why, we just need it
|
||||
// to be valid.
|
||||
int readAlignment = GuessAlignment(dest->Width(),
|
||||
destPixelSize,
|
||||
dest->Stride());
|
||||
if (!readAlignment) // Couldn't calculate a valid alignment.
|
||||
needsTempSurf = true;
|
||||
|
||||
if (!needsTempSurf) {
|
||||
readSurf = dest;
|
||||
} else {
|
||||
if (gl->DebugMode()) {
|
||||
NS_WARNING("Needing intermediary surface for ReadPixels. This will be slow!");
|
||||
}
|
||||
SurfaceFormat readFormatGFX;
|
||||
|
||||
switch (readFormat) {
|
||||
case LOCAL_GL_RGBA:
|
||||
case LOCAL_GL_BGRA: {
|
||||
readFormatGFX = hasAlpha ? SurfaceFormat::B8G8R8A8
|
||||
: SurfaceFormat::B8G8R8X8;
|
||||
break;
|
||||
}
|
||||
case LOCAL_GL_RGB: {
|
||||
MOZ_ASSERT(destPixelSize == 2);
|
||||
MOZ_ASSERT(readType == LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV);
|
||||
readFormatGFX = SurfaceFormat::R5G6B5;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
MOZ_CRASH("Bad read format.");
|
||||
}
|
||||
}
|
||||
|
||||
switch (readType) {
|
||||
case LOCAL_GL_UNSIGNED_BYTE: {
|
||||
MOZ_ASSERT(readFormat == LOCAL_GL_RGBA);
|
||||
readAlignment = 1;
|
||||
break;
|
||||
}
|
||||
case LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV: {
|
||||
MOZ_ASSERT(readFormat == LOCAL_GL_BGRA);
|
||||
readAlignment = 4;
|
||||
break;
|
||||
}
|
||||
case LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV: {
|
||||
MOZ_ASSERT(readFormat == LOCAL_GL_RGB);
|
||||
readAlignment = 2;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
MOZ_CRASH("Bad read type.");
|
||||
}
|
||||
}
|
||||
|
||||
tempSurf = new gfxImageSurface(dest->GetSize(),
|
||||
SurfaceFormatToImageFormat(readFormatGFX),
|
||||
false);
|
||||
readSurf = tempSurf;
|
||||
}
|
||||
MOZ_ASSERT(readAlignment);
|
||||
|
||||
GLint currentPackAlignment = 0;
|
||||
gl->fGetIntegerv(LOCAL_GL_PACK_ALIGNMENT, ¤tPackAlignment);
|
||||
|
||||
if (currentPackAlignment != readAlignment)
|
||||
gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, readAlignment);
|
||||
|
||||
GLsizei width = dest->Width();
|
||||
GLsizei height = dest->Height();
|
||||
|
||||
readSurf->Flush();
|
||||
gl->fReadPixels(0, 0,
|
||||
width, height,
|
||||
readFormat, readType,
|
||||
readSurf->Data());
|
||||
readSurf->MarkDirty();
|
||||
|
||||
if (currentPackAlignment != readAlignment)
|
||||
gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, currentPackAlignment);
|
||||
|
||||
if (readSurf != dest) {
|
||||
MOZ_ASSERT(readFormat == LOCAL_GL_RGBA);
|
||||
MOZ_ASSERT(readType == LOCAL_GL_UNSIGNED_BYTE);
|
||||
// So we just copied in RGBA in big endian, or le: 0xAABBGGRR.
|
||||
// We want 0xAARRGGBB, so swap R and B:
|
||||
dest->Flush();
|
||||
RefPtr<DataSourceSurface> readDSurf =
|
||||
Factory::CreateWrappingDataSourceSurface(readSurf->Data(),
|
||||
readSurf->Stride(),
|
||||
ToIntSize(readSurf->GetSize()),
|
||||
ImageFormatToSurfaceFormat(readSurf->Format()));
|
||||
SwapRAndBComponents(readDSurf);
|
||||
dest->MarkDirty();
|
||||
|
||||
gfxContext ctx(dest);
|
||||
ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
ctx.SetSource(readSurf);
|
||||
ctx.Paint();
|
||||
}
|
||||
|
||||
// Check if GL is giving back 1.0 alpha for
|
||||
// RGBA reads to RGBA images from no-alpha buffers.
|
||||
#ifdef XP_MACOSX
|
||||
if (gl->WorkAroundDriverBugs() &&
|
||||
gl->Vendor() == gl::GLVendor::NVIDIA &&
|
||||
dest->Format() == gfxImageFormat::ARGB32 &&
|
||||
width && height)
|
||||
{
|
||||
GLint alphaBits = 0;
|
||||
gl->fGetIntegerv(LOCAL_GL_ALPHA_BITS, &alphaBits);
|
||||
if (!alphaBits) {
|
||||
const uint32_t alphaMask = gfxPackedPixelNoPreMultiply(0xff,0,0,0);
|
||||
|
||||
MOZ_ASSERT(dest->Width() * destPixelSize == dest->Stride());
|
||||
|
||||
dest->Flush();
|
||||
uint32_t* itr = (uint32_t*)dest->Data();
|
||||
uint32_t testPixel = *itr;
|
||||
if ((testPixel & alphaMask) != alphaMask) {
|
||||
// We need to set the alpha channel to 1.0 manually.
|
||||
uint32_t* itrEnd = itr + width*height; // Stride is guaranteed to be width*4.
|
||||
|
||||
for (; itr != itrEnd; itr++) {
|
||||
*itr |= alphaMask;
|
||||
}
|
||||
}
|
||||
dest->MarkDirty();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest) {
|
||||
gl->MakeCurrent();
|
||||
@ -735,14 +553,6 @@ ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, SurfaceFormat aFo
|
||||
return surf.forget();
|
||||
}
|
||||
|
||||
void
|
||||
ReadScreenIntoImageSurface(GLContext* gl, gfxImageSurface* dest)
|
||||
{
|
||||
ScopedBindFramebuffer autoFB(gl, 0);
|
||||
ReadPixelsIntoImageSurface(gl, dest);
|
||||
}
|
||||
|
||||
|
||||
#define CLEANUP_IF_GLERROR_OCCURRED(x) \
|
||||
if (DidGLErrorOccur(x)) { \
|
||||
isurf = nullptr; \
|
||||
|
@ -26,8 +26,6 @@ namespace gl {
|
||||
|
||||
void ReadPixelsIntoDataSurface(GLContext* aGL,
|
||||
gfx::DataSourceSurface* aSurface);
|
||||
void ReadPixelsIntoImageSurface(GLContext* aGL, gfxImageSurface* aSurface);
|
||||
void ReadScreenIntoImageSurface(GLContext* aGL, gfxImageSurface* aSurface);
|
||||
|
||||
TemporaryRef<gfx::DataSourceSurface>
|
||||
ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, gfx::SurfaceFormat aFormat);
|
||||
|
@ -1,101 +0,0 @@
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 "LayerUtils.h"
|
||||
#include "PremultiplyTables.h"
|
||||
#include "mozilla/Endian.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
static inline const uint8_t PremultiplyValue(uint8_t a, uint8_t v) {
|
||||
return PremultiplyTable[a*256+v];
|
||||
}
|
||||
|
||||
static inline const uint8_t UnpremultiplyValue(uint8_t a, uint8_t v) {
|
||||
return UnpremultiplyTable[a*256+v];
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static bool IsLittleEndian()
|
||||
{
|
||||
// Violate strict aliasing, because violating strict aliasing is how
|
||||
// we always pack and unpack between uint32_t and uint8_t[].
|
||||
uint16_t testShort;
|
||||
static const uint8_t testBytes[2] = { 0xAA, 0xBB };
|
||||
memcpy(&testShort, testBytes, sizeof(testBytes));
|
||||
return testShort == 0xBBAA;
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
#ifdef MOZ_LITTLE_ENDIAN
|
||||
#define ASSERT_ENDIAN() MOZ_ASSERT(IsLittleEndian(), "Defined as little endian, but actually big!")
|
||||
#else
|
||||
#define ASSERT_ENDIAN() MOZ_ASSERT(!IsLittleEndian(), "Defined as big endian, but actually little!")
|
||||
#endif
|
||||
|
||||
void
|
||||
PremultiplySurface(DataSourceSurface* srcSurface,
|
||||
DataSourceSurface* destSurface)
|
||||
{
|
||||
if (!destSurface)
|
||||
destSurface = srcSurface;
|
||||
|
||||
IntSize srcSize = srcSurface->GetSize();
|
||||
MOZ_ASSERT(srcSurface->GetFormat() == destSurface->GetFormat() &&
|
||||
srcSize.width == destSurface->GetSize().width &&
|
||||
srcSize.height == destSurface->GetSize().height &&
|
||||
srcSurface->Stride() == destSurface->Stride(),
|
||||
"Source and destination surfaces don't have identical characteristics");
|
||||
|
||||
MOZ_ASSERT(srcSurface->Stride() == srcSize.width * 4,
|
||||
"Source surface stride isn't tightly packed");
|
||||
|
||||
// Only premultiply ARGB32
|
||||
if (srcSurface->GetFormat() != SurfaceFormat::B8G8R8A8) {
|
||||
if (destSurface != srcSurface) {
|
||||
memcpy(destSurface->GetData(), srcSurface->GetData(),
|
||||
srcSurface->Stride() * srcSize.height);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t *src = srcSurface->GetData();
|
||||
uint8_t *dst = destSurface->GetData();
|
||||
|
||||
// Assert that our endian define is correct.
|
||||
ASSERT_ENDIAN();
|
||||
|
||||
uint32_t dim = srcSize.width * srcSize.height;
|
||||
for (uint32_t i = 0; i < dim; ++i) {
|
||||
#ifdef MOZ_LITTLE_ENDIAN
|
||||
uint8_t b = *src++;
|
||||
uint8_t g = *src++;
|
||||
uint8_t r = *src++;
|
||||
uint8_t a = *src++;
|
||||
|
||||
*dst++ = PremultiplyValue(a, b);
|
||||
*dst++ = PremultiplyValue(a, g);
|
||||
*dst++ = PremultiplyValue(a, r);
|
||||
*dst++ = a;
|
||||
#else
|
||||
uint8_t a = *src++;
|
||||
uint8_t r = *src++;
|
||||
uint8_t g = *src++;
|
||||
uint8_t b = *src++;
|
||||
|
||||
*dst++ = a;
|
||||
*dst++ = PremultiplyValue(a, r);
|
||||
*dst++ = PremultiplyValue(a, g);
|
||||
*dst++ = PremultiplyValue(a, b);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
#ifndef MOZILLA_LAYERS_LAYERUTILS_H_
|
||||
#define MOZILLA_LAYERS_LAYERUTILS_H_
|
||||
|
||||
#include "mozilla/gfx/2D.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
void
|
||||
PremultiplySurface(gfx::DataSourceSurface* srcSurface,
|
||||
gfx::DataSourceSurface* destSurface = nullptr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_LAYERS_LAYERUTILS_H_ */
|
@ -294,7 +294,6 @@ UNIFIED_SOURCES += [
|
||||
'LayerScope.cpp',
|
||||
'LayersLogging.cpp',
|
||||
'LayerSorter.cpp',
|
||||
'LayerUtils.cpp',
|
||||
'opengl/CompositingRenderTargetOGL.cpp',
|
||||
'opengl/CompositorOGL.cpp',
|
||||
'opengl/OGLShaderProgram.cpp',
|
||||
|
@ -35,60 +35,6 @@ static const uint8_t UnpremultiplyValue(uint8_t a, uint8_t v) {
|
||||
return gfxUtils::sUnpremultiplyTable[a*256+v];
|
||||
}
|
||||
|
||||
void
|
||||
gfxUtils::PremultiplyImageSurface(gfxImageSurface *aSourceSurface,
|
||||
gfxImageSurface *aDestSurface)
|
||||
{
|
||||
if (!aDestSurface)
|
||||
aDestSurface = aSourceSurface;
|
||||
|
||||
MOZ_ASSERT(aSourceSurface->Format() == aDestSurface->Format() &&
|
||||
aSourceSurface->Width() == aDestSurface->Width() &&
|
||||
aSourceSurface->Height() == aDestSurface->Height() &&
|
||||
aSourceSurface->Stride() == aDestSurface->Stride(),
|
||||
"Source and destination surfaces don't have identical characteristics");
|
||||
|
||||
MOZ_ASSERT(aSourceSurface->Stride() == aSourceSurface->Width() * 4,
|
||||
"Source surface stride isn't tightly packed");
|
||||
|
||||
// Only premultiply ARGB32
|
||||
if (aSourceSurface->Format() != gfxImageFormat::ARGB32) {
|
||||
if (aDestSurface != aSourceSurface) {
|
||||
memcpy(aDestSurface->Data(), aSourceSurface->Data(),
|
||||
aSourceSurface->Stride() * aSourceSurface->Height());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t *src = aSourceSurface->Data();
|
||||
uint8_t *dst = aDestSurface->Data();
|
||||
|
||||
uint32_t dim = aSourceSurface->Width() * aSourceSurface->Height();
|
||||
for (uint32_t i = 0; i < dim; ++i) {
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
uint8_t b = *src++;
|
||||
uint8_t g = *src++;
|
||||
uint8_t r = *src++;
|
||||
uint8_t a = *src++;
|
||||
|
||||
*dst++ = PremultiplyValue(a, b);
|
||||
*dst++ = PremultiplyValue(a, g);
|
||||
*dst++ = PremultiplyValue(a, r);
|
||||
*dst++ = a;
|
||||
#else
|
||||
uint8_t a = *src++;
|
||||
uint8_t r = *src++;
|
||||
uint8_t g = *src++;
|
||||
uint8_t b = *src++;
|
||||
|
||||
*dst++ = a;
|
||||
*dst++ = PremultiplyValue(a, r);
|
||||
*dst++ = PremultiplyValue(a, g);
|
||||
*dst++ = PremultiplyValue(a, b);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxUtils::PremultiplyDataSurface(DataSourceSurface *aSurface)
|
||||
{
|
||||
@ -135,59 +81,6 @@ gfxUtils::PremultiplyDataSurface(DataSourceSurface *aSurface)
|
||||
aSurface->Unmap();
|
||||
}
|
||||
|
||||
void
|
||||
gfxUtils::UnpremultiplyImageSurface(gfxImageSurface *aSourceSurface,
|
||||
gfxImageSurface *aDestSurface)
|
||||
{
|
||||
if (!aDestSurface)
|
||||
aDestSurface = aSourceSurface;
|
||||
|
||||
MOZ_ASSERT(aSourceSurface->Format() == aDestSurface->Format() &&
|
||||
aSourceSurface->Width() == aDestSurface->Width() &&
|
||||
aSourceSurface->Height() == aDestSurface->Height(),
|
||||
"Source and destination surfaces don't have identical characteristics");
|
||||
|
||||
// Only premultiply ARGB32
|
||||
if (aSourceSurface->Format() != gfxImageFormat::ARGB32) {
|
||||
if (aDestSurface != aSourceSurface) {
|
||||
aDestSurface->CopyFrom(aSourceSurface);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t *src = aSourceSurface->Data();
|
||||
uint8_t *dst = aDestSurface->Data();
|
||||
|
||||
for (int32_t i = 0; i < aSourceSurface->Height(); ++i) {
|
||||
uint8_t *srcRow = src + (i * aSourceSurface->Stride());
|
||||
uint8_t *dstRow = dst + (i * aDestSurface->Stride());
|
||||
|
||||
for (int32_t j = 0; j < aSourceSurface->Width(); ++j) {
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
uint8_t b = *srcRow++;
|
||||
uint8_t g = *srcRow++;
|
||||
uint8_t r = *srcRow++;
|
||||
uint8_t a = *srcRow++;
|
||||
|
||||
*dstRow++ = UnpremultiplyValue(a, b);
|
||||
*dstRow++ = UnpremultiplyValue(a, g);
|
||||
*dstRow++ = UnpremultiplyValue(a, r);
|
||||
*dstRow++ = a;
|
||||
#else
|
||||
uint8_t a = *srcRow++;
|
||||
uint8_t r = *srcRow++;
|
||||
uint8_t g = *srcRow++;
|
||||
uint8_t b = *srcRow++;
|
||||
|
||||
*dstRow++ = a;
|
||||
*dstRow++ = UnpremultiplyValue(a, r);
|
||||
*dstRow++ = UnpremultiplyValue(a, g);
|
||||
*dstRow++ = UnpremultiplyValue(a, b);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TemporaryRef<DataSourceSurface>
|
||||
gfxUtils::UnpremultiplyDataSurface(DataSourceSurface* aSurface)
|
||||
{
|
||||
|
@ -40,11 +40,7 @@ public:
|
||||
* If the source is not gfxImageFormat::ARGB32, no operation is performed. If
|
||||
* aDestSurface is given, the data is copied over.
|
||||
*/
|
||||
static void PremultiplyImageSurface(gfxImageSurface *aSourceSurface,
|
||||
gfxImageSurface *aDestSurface = nullptr);
|
||||
static void PremultiplyDataSurface(DataSourceSurface *aSurface);
|
||||
static void UnpremultiplyImageSurface(gfxImageSurface *aSurface,
|
||||
gfxImageSurface *aDestSurface = nullptr);
|
||||
static mozilla::TemporaryRef<DataSourceSurface> UnpremultiplyDataSurface(DataSourceSurface* aSurface);
|
||||
|
||||
static void ConvertBGRAtoRGBA(gfxImageSurface *aSourceSurface,
|
||||
|
Loading…
Reference in New Issue
Block a user