зеркало из https://github.com/mozilla/pjs.git
Bug 573507: Make D2D work with transparent (layered) windows by using interop to get a DC from. r=jmathies
This commit is contained in:
Родитель
cc338051a5
Коммит
aa767ed5eb
|
@ -6887,8 +6887,18 @@ void nsWindow::ResizeTranslucentWindow(PRInt32 aNewWidth, PRInt32 aNewHeight, PR
|
|||
if (!force && aNewWidth == mBounds.width && aNewHeight == mBounds.height)
|
||||
return;
|
||||
|
||||
mTransparentSurface = new gfxWindowsSurface(gfxIntSize(aNewWidth, aNewHeight), gfxASurface::ImageFormatARGB32);
|
||||
mMemoryDC = mTransparentSurface->GetDC();
|
||||
if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() ==
|
||||
gfxWindowsPlatform::RENDER_DIRECT2D) {
|
||||
nsRefPtr<gfxD2DSurface> newSurface =
|
||||
new gfxD2DSurface(gfxIntSize(aNewWidth, aNewHeight), gfxASurface::ImageFormatARGB32);
|
||||
mTransparentSurface = newSurface;
|
||||
mMemoryDC = nsnull;
|
||||
} else {
|
||||
nsRefPtr<gfxWindowsSurface> newSurface =
|
||||
new gfxWindowsSurface(gfxIntSize(aNewWidth, aNewHeight), gfxASurface::ImageFormatARGB32);
|
||||
mTransparentSurface = newSurface;
|
||||
mMemoryDC = newSurface->GetDC();
|
||||
}
|
||||
}
|
||||
|
||||
void nsWindow::SetWindowTranslucencyInner(nsTransparencyMode aMode)
|
||||
|
@ -6972,9 +6982,24 @@ nsresult nsWindow::UpdateTranslucentWindow()
|
|||
RECT winRect;
|
||||
::GetWindowRect(hWnd, &winRect);
|
||||
|
||||
if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() ==
|
||||
gfxWindowsPlatform::RENDER_DIRECT2D) {
|
||||
mMemoryDC = static_cast<gfxD2DSurface*>(mTransparentSurface.get())->
|
||||
GetDC(PR_TRUE);
|
||||
}
|
||||
// perform the alpha blend
|
||||
if (!::UpdateLayeredWindow(hWnd, NULL, (POINT*)&winRect, &winSize, mMemoryDC, &srcPos, 0, &bf, ULW_ALPHA))
|
||||
PRBool updateSuccesful =
|
||||
::UpdateLayeredWindow(hWnd, NULL, (POINT*)&winRect, &winSize, mMemoryDC, &srcPos, 0, &bf, ULW_ALPHA);
|
||||
|
||||
if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() ==
|
||||
gfxWindowsPlatform::RENDER_DIRECT2D) {
|
||||
nsIntRect r(0, 0, 0, 0);
|
||||
static_cast<gfxD2DSurface*>(mTransparentSurface.get())->ReleaseDC(&r);
|
||||
}
|
||||
|
||||
if (!updateSuccesful) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -502,7 +502,7 @@ protected:
|
|||
// Transparency
|
||||
#ifdef MOZ_XUL
|
||||
// Use layered windows to support full 256 level alpha translucency
|
||||
nsRefPtr<gfxWindowsSurface> mTransparentSurface;
|
||||
nsRefPtr<gfxASurface> mTransparentSurface;
|
||||
HDC mMemoryDC;
|
||||
nsTransparencyMode mTransparencyMode;
|
||||
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||
|
|
|
@ -416,7 +416,9 @@ PRBool nsWindow::OnPaint(HDC aDC)
|
|||
|
||||
#if defined(MOZ_XUL)
|
||||
// don't support transparency for non-GDI rendering, for now
|
||||
if (IsRenderMode(gfxWindowsPlatform::RENDER_GDI) && eTransparencyTransparent == mTransparencyMode) {
|
||||
if ((IsRenderMode(gfxWindowsPlatform::RENDER_GDI) ||
|
||||
IsRenderMode(gfxWindowsPlatform::RENDER_DIRECT2D)) &&
|
||||
eTransparencyTransparent == mTransparencyMode) {
|
||||
if (mTransparentSurface == nsnull)
|
||||
SetupTranslucentWindowMemoryBitmap(mTransparencyMode);
|
||||
targetSurface = mTransparentSurface;
|
||||
|
@ -545,7 +547,8 @@ DDRAW_FAILED:
|
|||
}
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
if (IsRenderMode(gfxWindowsPlatform::RENDER_GDI) &&
|
||||
if ((IsRenderMode(gfxWindowsPlatform::RENDER_GDI) ||
|
||||
IsRenderMode(gfxWindowsPlatform::RENDER_DIRECT2D))&&
|
||||
eTransparencyTransparent == mTransparencyMode) {
|
||||
// Data from offscreen drawing surface was copied to memory bitmap of transparent
|
||||
// bitmap. Now it can be read from memory bitmap to apply alpha channel and after
|
||||
|
|
Загрузка…
Ссылка в новой задаче