mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 736481 - 2/7 - lose WebGL context on memory-pressure events - r=jgilbert, a=blocking-fennec
This commit is contained in:
parent
7e0123bd58
commit
3c1e40fdd9
@ -71,10 +71,25 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
||||
#include "nsIObserverService.h"
|
||||
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gl;
|
||||
using namespace mozilla::layers;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(WebGLMemoryPressureObserver, nsIObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLMemoryPressureObserver::Observe(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
const PRUnichar* aSomeData)
|
||||
{
|
||||
if (strcmp(aTopic, "memory-pressure") == 0)
|
||||
mContext->ForceLoseContext();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult NS_NewCanvasRenderingContextWebGL(nsIDOMWebGLRenderingContext** aResult);
|
||||
|
||||
@ -172,6 +187,16 @@ WebGLContext::WebGLContext()
|
||||
mContextRestorer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
mContextStatus = ContextStable;
|
||||
mContextLostErrorSet = false;
|
||||
|
||||
nsRefPtr<WebGLMemoryPressureObserver> memoryPressureObserver
|
||||
= new WebGLMemoryPressureObserver(this);
|
||||
nsCOMPtr<nsIObserverService> observerService
|
||||
= mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->AddObserver(memoryPressureObserver,
|
||||
"memory-pressure",
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
WebGLContext::~WebGLContext()
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "nsIJSNativeInitializer.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
#include "GLContextProvider.h"
|
||||
#include "Layers.h"
|
||||
@ -526,6 +527,7 @@ class WebGLContext :
|
||||
friend class WebGLMemoryMultiReporterWrapper;
|
||||
friend class WebGLExtensionLoseContext;
|
||||
friend class WebGLContextUserData;
|
||||
friend class WebGLMemoryPressureObserver;
|
||||
|
||||
public:
|
||||
WebGLContext();
|
||||
@ -2887,6 +2889,21 @@ class WebGLMemoryMultiReporterWrapper
|
||||
}
|
||||
};
|
||||
|
||||
class WebGLMemoryPressureObserver MOZ_FINAL
|
||||
: public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
WebGLMemoryPressureObserver(WebGLContext *context)
|
||||
: mContext(context)
|
||||
{}
|
||||
|
||||
private:
|
||||
WebGLContext *mContext;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user