mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-03 22:07:30 +09:00
[widget] Properly test for and handle errors in target-surface creation and mapping.
This commit is contained in:
parent
cc6b0f11e7
commit
bca689b483
1 changed files with 18 additions and 11 deletions
|
|
@ -355,32 +355,38 @@ TaskbarPreviewCallback::Done(nsISupports *aCanvas, bool aDrawBorder) {
|
||||||
}
|
}
|
||||||
RefPtr<gfxWindowsSurface> target = new gfxWindowsSurface(source->GetSize(),
|
RefPtr<gfxWindowsSurface> target = new gfxWindowsSurface(source->GetSize(),
|
||||||
gfx::SurfaceFormat::A8R8G8B8_UINT32);
|
gfx::SurfaceFormat::A8R8G8B8_UINT32);
|
||||||
if (!target) {
|
if (target->CairoStatus() != CAIRO_STATUS_SUCCESS) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<gfx::DataSourceSurface> srcSurface = source->GetDataSurface();
|
using DataSrcSurf = gfx::DataSourceSurface;
|
||||||
|
RefPtr<DataSrcSurf> srcSurface = source->GetDataSurface();
|
||||||
RefPtr<gfxImageSurface> imageSurface = target->GetAsImageSurface();
|
RefPtr<gfxImageSurface> imageSurface = target->GetAsImageSurface();
|
||||||
if (!srcSurface || !imageSurface) {
|
if (!srcSurface || !imageSurface) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::DataSourceSurface::MappedSurface sourceMap;
|
DataSrcSurf::ScopedMap const sourceMap(srcSurface, DataSrcSurf::READ);
|
||||||
srcSurface->Map(gfx::DataSourceSurface::READ, &sourceMap);
|
if (sourceMap.IsMapped()) {
|
||||||
mozilla::gfx::CopySurfaceDataToPackedArray(sourceMap.mData,
|
mozilla::gfx::CopySurfaceDataToPackedArray(sourceMap.GetData(),
|
||||||
imageSurface->Data(),
|
imageSurface->Data(),
|
||||||
srcSurface->GetSize(),
|
srcSurface->GetSize(),
|
||||||
sourceMap.mStride,
|
sourceMap.GetStride(),
|
||||||
BytesPerPixel(srcSurface->GetFormat()));
|
BytesPerPixel(srcSurface->GetFormat()));
|
||||||
srcSurface->Unmap();
|
} else if (source->GetSize().IsEmpty()) {
|
||||||
|
// A zero-size source-surface probably shouldn't happen, but is harmless
|
||||||
|
// here. Fall through.
|
||||||
|
} else {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
HDC hDC = target->GetDC();
|
HDC hDC = target->GetDC();
|
||||||
HBITMAP hBitmap = (HBITMAP)GetCurrentObject(hDC, OBJ_BITMAP);
|
HBITMAP hBitmap = (HBITMAP)GetCurrentObject(hDC, OBJ_BITMAP);
|
||||||
|
|
||||||
DWORD flags = aDrawBorder ? DWM_SIT_DISPLAYFRAME : 0;
|
DWORD flags = aDrawBorder ? DWM_SIT_DISPLAYFRAME : 0;
|
||||||
POINT pptClient = { 0, 0 };
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
if (!mIsThumbnail) {
|
if (!mIsThumbnail) {
|
||||||
|
POINT pptClient = { 0, 0 };
|
||||||
hr = WinUtils::dwmSetIconicLivePreviewBitmapPtr(mPreview->PreviewWindow(),
|
hr = WinUtils::dwmSetIconicLivePreviewBitmapPtr(mPreview->PreviewWindow(),
|
||||||
hBitmap, &pptClient, flags);
|
hBitmap, &pptClient, flags);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -388,6 +394,7 @@ TaskbarPreviewCallback::Done(nsISupports *aCanvas, bool aDrawBorder) {
|
||||||
hBitmap, flags);
|
hBitmap, flags);
|
||||||
}
|
}
|
||||||
MOZ_ASSERT(SUCCEEDED(hr));
|
MOZ_ASSERT(SUCCEEDED(hr));
|
||||||
|
mozilla::Unused << hr;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue