Bug 588690 - Part 2: Clear cached resources when a windows becomes inactive. r=roc a=blocking-beta5+

This commit is contained in:
Bas Schouten 2010-08-20 05:40:51 +02:00
Родитель 83c43a8e49
Коммит 0f23293c1d
2 изменённых файлов: 16 добавлений и 24 удалений

Просмотреть файл

@ -679,9 +679,9 @@ NS_METHOD nsWindow::Destroy()
}
mLayerManager = nsnull;
/* We should clear our D2D window surface now and not wait for the GC to
/* We should clear our cached resources now and not wait for the GC to
* delete the nsWindow. */
mD2DWindowSurface = nsnull;
ClearCachedResources();
// The DestroyWindow function destroys the specified window. The function sends WM_DESTROY
// and WM_NCDESTROY messages to the window to deactivate it and remove the keyboard focus
@ -1167,11 +1167,9 @@ NS_METHOD nsWindow::Show(PRBool bState)
// SetWindowPos would get the correct answer.
mIsVisible = bState;
#ifdef CAIRO_HAS_D2D_SURFACE
if (!mIsVisible && wasVisible) {
ClearD2DSurface();
ClearCachedResources();
}
#endif
if (mWnd) {
if (bState) {
@ -7936,30 +7934,28 @@ VOID CALLBACK nsWindow::HookTimerForPopups(HWND hwnd, UINT uMsg, UINT idEvent, D
}
#endif // WinCE
#ifdef CAIRO_HAS_D2D_SURFACE
BOOL CALLBACK nsWindow::ClearD2DSurfaceCallback(HWND aWnd, LPARAM aMsg)
BOOL CALLBACK nsWindow::ClearResourcesCallback(HWND aWnd, LPARAM aMsg)
{
nsWindow *window = nsWindow::GetNSWindowPtr(aWnd);
if (window) {
window->ClearD2DSurface();
window->ClearCachedResources();
}
return TRUE;
}
void
nsWindow::ClearD2DSurface()
nsWindow::ClearCachedResources()
{
#ifdef CAIRO_HAS_D2D_SURFACE
mD2DWindowSurface = nsnull;
if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() ==
gfxWindowsPlatform::RENDER_DIRECT2D) {
// The layer manager holds onto a bunch of buffers created with create
// similar surface. This can consume quite a bit of VMEM for each tab,
// if a window is hidden we clear the layer manager to conserve VRAM.
mLayerManager = nsnull;
}
::EnumChildWindows(mWnd, nsWindow::ClearD2DSurfaceCallback, NULL);
}
#endif
if (mLayerManager &&
mLayerManager->GetBackendType() == LayerManager::LAYERS_BASIC) {
static_cast<BasicLayerManager*>(mLayerManager.get())->
ClearCachedResources();
}
::EnumChildWindows(mWnd, nsWindow::ClearResourcesCallback, NULL);
}
static PRBool IsDifferentThreadWindow(HWND aWnd)
{

Просмотреть файл

@ -291,9 +291,7 @@ protected:
static LRESULT CALLBACK MozSpecialWndProc(int code, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK MozSpecialMouseProc(int code, WPARAM wParam, LPARAM lParam);
static VOID CALLBACK HookTimerForPopups( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime );
#ifdef CAIRO_HAS_D2D_SURFACE
static BOOL CALLBACK ClearD2DSurfaceCallback(HWND aChild, LPARAM aParam);
#endif
static BOOL CALLBACK ClearResourcesCallback(HWND aChild, LPARAM aParam);
/**
* Window utilities
@ -455,9 +453,7 @@ protected:
#ifdef ACCESSIBILITY
static STDMETHODIMP_(LRESULT) LresultFromObject(REFIID riid, WPARAM wParam, LPUNKNOWN pAcc);
#endif // ACCESSIBILITY
#ifdef CAIRO_HAS_D2D_SURFACE
void ClearD2DSurface();
#endif
void ClearCachedResources();
protected:
nsCOMPtr<nsIWidget> mParent;