mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1049251 - Partially disable SkiaGL on Low total system memory r=jrmuizel
This commit is contained in:
parent
9ca169cc88
commit
5cb1b77a4e
@ -897,10 +897,13 @@ CanvasRenderingContext2D::CheckSizeForSkiaGL(IntSize size) {
|
||||
// Cache the number of pixels on the primary screen
|
||||
static int32_t gScreenPixels = -1;
|
||||
if (gScreenPixels < 0) {
|
||||
// Default to historical mobile screen size of 980x480. In addition,
|
||||
// allow skia use up to this size even if the screen is smaller. A lot
|
||||
// content expects this size to work well.
|
||||
gScreenPixels = 980 * 480;
|
||||
// Default to historical mobile screen size of 980x480, like FishIEtank.
|
||||
// In addition, allow skia use up to this size even if the screen is smaller.
|
||||
// A lot content expects this size to work well.
|
||||
// See Bug 999841
|
||||
if (gfxPlatform::GetPlatform()->HasEnoughTotalSystemMemoryForSkiaGL()) {
|
||||
gScreenPixels = 980 * 480;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScreenManager> screenManager =
|
||||
do_GetService("@mozilla.org/gfx/screenmanager;1");
|
||||
@ -916,22 +919,8 @@ CanvasRenderingContext2D::CheckSizeForSkiaGL(IntSize size) {
|
||||
}
|
||||
}
|
||||
|
||||
// On high DPI devices the screen pixels may be scaled up. Make
|
||||
// sure to apply that scaling here as well if we are hooked up
|
||||
// to a widget.
|
||||
static double gDefaultScale = 0.0;
|
||||
if (gDefaultScale < 1.0) {
|
||||
nsIPresShell* ps = GetPresShell();
|
||||
if (ps) {
|
||||
nsIFrame* frame = ps->GetRootFrame();
|
||||
if (frame) {
|
||||
nsIWidget* widget = frame->GetNearestWidget();
|
||||
if (widget) {
|
||||
gDefaultScale = widget->GetDefaultScale().scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Just always use a scale of 1.0. It can be changed if a lot of contents need it.
|
||||
static double gDefaultScale = 1.0;
|
||||
|
||||
double scale = gDefaultScale > 0 ? gDefaultScale : 1.0;
|
||||
int32_t threshold = ceil(scale * scale * gScreenPixels);
|
||||
|
@ -278,6 +278,7 @@ gfxPlatform::gfxPlatform()
|
||||
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO);
|
||||
InitBackendPrefs(canvasMask, BackendType::CAIRO,
|
||||
contentMask, BackendType::CAIRO);
|
||||
mTotalSystemMemory = mozilla::hal::GetTotalSystemMemory();
|
||||
}
|
||||
|
||||
gfxPlatform*
|
||||
@ -852,14 +853,12 @@ gfxPlatform::InitializeSkiaCacheLimits()
|
||||
cacheSizeLimit *= 1024*1024;
|
||||
|
||||
if (usingDynamicCache) {
|
||||
uint32_t totalMemory = mozilla::hal::GetTotalSystemMemory();
|
||||
|
||||
if (totalMemory < 512*1024*1024) {
|
||||
if (mTotalSystemMemory < 512*1024*1024) {
|
||||
// We need a very minimal cache on anything smaller than 512mb.
|
||||
// Note the large jump as we cross 512mb (from 2mb to 32mb).
|
||||
cacheSizeLimit = 2*1024*1024;
|
||||
} else if (totalMemory > 0) {
|
||||
cacheSizeLimit = totalMemory / 16;
|
||||
} else if (mTotalSystemMemory > 0) {
|
||||
cacheSizeLimit = mTotalSystemMemory / 16;
|
||||
}
|
||||
}
|
||||
|
||||
@ -912,6 +911,17 @@ gfxPlatform::PurgeSkiaCache()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
gfxPlatform::HasEnoughTotalSystemMemoryForSkiaGL()
|
||||
{
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (mTotalSystemMemory < 250*1024*1024) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
TemporaryRef<DrawTarget>
|
||||
gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat)
|
||||
{
|
||||
|
@ -547,6 +547,7 @@ public:
|
||||
|
||||
static bool UsesOffMainThreadCompositing();
|
||||
|
||||
bool HasEnoughTotalSystemMemoryForSkiaGL();
|
||||
protected:
|
||||
gfxPlatform();
|
||||
virtual ~gfxPlatform();
|
||||
@ -616,6 +617,8 @@ protected:
|
||||
// max number of entries in word cache
|
||||
int32_t mWordCacheMaxEntries;
|
||||
|
||||
uint32_t mTotalSystemMemory;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Start up Thebes.
|
||||
|
Loading…
Reference in New Issue
Block a user