mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1078693: Correctly indicate validity of a SourceSurfaceD2D1 and deal with failed surface creation. r=jrmuizel
This commit is contained in:
parent
7318736c2a
commit
7dcacf511a
@ -16,6 +16,7 @@ SourceSurfaceD2D1::SourceSurfaceD2D1(ID2D1Image *aImage, ID2D1DeviceContext *aDC
|
||||
: mImage(aImage)
|
||||
, mDC(aDC)
|
||||
, mDrawTarget(aDT)
|
||||
, mDevice(Factory::GetD2D1Device())
|
||||
{
|
||||
aImage->QueryInterface((ID2D1Bitmap1**)byRef(mRealizedBitmap));
|
||||
|
||||
@ -27,9 +28,17 @@ SourceSurfaceD2D1::~SourceSurfaceD2D1()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
SourceSurfaceD2D1::IsValid() const
|
||||
{
|
||||
return mDevice == Factory::GetD2D1Device();
|
||||
}
|
||||
|
||||
TemporaryRef<DataSourceSurface>
|
||||
SourceSurfaceD2D1::GetDataSurface()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
EnsureRealizedBitmap();
|
||||
|
||||
RefPtr<ID2D1Bitmap1> softwareBitmap;
|
||||
@ -40,11 +49,23 @@ SourceSurfaceD2D1::GetDataSurface()
|
||||
props.colorContext = nullptr;
|
||||
props.bitmapOptions = D2D1_BITMAP_OPTIONS_CANNOT_DRAW |
|
||||
D2D1_BITMAP_OPTIONS_CPU_READ;
|
||||
mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(softwareBitmap));
|
||||
hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(softwareBitmap));
|
||||
|
||||
if (FAILED(hr)) {
|
||||
gfxCriticalError() << "Failed to create software bitmap: " << mSize << " Code: " << hexa(hr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
D2D1_POINT_2U point = D2D1::Point2U(0, 0);
|
||||
D2D1_RECT_U rect = D2D1::RectU(0, 0, mSize.width, mSize.height);
|
||||
softwareBitmap->CopyFromBitmap(&point, mRealizedBitmap, &rect);
|
||||
|
||||
hr = softwareBitmap->CopyFromBitmap(&point, mRealizedBitmap, &rect);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
gfxWarning() << "Failed to readback into software bitmap. Code: " << hexa(hr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new DataSourceSurfaceD2D1(softwareBitmap, mFormat);
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
virtual SurfaceType GetType() const { return SurfaceType::D2D1_1_IMAGE; }
|
||||
virtual IntSize GetSize() const { return mSize; }
|
||||
virtual SurfaceFormat GetFormat() const { return mFormat; }
|
||||
virtual bool IsValid() const;
|
||||
virtual TemporaryRef<DataSourceSurface> GetDataSurface();
|
||||
|
||||
ID2D1Image *GetImage() { return mImage; }
|
||||
@ -54,6 +55,8 @@ private:
|
||||
// had a reason yet to realize ourselves.
|
||||
RefPtr<ID2D1Bitmap1> mRealizedBitmap;
|
||||
RefPtr<ID2D1DeviceContext> mDC;
|
||||
// Keep this around to verify whether out image is still valid in the future.
|
||||
RefPtr<ID2D1Device> mDevice;
|
||||
|
||||
SurfaceFormat mFormat;
|
||||
IntSize mSize;
|
||||
@ -70,6 +73,7 @@ public:
|
||||
virtual SurfaceType GetType() const { return SurfaceType::DATA; }
|
||||
virtual IntSize GetSize() const;
|
||||
virtual SurfaceFormat GetFormat() const { return mFormat; }
|
||||
virtual bool IsValid() const { return !!mBitmap; }
|
||||
virtual uint8_t *GetData();
|
||||
virtual int32_t Stride();
|
||||
virtual bool Map(MapType, MappedSurface *aMappedSurface);
|
||||
|
Loading…
Reference in New Issue
Block a user