diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index e090bfc0ec83..300ff8228a12 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -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 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); diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 1adc09092b6a..be4a7768e171 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -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 gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat) { diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 3e90a8bfb434..35efe7ccda1e 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -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.