Bug 888445 - Only use SkiaGL canvas on NVIDIA r=bjacob
authorJames Willcox <jwillcox@mozilla.com>
Fri, 28 Jun 2013 15:59:44 -0400
changeset 139172 8e87e5a44607cf2a119715afb8315c87353f0500
parent 139171 cc82635606eb9253c7c85d6e2ac0416ceafaa5b0
child 139173 fb0c86ed08c2a198ea0513202da252a8be675ed5
push id31266
push userjwillcox@mozilla.com
push dateFri, 19 Jul 2013 02:34:02 +0000
treeherdermozilla-inbound@4303c1af09f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs888445
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 888445 - Only use SkiaGL canvas on NVIDIA r=bjacob
content/canvas/src/CanvasRenderingContext2D.cpp
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -99,16 +99,17 @@
 
 #ifdef USE_SKIA_GPU
 #undef free // apparently defined by some windows header, clashing with a free()
             // method in SkTypes.h
 #include "GLContext.h"
 #include "GLContextProvider.h"
 #include "GLContextSkia.h"
 #include "SurfaceTypes.h"
+#include "nsIGfxInfo.h"
 using mozilla::gl::GLContext;
 using mozilla::gl::GLContextProvider;
 #endif
 
 #ifdef XP_WIN
 #include "gfxWindowsPlatform.h"
 #endif
 
@@ -854,44 +855,50 @@ CanvasRenderingContext2D::EnsureTarget()
 
     if (ownerDoc) {
       layerManager =
         nsContentUtils::PersistentLayerManagerForDocument(ownerDoc);
     }
 
      if (layerManager) {
 #ifdef USE_SKIA_GPU
-       if (gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas()) {
-         SurfaceCaps caps = SurfaceCaps::ForRGBA();
-         caps.preserve = true;
+      if (gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas()) {
+        SurfaceCaps caps = SurfaceCaps::ForRGBA();
+        caps.preserve = true;
 
 #ifdef MOZ_WIDGET_GONK
-         layers::ShadowLayerForwarder *forwarder = layerManager->AsShadowForwarder();
-         if (forwarder) {
-           caps.surfaceAllocator = static_cast<layers::ISurfaceAllocator*>(forwarder);
-         }
+        layers::ShadowLayerForwarder *forwarder = layerManager->AsShadowForwarder();
+        if (forwarder) {
+          caps.surfaceAllocator = static_cast<layers::ISurfaceAllocator*>(forwarder);
+        }
 #endif
 
-         DemoteOldestContextIfNecessary();
-
-         nsRefPtr<GLContext> glContext;
-
-         if (!mForceSoftware) {
-           glContext = GLContextProvider::CreateOffscreen(gfxIntSize(size.width, size.height),
-                                                          caps, GLContext::ContextFlagsNone);
-         }
-
-         if (glContext) {
-           SkAutoTUnref<GrGLInterface> i(CreateGrGLInterfaceFromGLContext(glContext));
-           mTarget = Factory::CreateDrawTargetSkiaWithGLContextAndGrGLInterface(glContext, i, size, format);
-           AddDemotableContext(this);
-         } else {
-           mTarget = layerManager->CreateDrawTarget(size, format);
-         }
-       } else
+        DemoteOldestContextIfNecessary();
+
+        nsRefPtr<GLContext> glContext;
+        nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
+        nsString vendor;
+
+        if (!mForceSoftware &&
+            gfxInfo &&
+            NS_SUCCEEDED(gfxInfo->GetAdapterVendorID(vendor)) &&
+            StringBeginsWith(vendor, NS_LITERAL_STRING("NVIDIA")))
+        {
+          glContext = GLContextProvider::CreateOffscreen(gfxIntSize(size.width, size.height),
+                                                         caps, GLContext::ContextFlagsNone);
+        }
+
+        if (glContext) {
+          SkAutoTUnref<GrGLInterface> i(CreateGrGLInterfaceFromGLContext(glContext));
+          mTarget = Factory::CreateDrawTargetSkiaWithGLContextAndGrGLInterface(glContext, i, size, format);
+          AddDemotableContext(this);
+        } else {
+          mTarget = layerManager->CreateDrawTarget(size, format);
+        }
+      } else
 #endif
        mTarget = layerManager->CreateDrawTarget(size, format);
      } else {
        mTarget = gfxPlatform::GetPlatform()->CreateOffscreenDrawTarget(size, format);
      }
   }
 
   if (mTarget) {