Bug 711063 - Part 1: Add new glue code for Azure Wrapper. r=joedrew
authorBas Schouten <bschouten@mozilla.com>
Thu, 05 Jan 2012 08:17:51 +0100
changeset 85066 33fa4f12c4bbaba9182debbb684383deb082257c
parent 85065 c87c1aedefd440aeb1ce52df7d0f61cbfd3a16d1
child 85067 f8c79a52b765874e93c8e4614df85e8d23e7a8fd
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoedrew
bugs711063
milestone12.0a1
Bug 711063 - Part 1: Add new glue code for Azure Wrapper. r=joedrew
content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
gfx/thebes/gfx2DGlue.h
--- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
@@ -1190,17 +1190,17 @@ nsCanvasRenderingContext2DAzure::Redraw(
 
   if (!mCanvasElement) {
     NS_ASSERTION(mDocShell, "Redraw with no canvas element or docshell!");
     return;
   }
 
   nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement());
 
-  gfxRect tmpR = GFXRect(r);
+  gfxRect tmpR = ThebesRect(r);
   HTMLCanvasElement()->InvalidateCanvasContent(&tmpR);
 
   return;
 }
 
 nsresult
 nsCanvasRenderingContext2DAzure::RedrawUser(const gfxRect& r)
 {
--- a/gfx/thebes/gfx2DGlue.h
+++ b/gfx/thebes/gfx2DGlue.h
@@ -1,11 +1,14 @@
 
 #include "gfxRect.h"
+#include "gfxMatrix.h"
+#include "gfxContext.h"
 #include "mozilla/gfx/Rect.h"
+#include "mozilla/gfx/2D.h"
 
 namespace mozilla {
 namespace gfx {
 class DrawTarget;
 class SourceSurface;
 class ScaledFont;
 }
 }
@@ -14,27 +17,235 @@ namespace mozilla {
 namespace gfx {
 
 inline Rect ToRect(const gfxRect &aRect)
 {
   return Rect(Float(aRect.x), Float(aRect.y),
               Float(aRect.width), Float(aRect.height));
 }
 
-inline gfxRect GFXRect(const Rect &aRect)
+inline Color ToColor(const gfxRGBA &aRGBA)
+{
+  return Color(Float(aRGBA.r), Float(aRGBA.g),
+               Float(aRGBA.b), Float(aRGBA.a));
+}
+
+inline Matrix ToMatrix(const gfxMatrix &aMatrix)
+{
+  return Matrix(Float(aMatrix.xx), Float(aMatrix.yx), Float(aMatrix.xy),
+                Float(aMatrix.yy), Float(aMatrix.x0), Float(aMatrix.y0));
+}
+
+inline Point ToPoint(const gfxPoint &aPoint)
+{
+  return Point(Float(aPoint.x), Float(aPoint.y));
+}
+
+inline Size ToSize(const gfxSize &aSize)
+{
+  return Size(Float(aSize.width), Float(aSize.height));
+}
+
+inline Filter ToFilter(gfxPattern::GraphicsFilter aFilter)
+{
+  switch (aFilter) {
+  case gfxPattern::FILTER_NEAREST:
+    return FILTER_POINT;
+  default:
+    return FILTER_LINEAR;
+  }
+}
+
+inline gfxPattern::GraphicsFilter ThebesFilter(Filter aFilter)
+{
+  switch (aFilter) {
+  case FILTER_POINT:
+    return gfxPattern::FILTER_NEAREST;
+  default:
+    return gfxPattern::FILTER_BEST;
+  }
+}
+
+inline ExtendMode ToExtendMode(gfxPattern::GraphicsExtend aExtend)
+{
+  switch (aExtend) {
+  case gfxPattern::EXTEND_REPEAT:
+    return EXTEND_REPEAT;
+  case gfxPattern::EXTEND_REFLECT:
+    return EXTEND_REFLECT;
+  default:
+    return EXTEND_CLAMP;
+  }
+}
+
+inline gfxPattern::GraphicsExtend ThebesExtend(ExtendMode aExtend)
+{
+  switch (aExtend) {
+  case EXTEND_REPEAT:
+    return gfxPattern::EXTEND_REPEAT;
+  case EXTEND_REFLECT:
+    return gfxPattern::EXTEND_REFLECT;
+  default:
+    return gfxPattern::EXTEND_PAD;
+  }
+}
+
+inline gfxPoint ThebesPoint(const Point &aPoint)
+{
+  return gfxPoint(aPoint.x, aPoint.y);
+}
+
+inline gfxSize ThebesSize(const Size &aSize)
+{
+  return gfxSize(aSize.width, aSize.height);
+}
+
+inline gfxRect ThebesRect(const Rect &aRect)
 {
   return gfxRect(aRect.x, aRect.y, aRect.width, aRect.height);
 }
 
+inline gfxRGBA ThebesRGBA(const Color &aColor)
+{
+  return gfxRGBA(aColor.r, aColor.g, aColor.b, aColor.a);
+}
+
+inline gfxContext::GraphicsLineCap ThebesLineCap(CapStyle aStyle)
+{
+  switch (aStyle) {
+  case CAP_BUTT:
+    return gfxContext::LINE_CAP_BUTT;
+  case CAP_ROUND:
+    return gfxContext::LINE_CAP_ROUND;
+  case CAP_SQUARE:
+    return gfxContext::LINE_CAP_SQUARE;
+  default:
+    return gfxContext::LINE_CAP_BUTT;
+  }
+}
+
+inline CapStyle ToCapStyle(gfxContext::GraphicsLineCap aStyle)
+{
+  switch (aStyle) {
+  case gfxContext::LINE_CAP_BUTT:
+    return CAP_BUTT;
+  case gfxContext::LINE_CAP_ROUND:
+    return CAP_ROUND;
+  case gfxContext::LINE_CAP_SQUARE:
+    return CAP_SQUARE;
+  default:
+    return CAP_BUTT;
+  }
+}
+
+inline gfxContext::GraphicsLineJoin ThebesLineJoin(JoinStyle aStyle)
+{
+  switch (aStyle) {
+  case JOIN_MITER:
+    return gfxContext::LINE_JOIN_MITER;
+  case JOIN_BEVEL:
+    return gfxContext::LINE_JOIN_BEVEL;
+  case JOIN_ROUND:
+    return gfxContext::LINE_JOIN_ROUND;
+  default:
+    return gfxContext::LINE_JOIN_MITER;
+  }
+}
+
+inline JoinStyle ToJoinStyle(gfxContext::GraphicsLineJoin aStyle)
+{
+  switch (aStyle) {
+  case gfxContext::LINE_JOIN_MITER:
+    return JOIN_MITER;
+  case gfxContext::LINE_JOIN_BEVEL:
+    return JOIN_BEVEL;
+  case gfxContext::LINE_JOIN_ROUND:
+    return JOIN_ROUND;
+  default:
+    return JOIN_MITER;
+  }
+}
+
+inline gfxMatrix ThebesMatrix(const Matrix &aMatrix)
+{
+  return gfxMatrix(aMatrix._11, aMatrix._12, aMatrix._21,
+                   aMatrix._22, aMatrix._31, aMatrix._32);
+}
+
 inline gfxASurface::gfxContentType ContentForFormat(const SurfaceFormat &aFormat)
 {
   switch (aFormat) {
   case FORMAT_B8G8R8X8:
     return gfxASurface::CONTENT_COLOR;
   case FORMAT_A8:
     return gfxASurface::CONTENT_ALPHA;
+  case FORMAT_B8G8R8A8:
   default:
     return gfxASurface::CONTENT_COLOR_ALPHA;
   }
 }
 
+inline SurfaceFormat FormatForContent(gfxASurface::gfxContentType aContent)
+{
+  switch (aContent) {
+  case gfxASurface::CONTENT_COLOR:
+    return FORMAT_B8G8R8X8;
+  case gfxASurface::CONTENT_ALPHA:
+    return FORMAT_A8;
+  default:
+    return FORMAT_B8G8R8A8;
+  }
+}
+
+inline CompositionOp CompositionOpForOp(gfxContext::GraphicsOperator aOp)
+{
+  switch (aOp) {
+  case gfxContext::OPERATOR_ADD:
+    return OP_ADD;
+  case gfxContext::OPERATOR_ATOP:
+    return OP_ATOP;
+  case gfxContext::OPERATOR_IN:
+    return OP_IN;
+  case gfxContext::OPERATOR_OUT:
+    return OP_OUT;
+  case gfxContext::OPERATOR_SOURCE:
+    return OP_SOURCE;
+  case gfxContext::OPERATOR_DEST_IN:
+    return OP_DEST_IN;
+  case gfxContext::OPERATOR_DEST_OUT:
+    return OP_DEST_OUT;
+  case gfxContext::OPERATOR_DEST_ATOP:
+    return OP_DEST_ATOP;
+  case gfxContext::OPERATOR_XOR:
+    return OP_XOR;
+  default:
+    return OP_OVER;
+  }
+}
+
+inline gfxContext::GraphicsOperator ThebesOp(CompositionOp aOp)
+{
+  switch (aOp) {
+  case OP_ADD:
+    return gfxContext::OPERATOR_ADD;
+  case OP_ATOP:
+    return gfxContext::OPERATOR_ATOP;
+  case OP_IN:
+    return gfxContext::OPERATOR_IN;
+  case OP_OUT:
+    return gfxContext::OPERATOR_OUT;
+  case OP_SOURCE:
+    return gfxContext::OPERATOR_SOURCE;
+  case OP_DEST_IN:
+    return gfxContext::OPERATOR_DEST_IN;
+  case OP_DEST_OUT:
+    return gfxContext::OPERATOR_DEST_OUT;
+  case OP_DEST_ATOP:
+    return gfxContext::OPERATOR_DEST_ATOP;
+  case OP_XOR:
+    return gfxContext::OPERATOR_XOR;
+  default:
+    return gfxContext::OPERATOR_OVER;
+  }
+}
+
 }
 }