Commit c8810274 authored by George Wright's avatar George Wright
Browse files

Bug 1335145 - Only limit accelerated canvases for mobile r=milan

parent 2f238184
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -1059,6 +1059,8 @@ NS_INTERFACE_MAP_END
// Initialize our static variables.
uint32_t CanvasRenderingContext2D::sNumLivingContexts = 0;
DrawTarget* CanvasRenderingContext2D::sErrorTarget = nullptr;
static bool sMaxContextsInitialized = false;
static int32_t sMaxContexts = 0;



@@ -1079,6 +1081,11 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(layers::LayersBackend aCompos
  , mPathTransformWillUpdate(false)
  , mInvalidateCount(0)
{
  if (!sMaxContextsInitialized) {
    sMaxContexts = gfxPrefs::CanvasAzureAcceleratedLimit();
    sMaxContextsInitialized = true;
  }

  sNumLivingContexts++;

  mShutdownObserver = new CanvasShutdownObserver(this);
@@ -1431,10 +1438,13 @@ CanvasRenderingContext2D::DemotableContexts()
void
CanvasRenderingContext2D::DemoteOldestContextIfNecessary()
{
  const size_t kMaxContexts = 64;
  MOZ_ASSERT(sMaxContextsInitialized);
  if (sMaxContexts <= 0) {
    return;
  }

  std::vector<CanvasRenderingContext2D*>& contexts = DemotableContexts();
  if (contexts.size() < kMaxContexts)
  if (contexts.size() < (size_t)sMaxContexts)
    return;

  CanvasRenderingContext2D* oldest = contexts.front();
@@ -1446,6 +1456,10 @@ CanvasRenderingContext2D::DemoteOldestContextIfNecessary()
void
CanvasRenderingContext2D::AddDemotableContext(CanvasRenderingContext2D* aContext)
{
  MOZ_ASSERT(sMaxContextsInitialized);
  if (sMaxContexts <= 0)
    return;

  std::vector<CanvasRenderingContext2D*>::iterator iter = std::find(DemotableContexts().begin(), DemotableContexts().end(), aContext);
  if (iter != DemotableContexts().end())
    return;
@@ -1456,6 +1470,10 @@ CanvasRenderingContext2D::AddDemotableContext(CanvasRenderingContext2D* aContext
void
CanvasRenderingContext2D::RemoveDemotableContext(CanvasRenderingContext2D* aContext)
{
  MOZ_ASSERT(sMaxContextsInitialized);
  if (sMaxContexts <= 0)
    return;

  std::vector<CanvasRenderingContext2D*>::iterator iter = std::find(DemotableContexts().begin(), DemotableContexts().end(), aContext);
  if (iter != DemotableContexts().end())
    DemotableContexts().erase(iter);
+1 −0
Original line number Diff line number Diff line
@@ -365,6 +365,7 @@ private:
  DECL_GFX_PREF(Live, "gfx.canvas.auto_accelerate.min_frames", CanvasAutoAccelerateMinFrames, int32_t, 30);
  DECL_GFX_PREF(Live, "gfx.canvas.auto_accelerate.min_seconds", CanvasAutoAccelerateMinSeconds, float, 5.0f);
  DECL_GFX_PREF(Live, "gfx.canvas.azure.accelerated",          CanvasAzureAccelerated, bool, false);
  DECL_GFX_PREF(Once, "gfx.canvas.azure.accelerated.limit",    CanvasAzureAcceleratedLimit, int32_t, 0);
  // 0x7fff is the maximum supported xlib surface size and is more than enough for canvases.
  DECL_GFX_PREF(Live, "gfx.canvas.max-size",                   MaxCanvasSize, int32_t, 0x7fff);
  DECL_GFX_PREF(Once, "gfx.canvas.skiagl.cache-items",         CanvasSkiaGLCacheItems, int32_t, 256);
+1 −0
Original line number Diff line number Diff line
@@ -775,6 +775,7 @@ pref("dom.phonenumber.substringmatching.VE", 7);
// Enable hardware-accelerated Skia canvas
pref("gfx.canvas.azure.backends", "skia");
pref("gfx.canvas.azure.accelerated", true);
pref("gfx.canvas.azure.accelerated.limit", 64);

// See ua-update.json.in for the packaged UA override list
pref("general.useragent.updates.enabled", true);