Bug 1019681 - Remove gfxASurface's MovePixels() and FastMovePixels() methods and their overrides. r=Bas

--HG--
extra : rebase_source : 49445275b3b6ad94ffb2f9f4375e6a81ebf2842c
This commit is contained in:
Jonathan Watt 2014-06-05 01:03:07 +01:00
Родитель dd0a3a7c18
Коммит 72dfb5131d
7 изменённых файлов: 0 добавлений и 155 удалений

Просмотреть файл

@ -525,52 +525,6 @@ gfxASurface::BytePerPixelFromFormat(gfxImageFormat format)
return 0;
}
void
gfxASurface::FastMovePixels(const nsIntRect& aSourceRect,
const nsIntPoint& aDestTopLeft)
{
// Used when the backend can internally handle self copies.
nsIntRect dest(aDestTopLeft, aSourceRect.Size());
nsRefPtr<gfxContext> ctx = new gfxContext(this);
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
nsIntPoint srcOrigin = dest.TopLeft() - aSourceRect.TopLeft();
ctx->SetSource(this, gfxPoint(srcOrigin.x, srcOrigin.y));
ctx->Rectangle(gfxRect(dest.x, dest.y, dest.width, dest.height));
ctx->Fill();
}
void
gfxASurface::MovePixels(const nsIntRect& aSourceRect,
const nsIntPoint& aDestTopLeft)
{
// Assume the backend can't handle self copying well and allocate
// a temporary surface instead.
nsRefPtr<gfxASurface> tmp =
CreateSimilarSurface(GetContentType(),
nsIntSize(aSourceRect.width, aSourceRect.height));
// CreateSimilarSurface can return nullptr if the current surface is
// in an error state. This isn't good, but its better to carry
// on with the error surface instead of crashing.
NS_WARN_IF_FALSE(tmp, "Must have temporary surface to move pixels!");
if (!tmp) {
return;
}
nsRefPtr<gfxContext> ctx = new gfxContext(tmp);
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
ctx->SetSource(this, gfxPoint(-aSourceRect.x, -aSourceRect.y));
ctx->Paint();
ctx = new gfxContext(this);
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
ctx->SetSource(tmp, gfxPoint(aDestTopLeft.x, aDestTopLeft.y));
ctx->Rectangle(gfxRect(aDestTopLeft.x,
aDestTopLeft.y,
aSourceRect.width,
aSourceRect.height));
ctx->Fill();
}
/** Memory reporting **/
static const char *sDefaultSurfaceDescription =

Просмотреть файл

@ -209,19 +209,6 @@ public:
return GetEmptyOpaqueRect();
}
/**
* Move the pixels in |aSourceRect| to |aDestTopLeft|. Like with
* memmove(), |aSourceRect| and the rectangle defined by
* |aDestTopLeft| are allowed to overlap, and the effect is
* equivalent to copying |aSourceRect| to a scratch surface and
* then back to |aDestTopLeft|.
*
* |aSourceRect| and the destination rectangle defined by
* |aDestTopLeft| are clipped to this surface's bounds.
*/
virtual void MovePixels(const nsIntRect& aSourceRect,
const nsIntPoint& aDestTopLeft);
/**
* Mark the surface as being allowed/not allowed to be used as a source.
*/
@ -236,14 +223,6 @@ protected:
static gfxASurface* GetSurfaceWrapper(cairo_surface_t *csurf);
static void SetSurfaceWrapper(cairo_surface_t *csurf, gfxASurface *asurf);
/**
* An implementation of MovePixels that assumes the backend can
* internally handle this operation and doesn't allocate any
* temporary surfaces.
*/
void FastMovePixels(const nsIntRect& aSourceRect,
const nsIntPoint& aDestTopLeft);
// NB: Init() *must* be called from within subclass's
// constructors. It's unsafe to call it after the ctor finishes;
// leaks and use-after-frees are possible.

Просмотреть файл

@ -29,12 +29,6 @@ public:
gfxD2DSurface(cairo_surface_t *csurf);
void MovePixels(const nsIntRect& aSourceRect,
const nsIntPoint& aDestTopLeft)
{
FastMovePixels(aSourceRect, aDestTopLeft);
}
virtual ~gfxD2DSurface();
void Present();

Просмотреть файл

@ -371,70 +371,3 @@ gfxImageSurface::GetAsImageSurface()
nsRefPtr<gfxImageSurface> surface = this;
return surface.forget();
}
void
gfxImageSurface::MovePixels(const nsIntRect& aSourceRect,
const nsIntPoint& aDestTopLeft)
{
const nsIntRect bounds(0, 0, mSize.width, mSize.height);
nsIntPoint offset = aDestTopLeft - aSourceRect.TopLeft();
nsIntRect clippedSource = aSourceRect;
clippedSource.IntersectRect(clippedSource, bounds);
nsIntRect clippedDest = clippedSource + offset;
clippedDest.IntersectRect(clippedDest, bounds);
const nsIntRect dest = clippedDest;
const nsIntRect source = dest - offset;
// NB: this relies on IntersectRect() and operator+/- preserving
// x/y for empty rectangles
NS_ABORT_IF_FALSE(bounds.Contains(dest) && bounds.Contains(source) &&
aSourceRect.Contains(source) &&
nsIntRect(aDestTopLeft, aSourceRect.Size()).Contains(dest) &&
source.Size() == dest.Size() &&
offset == (dest.TopLeft() - source.TopLeft()),
"Messed up clipping, crash or corruption will follow");
if (source.IsEmpty() || source.IsEqualInterior(dest)) {
return;
}
long naturalStride = ComputeStride(mSize, mFormat);
if (mStride == naturalStride && dest.width == bounds.width) {
// Fast path: this is a vertical shift of some rows in a
// "normal" image surface. We can directly memmove and
// hopefully stay in SIMD land.
unsigned char* dst = mData + dest.y * mStride;
const unsigned char* src = mData + source.y * mStride;
size_t nBytes = dest.height * mStride;
memmove(dst, src, nBytes);
return;
}
// Slow(er) path: have to move row-by-row.
const int32_t bpp = BytePerPixelFromFormat(mFormat);
const size_t nRowBytes = dest.width * bpp;
// dstRow points at the first pixel within the current destination
// row, and similarly for srcRow. endSrcRow is one row beyond the
// last row we need to copy. stride is either +mStride or
// -mStride, depending on which direction we're copying.
unsigned char* dstRow;
unsigned char* srcRow;
unsigned char* endSrcRow; // NB: this may point outside the image
long stride;
if (dest.y > source.y) {
// We're copying down from source to dest, so walk backwards
// starting from the last rows to avoid stomping pixels we
// need.
stride = -mStride;
dstRow = mData + dest.x * bpp + (dest.YMost() - 1) * mStride;
srcRow = mData + source.x * bpp + (source.YMost() - 1) * mStride;
endSrcRow = mData + source.x * bpp + (source.y - 1) * mStride;
} else {
stride = mStride;
dstRow = mData + dest.x * bpp + dest.y * mStride;
srcRow = mData + source.x * bpp + source.y * mStride;
endSrcRow = mData + source.x * bpp + source.YMost() * mStride;
}
for (; srcRow != endSrcRow; dstRow += stride, srcRow += stride) {
memmove(dstRow, srcRow, nRowBytes);
}
}

Просмотреть файл

@ -124,9 +124,6 @@ public:
virtual already_AddRefed<gfxImageSurface> GetAsImageSurface();
/** See gfxASurface.h. */
virtual void MovePixels(const nsIntRect& aSourceRect,
const nsIntPoint& aDestTopLeft) MOZ_OVERRIDE;
static long ComputeStride(const gfxIntSize&, gfxImageFormat);
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const

Просмотреть файл

@ -39,12 +39,6 @@ public:
already_AddRefed<gfxImageSurface> GetAsImageSurface();
void MovePixels(const nsIntRect& aSourceRect,
const nsIntPoint& aDestTopLeft)
{
FastMovePixels(aSourceRect, aDestTopLeft);
}
protected:
void MakeInvalid();

Просмотреть файл

@ -67,12 +67,6 @@ public:
const gfxIntSize GetSize() const;
void MovePixels(const nsIntRect& aSourceRect,
const nsIntPoint& aDestTopLeft)
{
FastMovePixels(aSourceRect, aDestTopLeft);
}
// The memory used by this surface lives in this process's address space,
// but not in the heap.
virtual gfxMemoryLocation GetMemoryLocation() const;