gfxOS2Surface::gfxOS2Surface(HWND aWnd) : mWnd(aWnd), mDC(nullptr), mPS(nullptr), mBitmap(nullptr) { #ifdef DEBUG_thebes_2 printf("gfxOS2Surface[%#x]::gfxOS2Surface(HWND=%#x)\n", (unsigned int)this, (unsigned int)aWnd); #endif RECTL rectl; WinQueryWindowRect(aWnd, &rectl); mSize.width = rectl.xRight - rectl.xLeft; mSize.height = rectl.yTop - rectl.yBottom; if (mSize.width == 0) mSize.width = 1; // fake a minimal surface area to let if (mSize.height == 0) mSize.height = 1; // cairo_os2_surface_create() return something // This variation on cairo_os2_surface_create() avoids creating a // persistent HPS that may never be used. It also enables manual // refresh so nsWindow::OnPaint() controls when the screen is updated. cairo_surface_t *surf = cairo_os2_surface_create_for_window(mWnd, mSize.width, mSize.height); #ifdef DEBUG_thebes_2 printf(" type(%#x)=%d (ID=%#x, h/w=%d/%d)\n", (unsigned int)surf, cairo_surface_get_type(surf), (unsigned int)mPS, mSize.width, mSize.height); #endif Init(surf); }
gfxOS2Surface::gfxOS2Surface(HWND aWnd) : mWnd(aWnd), mDC(0), mPS(0), mSize(0,0), mSurfType(os2Window) { RECTL rectl; WinQueryWindowRect(aWnd, &rectl); mSize.width = rectl.xRight - rectl.xLeft; mSize.height = rectl.yTop - rectl.yBottom; // If necessary fake a minimal surface area to let // cairo_os2_surface_create() return something. if (mSize.width == 0) mSize.width = 1; if (mSize.height == 0) mSize.height = 1; cairo_surface_t *surf = cairo_os2_surface_create_for_window(mWnd, mSize.width, mSize.height); Init(surf); RecordMemoryUsed(mSize.width * mSize.height * 4 + OS2_OVERHEAD); }