Bug 1958711 - Clean up gfxWindowsSurface. r=gfx-reviewers,nical
mWnd is always null, mOwnsDc is always false. Differential Revision: https://phabricator.services.mozilla.com/D244525
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
#include "nsString.h"
|
||||
|
||||
gfxWindowsSurface::gfxWindowsSurface(HDC dc, uint32_t flags)
|
||||
: mOwnsDC(false), mDC(dc), mWnd(nullptr) {
|
||||
: mDC(dc) {
|
||||
InitWithDC(flags);
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@ void gfxWindowsSurface::MakeInvalid(mozilla::gfx::IntSize& size) {
|
||||
}
|
||||
|
||||
gfxWindowsSurface::gfxWindowsSurface(const mozilla::gfx::IntSize& realSize,
|
||||
gfxImageFormat imageFormat)
|
||||
: mOwnsDC(false), mWnd(nullptr) {
|
||||
gfxImageFormat imageFormat) {
|
||||
mozilla::gfx::IntSize size(realSize);
|
||||
if (!mozilla::gfx::Factory::CheckSurfaceSize(size)) MakeInvalid(size);
|
||||
if (!mozilla::gfx::Factory::CheckSurfaceSize(size)) {
|
||||
MakeInvalid(size);
|
||||
}
|
||||
|
||||
cairo_format_t cformat = GfxFormatToCairoFormat(imageFormat);
|
||||
cairo_surface_t* surf =
|
||||
@@ -39,17 +40,13 @@ gfxWindowsSurface::gfxWindowsSurface(const mozilla::gfx::IntSize& realSize,
|
||||
if (CairoStatus() == CAIRO_STATUS_SUCCESS) {
|
||||
mDC = cairo_win32_surface_get_dc(CairoSurface());
|
||||
RecordMemoryUsed(size.width * size.height * 4 + sizeof(gfxWindowsSurface));
|
||||
} else {
|
||||
mDC = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
gfxWindowsSurface::gfxWindowsSurface(cairo_surface_t* csurf)
|
||||
: mOwnsDC(false), mWnd(nullptr) {
|
||||
if (cairo_surface_status(csurf) == 0)
|
||||
gfxWindowsSurface::gfxWindowsSurface(cairo_surface_t* csurf) {
|
||||
if (cairo_surface_status(csurf) == 0) {
|
||||
mDC = cairo_win32_surface_get_dc(csurf);
|
||||
else
|
||||
mDC = nullptr;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(cairo_surface_get_type(csurf) !=
|
||||
CAIRO_SURFACE_TYPE_WIN32_PRINTING);
|
||||
@@ -65,14 +62,7 @@ void gfxWindowsSurface::InitWithDC(uint32_t flags) {
|
||||
}
|
||||
}
|
||||
|
||||
gfxWindowsSurface::~gfxWindowsSurface() {
|
||||
if (mOwnsDC) {
|
||||
if (mWnd)
|
||||
::ReleaseDC(mWnd, mDC);
|
||||
else
|
||||
::DeleteDC(mDC);
|
||||
}
|
||||
}
|
||||
gfxWindowsSurface::~gfxWindowsSurface() = default;
|
||||
|
||||
HDC gfxWindowsSurface::GetDC() {
|
||||
return cairo_win32_surface_get_dc(CairoSurface());
|
||||
@@ -91,7 +81,9 @@ already_AddRefed<gfxImageSurface> gfxWindowsSurface::GetAsImageSurface() {
|
||||
"CairoSurface() shouldn't be nullptr when mSurfaceValid is TRUE!");
|
||||
|
||||
cairo_surface_t* isurf = cairo_win32_surface_get_image(CairoSurface());
|
||||
if (!isurf) return nullptr;
|
||||
if (!isurf) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<gfxImageSurface> result =
|
||||
gfxASurface::Wrap(isurf).downcast<gfxImageSurface>();
|
||||
|
||||
@@ -44,11 +44,8 @@ class gfxWindowsSurface : public gfxASurface {
|
||||
|
||||
private:
|
||||
void MakeInvalid(mozilla::gfx::IntSize& size);
|
||||
|
||||
bool mOwnsDC;
|
||||
|
||||
HDC mDC;
|
||||
HWND mWnd;
|
||||
// NOTE: the DC is _not_ owned by us.
|
||||
HDC mDC = nullptr;
|
||||
};
|
||||
|
||||
#endif /* GFX_WINDOWSSURFACE_H */
|
||||
|
||||
Reference in New Issue
Block a user