mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 13:56:29 +00:00
Bug 777700 - Part 1: Add a way to check validity of SourceSurfaces. r=jrmuizel
This commit is contained in:
parent
cb76490018
commit
6f1c5a20d8
@ -303,6 +303,13 @@ public:
|
||||
virtual IntSize GetSize() const = 0;
|
||||
virtual SurfaceFormat GetFormat() const = 0;
|
||||
|
||||
/* This returns false if some event has made this source surface invalid for
|
||||
* usage with current DrawTargets. For example in the case of Direct2D this
|
||||
* could return false if we have switched devices since this surface was
|
||||
* created.
|
||||
*/
|
||||
virtual bool IsValid() const { return true; }
|
||||
|
||||
/*
|
||||
* This function will get a DataSourceSurface for this surface, a
|
||||
* DataSourceSurface's data can be accessed directly.
|
||||
|
@ -34,6 +34,12 @@ SourceSurfaceD2D::GetFormat() const
|
||||
return mFormat;
|
||||
}
|
||||
|
||||
bool
|
||||
SourceSurfaceD2D::IsValid() const
|
||||
{
|
||||
return mDevice == Factory::GetDirect3D10Device();
|
||||
}
|
||||
|
||||
TemporaryRef<DataSourceSurface>
|
||||
SourceSurfaceD2D::GetDataSurface()
|
||||
{
|
||||
@ -68,6 +74,7 @@ SourceSurfaceD2D::InitFromData(unsigned char *aData,
|
||||
}
|
||||
|
||||
DrawTargetD2D::mVRAMUsageSS += GetByteSize();
|
||||
mDevice = Factory::GetDirect3D10Device();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -103,6 +110,7 @@ SourceSurfaceD2D::InitFromTexture(ID3D10Texture2D *aTexture,
|
||||
return false;
|
||||
}
|
||||
|
||||
aTexture->GetDevice(byRef(mDevice));
|
||||
DrawTargetD2D::mVRAMUsageSS += GetByteSize();
|
||||
|
||||
return true;
|
||||
|
@ -22,6 +22,8 @@ public:
|
||||
virtual SurfaceType GetType() const { return SURFACE_D2D1_BITMAP; }
|
||||
virtual IntSize GetSize() const;
|
||||
virtual SurfaceFormat GetFormat() const;
|
||||
virtual bool IsValid() const;
|
||||
|
||||
virtual TemporaryRef<DataSourceSurface> GetDataSurface();
|
||||
|
||||
ID2D1Bitmap *GetBitmap() { return mBitmap; }
|
||||
@ -41,6 +43,8 @@ private:
|
||||
uint32_t GetByteSize() const;
|
||||
|
||||
RefPtr<ID2D1Bitmap> mBitmap;
|
||||
// We need to keep this pointer here to check surface validity.
|
||||
RefPtr<ID3D10Device> mDevice;
|
||||
SurfaceFormat mFormat;
|
||||
IntSize mSize;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user