Bug 1319362 - Use area but not just dimension to check SkiaGL minimum size. r=lsalzman
authorEthan Lin <ethlin@mozilla.com>
Tue, 22 Nov 2016 19:52:00 +0100
changeset 324290 a38d735c9041b9a769645bd9dd0b9d34263d05e6
parent 324289 797ee4b5a94885a83851e5e45233a714ddfa0434
child 324291 06ed2770b58d3610b8b8fecc50cb9e4087dc595d
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerslsalzman
bugs1319362
milestone53.0a1
Bug 1319362 - Use area but not just dimension to check SkiaGL minimum size. r=lsalzman
dom/canvas/CanvasRenderingContext2D.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -1447,22 +1447,25 @@ CanvasRenderingContext2D::AddDemotableCo
 void
 CanvasRenderingContext2D::RemoveDemotableContext(CanvasRenderingContext2D* aContext)
 {
   std::vector<CanvasRenderingContext2D*>::iterator iter = std::find(DemotableContexts().begin(), DemotableContexts().end(), aContext);
   if (iter != DemotableContexts().end())
     DemotableContexts().erase(iter);
 }
 
+#define MIN_SKIA_GL_DIMENSION 16
+
 bool
 CanvasRenderingContext2D::CheckSizeForSkiaGL(IntSize aSize) {
   MOZ_ASSERT(NS_IsMainThread());
 
   int minsize = Preferences::GetInt("gfx.canvas.min-size-for-skia-gl", 128);
-  if (aSize.width < minsize || aSize.height < minsize) {
+  if (aSize.width < MIN_SKIA_GL_DIMENSION || aSize.height < MIN_SKIA_GL_DIMENSION ||
+      (aSize.width * aSize.height < minsize * minsize)) {
     return false;
   }
 
   // Maximum pref allows 3 different options:
   //  0   means unlimited size
   //  > 0 means use value as an absolute threshold
   //  < 0 means use the number of screen pixels as a threshold
   int maxsize = Preferences::GetInt("gfx.canvas.max-size-for-skia-gl", 0);