Bug 1522021. Implement SourceSurfaceOffset. r=mstange

This forwards to an underlying source surface but also has an origin that it
uses to correctly return results from GetRect()

Differential Revision: https://phabricator.services.mozilla.com/D17692

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jeff Muizelaar 2019-01-25 23:06:24 +00:00
parent b0d9cc5e6d
commit 93752e905d
3 changed files with 18 additions and 2 deletions

View File

@ -25,7 +25,7 @@ bool DrawTargetOffset::Init(DrawTarget* aDrawTarget, IntPoint aOrigin) {
}
already_AddRefed<SourceSurface> DrawTargetOffset::Snapshot() {
return mDrawTarget->Snapshot();
return MakeAndAddRef<SourceSurfaceOffset>(mDrawTarget->Snapshot(), mOrigin);
}
void DrawTargetOffset::DetachAllSnapshots() {}

View File

@ -19,6 +19,21 @@
namespace mozilla {
namespace gfx {
class SourceSurfaceOffset: public SourceSurface {
public:
SourceSurfaceOffset(RefPtr<SourceSurface> aSurface, IntPoint aOffset) :
mSurface(aSurface),
mOffset(aOffset) {}
virtual SurfaceType GetType() const override { return SurfaceType::OFFSET; }
virtual IntSize GetSize() const override { return mSurface->GetSize(); }
virtual IntRect GetRect() const override { return IntRect(mOffset, mSurface->GetSize()); }
virtual SurfaceFormat GetFormat() const override { return mSurface->GetFormat(); }
virtual already_AddRefed<DataSourceSurface> GetDataSurface() override { return mSurface->GetDataSurface(); }
private:
RefPtr<SourceSurface> mSurface;
IntPoint mOffset;
};
class DrawTargetOffset : public DrawTarget {
public:
DrawTargetOffset();

View File

@ -34,7 +34,8 @@ enum class SurfaceType : int8_t {
TILED, /* Surface from a tiled DrawTarget */
DATA_SHARED, /* Data surface using shared memory */
CAPTURE, /* Data from a DrawTargetCapture */
DATA_RECYCLING_SHARED /* Data surface using shared memory */
DATA_RECYCLING_SHARED, /* Data surface using shared memory */
OFFSET, /* Offset */
};
enum class SurfaceFormat : int8_t {