mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 556487 - Subimage API. r=roc a=blocking2.0
This commit is contained in:
parent
39bc8e0957
commit
346c73181d
@ -192,3 +192,27 @@ gfxImageSurface::CopyFrom(gfxImageSurface *other)
|
|||||||
|
|
||||||
return PR_TRUE;
|
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.
|
// 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
|
* 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,
|
* 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 */
|
/* Fast copy from another image surface; returns TRUE if successful, FALSE otherwise */
|
||||||
PRBool CopyFrom (gfxImageSurface *other);
|
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:
|
protected:
|
||||||
gfxImageSurface();
|
gfxImageSurface();
|
||||||
void InitFromSurface(cairo_surface_t *csurf);
|
void InitFromSurface(cairo_surface_t *csurf);
|
||||||
@ -111,4 +118,14 @@ protected:
|
|||||||
long mStride;
|
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 */
|
#endif /* GFX_IMAGESURFACE_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user