Bug 702517 - Expose skia backend as a GfxInfo property and use it to mark tests as passing. r=jrmuizel
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 18 Nov 2011 17:00:38 +1300
changeset 82071 c83fc47b1433b5ef801505b3d0a7abcdf46f8ec3
parent 82070 e789d1408f877c736d4a8a8bc0ec5024be5cfa78
child 82072 408f89aa1c91e7392087a00ace062ccdfea69423
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs702517
milestone11.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 702517 - Expose skia backend as a GfxInfo property and use it to mark tests as passing. r=jrmuizel
content/canvas/test/test_canvas.html
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
--- a/content/canvas/test/test_canvas.html
+++ b/content/canvas/test/test_canvas.html
@@ -24,16 +24,28 @@ function IsAzureEnabled() {
   try {
     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
     enabled = Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).AzureEnabled;
   } catch (e) { }
 
   return enabled;
 }
 
+function IsAzureSkia() {
+  var enabled = false;
+  
+  try {
+    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+    var backend = Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).getInfo().AzureBackend;
+    enabled = (backend == "skia");
+  } catch (e) { }
+
+  return enabled;
+}
+
 </script>
 <!-- Includes all the tests in the content/canvas/tests except for test_bug397524.html -->
 
 <!-- [[[ test_2d.canvas.readonly.html ]]] -->
 
 <p>Canvas test: 2d.canvas.readonly</p>
 <!-- Testing: CanvasRenderingContext2D.canvas is readonly -->
 <canvas id="c1" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
@@ -14334,18 +14346,21 @@ ctx.lineCap = 'round';
 ctx.lineJoin = 'round';
 
 ctx.beginPath();
 ctx.moveTo(50, 25);
 ctx.lineTo(50, 25);
 ctx.closePath();
 ctx.stroke();
 
-todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
-
+if (IsAzureEnabled() && IsAzureSkia()) {
+  isPixel(ctx, 50,25, 0,255,0,255, 0);
+} else {
+  todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
+}
 
 }
 </script>
 
 <!-- [[[ test_2d.path.stroke.prune.corner.html ]]] -->
 
 <p>Canvas test: 2d.path.stroke.prune.corner</p>
 <!-- Testing: Zero-length line segments are removed before stroking with miters -->
@@ -14407,17 +14422,21 @@ ctx.moveTo(50, 25);
 ctx.quadraticCurveTo(50, 25, 50, 25);
 ctx.stroke();
 
 ctx.beginPath();
 ctx.moveTo(50, 25);
 ctx.bezierCurveTo(50, 25, 50, 25, 50, 25);
 ctx.stroke();
 
-todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
+if (IsAzureEnabled() && IsAzureSkia()) {
+  isPixel(ctx, 50,25, 0,255,0,255, 0);
+} else {
+  todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
+}
 
 
 }
 </script>
 
 <!-- [[[ test_2d.path.stroke.prune.line.html ]]] -->
 
 <p>Canvas test: 2d.path.stroke.prune.line</p>
@@ -14440,18 +14459,21 @@ ctx.lineWidth = 100;
 ctx.lineCap = 'round';
 ctx.lineJoin = 'round';
 
 ctx.beginPath();
 ctx.moveTo(50, 25);
 ctx.lineTo(50, 25);
 ctx.stroke();
 
-todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
-
+if (IsAzureEnabled() && IsAzureSkia()) {
+  isPixel(ctx, 50,25, 0,255,0,255, 0);
+} else {
+  todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
+}
 
 }
 </script>
 
 <!-- [[[ test_2d.path.stroke.prune.rect.html ]]] -->
 
 <p>Canvas test: 2d.path.stroke.prune.rect</p>
 <!-- Testing: Zero-length line segments from rect and strokeRect are removed before stroking -->
@@ -14474,18 +14496,21 @@ ctx.lineCap = 'round';
 ctx.lineJoin = 'round';
 
 ctx.beginPath();
 ctx.rect(50, 25, 0, 0);
 ctx.stroke();
 
 ctx.strokeRect(50, 25, 0, 0);
 
-todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
-
+if (IsAzureEnabled() && IsAzureSkia()) {
+  isPixel(ctx, 50,25, 0,255,0,255, 0);
+} else {
+  todo_isPixel(ctx, 50,25, 0,255,0,255, 0);
+}
 
 }
 </script>
 
 <!-- [[[ test_2d.path.stroke.scale1.html ]]] -->
 
 <p>Canvas test: 2d.path.stroke.scale1</p>
 <!-- Testing: Stroke line widths are scaled by the current transformation matrix -->
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -215,16 +215,17 @@ static const char *gPrefLangNames[] = {
     "x-knda",
     "x-sinh",
     "x-tibt",
     "x-unicode",
     "x-user-def"
 };
 
 gfxPlatform::gfxPlatform()
+  : mAzureBackendCollector(this, &gfxPlatform::GetAzureBackendInfo)
 {
     mUseHarfBuzzScripts = UNINITIALIZED_VALUE;
     mAllowDownloadableFonts = UNINITIALIZED_VALUE;
     mDownloadableFontsSanitize = UNINITIALIZED_VALUE;
 }
 
 gfxPlatform*
 gfxPlatform::GetPlatform()
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -48,16 +48,17 @@
 #include "gfxTypes.h"
 #include "gfxASurface.h"
 #include "gfxColor.h"
 
 #include "qcms.h"
 
 #include "gfx2DGlue.h"
 #include "mozilla/RefPtr.h"
+#include "GfxInfoCollector.h"
 
 #ifdef XP_OS2
 #undef OS2EMX_PLAIN_CHAR
 #endif
 
 class gfxImageSurface;
 class gfxFont;
 class gfxFontGroup;
@@ -137,16 +138,34 @@ enum eGfxLog {
 
 // when searching through pref langs, max number of pref langs
 const PRUint32 kMaxLenPrefLangList = 32;
 
 #define UNINITIALIZED_VALUE  (-1)
 
 typedef gfxASurface::gfxImageFormat gfxImageFormat;
 
+inline const char*
+GetBackendName(mozilla::gfx::BackendType aBackend)
+{
+  switch (aBackend) {
+      case mozilla::gfx::BACKEND_DIRECT2D:
+        return "direct2d";
+      case mozilla::gfx::BACKEND_COREGRAPHICS:
+        return "quartz";
+      case mozilla::gfx::BACKEND_CAIRO:
+        return "cairo";
+      case mozilla::gfx::BACKEND_SKIA:
+        return "skia";
+      default:
+        NS_ERROR("Invalid backend type!");
+        return "";
+  }
+}
+
 class THEBES_API gfxPlatform {
 public:
     /**
      * Return a pointer to the current active platform.
      * This is a singleton; it contains mostly convenience
      * functions to obtain platform-specific objects.
      */
     static gfxPlatform *GetPlatform();
@@ -185,16 +204,23 @@ public:
     virtual already_AddRefed<gfxASurface>
       GetThebesSurfaceForDrawTarget(mozilla::gfx::DrawTarget *aTarget);
 
     virtual mozilla::RefPtr<mozilla::gfx::DrawTarget>
       CreateOffscreenDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
 
     virtual bool SupportsAzure(mozilla::gfx::BackendType& aBackend) { return false; }
 
+    void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) {
+      mozilla::gfx::BackendType backend;
+      if (SupportsAzure(backend)) {
+        aObj.DefineProperty("AzureBackend", GetBackendName(backend)); 
+      }
+    }
+
     /*
      * Font bits
      */
 
     virtual void SetupClusterBoundaries(gfxTextRun *aTextRun, const PRUnichar *aString);
 
     /**
      * Fill aListOfFonts with the results of querying the list of font names
@@ -403,11 +429,12 @@ protected:
 
 private:
     virtual qcms_profile* GetPlatformCMSOutputProfile();
 
     nsRefPtr<gfxASurface> mScreenReferenceSurface;
     nsTArray<PRUint32> mCJKPrefLangs;
     nsCOMPtr<nsIObserver> mSRGBOverrideObserver;
     nsCOMPtr<nsIObserver> mFontPrefsObserver;
+    mozilla::widget::GfxInfoCollector<gfxPlatform> mAzureBackendCollector;
 };
 
 #endif /* GFX_PLATFORM_H */