зеркало из https://github.com/mozilla/gecko-dev.git
Bug 635035, part 3: Add gfxASurface::MovePixels() interface and generic impl. sr=roc
This commit is contained in:
Родитель
ac95b431ba
Коммит
48601a18b0
|
@ -40,9 +40,11 @@
|
|||
#include "nsMemory.h"
|
||||
|
||||
#include "gfxASurface.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "gfxImageSurface.h"
|
||||
|
||||
#include "nsRect.h"
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#ifdef CAIRO_HAS_WIN32_SURFACE
|
||||
|
@ -474,6 +476,24 @@ gfxASurface::BytePerPixelFromFormat(gfxImageFormat format)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gfxASurface::MovePixels(const nsIntRect& aSourceRect,
|
||||
const nsIntPoint& aDestTopLeft)
|
||||
{
|
||||
gfxIntSize size = GetSize();
|
||||
nsIntRect dest(aDestTopLeft, aSourceRect.Size());
|
||||
// Assume that our cairo backend already knows how to properly
|
||||
// self-copy. gfxASurface subtypes whose backend can't self-copy
|
||||
// need their own implementations, or their backends need to be
|
||||
// fixed.
|
||||
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();
|
||||
}
|
||||
|
||||
/** Memory reporting **/
|
||||
|
||||
static const char *sSurfaceNamesForSurfaceType[] = {
|
||||
|
|
|
@ -48,6 +48,8 @@ typedef struct _cairo_user_data_key cairo_user_data_key_t;
|
|||
typedef void (*thebes_destroy_func_t) (void *data);
|
||||
|
||||
class gfxImageSurface;
|
||||
struct nsIntPoint;
|
||||
struct nsIntRect;
|
||||
|
||||
/**
|
||||
* A surface is something you can draw on. Instantiate a subclass of this
|
||||
|
@ -220,6 +222,19 @@ public:
|
|||
|
||||
virtual PRBool SupportsSelfCopy() { return PR_TRUE; }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче