mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 556487 - Subimage API. r=roc a=blocking2.0
This commit is contained in:
parent
1d7bb77dc7
commit
72e503a1a5
@ -192,3 +192,27 @@ gfxImageSurface::CopyFrom(gfxImageSurface *other)
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
already_AddRefed<gfxSubimageSurface>
|
||||
gfxImageSurface::GetSubimage(const gfxRect& aRect)
|
||||
{
|
||||
gfxRect r(aRect);
|
||||
r.Round();
|
||||
unsigned char* subData = Data() +
|
||||
(Stride() * (int)r.Y()) +
|
||||
(int)r.X() * gfxASurface::BytePerPixelFromFormat(Format());
|
||||
|
||||
nsRefPtr<gfxSubimageSurface> image =
|
||||
new gfxSubimageSurface(this, subData,
|
||||
gfxIntSize((int)r.Width(), (int)r.Height()));
|
||||
|
||||
return image.forget().get();
|
||||
}
|
||||
|
||||
gfxSubimageSurface::gfxSubimageSurface(gfxImageSurface* aParent,
|
||||
unsigned char* aData,
|
||||
const gfxIntSize& aSize)
|
||||
: gfxImageSurface(aData, aSize, aParent->Stride(), aParent->Format())
|
||||
, mParent(aParent)
|
||||
{
|
||||
}
|
||||
|
@ -43,6 +43,8 @@
|
||||
|
||||
// ARGB -- raw buffer.. wont be changed.. good for storing data.
|
||||
|
||||
class gfxSubimageSurface;
|
||||
|
||||
/**
|
||||
* A raw image buffer. The format can be set in the constructor. Its main
|
||||
* purpose is for storing read-only images and using it as a source surface,
|
||||
@ -99,6 +101,11 @@ public:
|
||||
/* Fast copy from another image surface; returns TRUE if successful, FALSE otherwise */
|
||||
PRBool CopyFrom (gfxImageSurface *other);
|
||||
|
||||
/* return new Subimage with pointing to original image starting from aRect.pos
|
||||
* and size of aRect.size. New subimage keeping current image reference
|
||||
*/
|
||||
already_AddRefed<gfxSubimageSurface> GetSubimage(const gfxRect& aRect);
|
||||
|
||||
protected:
|
||||
gfxImageSurface();
|
||||
void InitFromSurface(cairo_surface_t *csurf);
|
||||
@ -111,4 +118,14 @@ protected:
|
||||
long mStride;
|
||||
};
|
||||
|
||||
class THEBES_API gfxSubimageSurface : public gfxImageSurface {
|
||||
protected:
|
||||
friend class gfxImageSurface;
|
||||
gfxSubimageSurface(gfxImageSurface* aParent,
|
||||
unsigned char* aData,
|
||||
const gfxIntSize& aSize);
|
||||
private:
|
||||
nsRefPtr<gfxImageSurface> mParent;
|
||||
};
|
||||
|
||||
#endif /* GFX_IMAGESURFACE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user