Backout fa3fe2aff1f5 (bug 756996) for bustage
authorEd Morley <emorley@mozilla.com>
Thu, 31 May 2012 15:46:38 +0100
changeset 99457 7bcf7ead7392057b9631fa6ee8012a53a92c6880
parent 99456 f16847bdf08665441832bafd04fcd81ca70184c9
child 99458 7d6bfa12744db6b5ec4f57c6d8b9a257a48fdb58
push idunknown
push userunknown
push dateunknown
bugs756996
milestone15.0a1
backs outfa3fe2aff1f56fa0320c4bc1dae935833b4af5b5
Backout fa3fe2aff1f5 (bug 756996) for bustage
gfx/2d/DrawTargetCairo.cpp
gfx/2d/DrawTargetD2D.cpp
gfx/2d/HelpersD2D.h
gfx/2d/ImageScalingSSE2.cpp
gfx/2d/PathD2D.cpp
gfx/layers/d3d10/ImageLayerD3D10.cpp
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -207,17 +207,16 @@ GfxPatternToCairoPattern(const Pattern& 
       }
 
       break;
     }
     default:
     {
       // We should support all pattern types!
       MOZ_ASSERT(false);
-      MOZ_NOT_REACHED_MARKER();
     }
   }
 
   return pat;
 }
 
 static bool
 NeedIntermediateSurface(const Pattern& aPattern, const DrawOptions& aOptions)
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -124,17 +124,18 @@ public:
       D2D1::RectF(0, 0, float(mDT->mSize.width), float(mDT->mSize.height)),
       byRef(rectGeom));
 
     RefPtr<ID2D1PathGeometry> invClippedArea;
     factory()->CreatePathGeometry(byRef(invClippedArea));
     RefPtr<ID2D1GeometrySink> sink;
     invClippedArea->Open(byRef(sink));
 
-    rectGeom->CombineWithGeometry(mClippedArea, D2D1_COMBINE_MODE_EXCLUDE, NULL, sink);
+    HRESULT hr = rectGeom->CombineWithGeometry(mClippedArea, D2D1_COMBINE_MODE_EXCLUDE,
+                                               NULL, sink);
     sink->Close();
 
     RefPtr<ID2D1BitmapBrush> brush;
     rt->CreateBitmapBrush(mOldSurfBitmap, D2D1::BitmapBrushProperties(), D2D1::BrushProperties(), byRef(brush));                   
 
     rt->FillGeometry(invClippedArea, brush);
   }
 
@@ -287,18 +288,16 @@ DrawTargetD2D::DrawSurface(SourceSurface
       D2D1_BITMAP_PROPERTIES props =
         D2D1::BitmapProperties(D2D1::PixelFormat(DXGIFormat(srcSurf->GetFormat()), AlphaMode(srcSurf->GetFormat())));
       mRT->CreateBitmap(D2D1::SizeU(UINT32(aSource.width), UINT32(aSource.height)), data, stride, props, byRef(bitmap));
 
       srcRect.x -= (uint32_t)aSource.x;
       srcRect.y -= (uint32_t)aSource.y;
     }
     break;
-  default:
-    break;
   }
 
   rt->DrawBitmap(bitmap, D2DRect(aDest), aOptions.mAlpha, D2DFilter(aSurfOptions.mFilter), D2DRect(srcRect));
 
   FinalizeRTForOperation(aOptions.mCompositionOp, ColorPattern(Color()), aDest);
 }
 
 void
@@ -695,18 +694,16 @@ DrawTargetD2D::CopySurface(SourceSurface
     break;
   case SURFACE_D2D1_DRAWTARGET:
     {
       SourceSurfaceD2DTarget *srcSurf = static_cast<SourceSurfaceD2DTarget*>(aSurface);
       bitmap = srcSurf->GetBitmap(mRT);
       AddDependencyOnSource(srcSurf);
     }
     break;
-  default:
-    return;
   }
 
   if (!bitmap) {
     return;
   }
 
   mRT->DrawBitmap(bitmap, D2DRect(dstRect), 1.0f,
                   D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
@@ -2007,18 +2004,16 @@ DrawTargetD2D::CreateBrushForPattern(con
           static_cast<DataSourceSurface*>(pat->mSurface.get());
         bitmap = CreatePartialBitmapForSurface(dataSurf, mat);
         
         if (!bitmap) {
           return NULL;
         }
       }
       break;
-    default:
-      break;
     }
     
     mRT->CreateBitmapBrush(bitmap,
                            D2D1::BitmapBrushProperties(D2DExtend(pat->mExtendMode),
                                                        D2DExtend(pat->mExtendMode),
                                                        D2DFilter(pat->mFilter)),
                            D2D1::BrushProperties(aAlpha, D2DMatrix(mat)),
                            byRef(bmBrush));
@@ -2270,16 +2265,18 @@ DrawTargetD2D::CreatePartialBitmapForSur
     // we need to deal with EXTEND modes here!
     return NULL;
   }
 
   int stride = aSurface->Stride();
 
   if (uploadRect.width <= mRT->GetMaximumBitmapSize() &&
       uploadRect.height <= mRT->GetMaximumBitmapSize()) {
+            
+    int Bpp = BytesPerPixel(aSurface->GetFormat());
 
     // A partial upload will suffice.
     mRT->CreateBitmap(D2D1::SizeU(uint32_t(uploadRect.width), uint32_t(uploadRect.height)),
                       aSurface->GetData() + int(uploadRect.x) * 4 + int(uploadRect.y) * stride,
                       stride,
                       D2D1::BitmapProperties(D2DPixelFormat(aSurface->GetFormat())),
                       byRef(bitmap));
 
@@ -2303,23 +2300,23 @@ DrawTargetD2D::CreatePartialBitmapForSur
     Point bottomRight = transform * Point(size.width, size.height);
     Point bottomLeft = transform * Point(0, size.height);
     
     IntSize scaleSize;
 
     scaleSize.width = max(Distance(topRight, topLeft), Distance(bottomRight, bottomLeft));
     scaleSize.height = max(Distance(topRight, bottomRight), Distance(topLeft, bottomLeft));
 
-    if (unsigned(scaleSize.width) > mRT->GetMaximumBitmapSize()) {
+    if (scaleSize.width > mRT->GetMaximumBitmapSize()) {
       // Ok, in this case we'd really want a downscale of a part of the bitmap,
       // perhaps we can do this later but for simplicity let's do something
       // different here and assume it's good enough, this should be rare!
       scaleSize.width = 4095;
     }
-    if (unsigned(scaleSize.height) > mRT->GetMaximumBitmapSize()) {
+    if (scaleSize.height > mRT->GetMaximumBitmapSize()) {
       scaleSize.height = 4095;
     }
 
     scaler.ScaleForSize(scaleSize);
 
     IntSize newSize = scaler.GetSize();
     
     mRT->CreateBitmap(D2D1::SizeU(newSize.width, newSize.height),
--- a/gfx/2d/HelpersD2D.h
+++ b/gfx/2d/HelpersD2D.h
@@ -27,49 +27,47 @@ static inline D2D1_SIZE_U D2DIntSize(con
 
 static inline D2D1_RECT_F D2DRect(const Rect &aRect)
 {
   return D2D1::RectF(aRect.x, aRect.y, aRect.XMost(), aRect.YMost());
 }
 
 static inline D2D1_EXTEND_MODE D2DExtend(ExtendMode aExtendMode)
 {
-  D2D1_EXTEND_MODE extend;
+  D2D1_EXTEND_MODE extend = D2D1_EXTEND_MODE_CLAMP;
   switch (aExtendMode) {
   case EXTEND_REPEAT:
     extend = D2D1_EXTEND_MODE_WRAP;
     break;
   case EXTEND_REFLECT:
     extend = D2D1_EXTEND_MODE_MIRROR;
     break;
-  default:
-    extend = D2D1_EXTEND_MODE_CLAMP;
   }
 
   return extend;
 }
 
 static inline D2D1_BITMAP_INTERPOLATION_MODE D2DFilter(const Filter &aFilter)
 {
   switch (aFilter) {
   case FILTER_POINT:
     return D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR;
-  default:
-    return D2D1_BITMAP_INTERPOLATION_MODE_LINEAR;
   }
+
+  return D2D1_BITMAP_INTERPOLATION_MODE_LINEAR;
 }
 
 static inline D2D1_ANTIALIAS_MODE D2DAAMode(AntialiasMode aMode)
 {
   switch (aMode) {
   case AA_NONE:
     return D2D1_ANTIALIAS_MODE_ALIASED;
-  default:
-    return D2D1_ANTIALIAS_MODE_PER_PRIMITIVE;
   }
+
+  return D2D1_ANTIALIAS_MODE_PER_PRIMITIVE;
 }
 
 static inline D2D1_MATRIX_3X2_F D2DMatrix(const Matrix &aTransform)
 {
   return D2D1::Matrix3x2F(aTransform._11, aTransform._12,
                           aTransform._21, aTransform._22,
                           aTransform._31, aTransform._32);
 }
@@ -90,56 +88,56 @@ static inline SurfaceFormat ToPixelForma
   case DXGI_FORMAT_A8_UNORM:
     return FORMAT_A8;
   case DXGI_FORMAT_B8G8R8A8_UNORM:
     if (aFormat.alphaMode == D2D1_ALPHA_MODE_IGNORE) {
       return FORMAT_B8G8R8X8;
     } else {
       return FORMAT_B8G8R8A8;
     }
-  default:
-    return FORMAT_B8G8R8A8;
   }
+
+  return FORMAT_B8G8R8A8;
 }
 
 static inline Rect ToRect(const D2D1_RECT_F &aRect)
 {
   return Rect(aRect.left, aRect.top, aRect.right - aRect.left, aRect.bottom - aRect.top);
 }
 
 static inline DXGI_FORMAT DXGIFormat(SurfaceFormat aFormat)
 {
   switch (aFormat) {
   case FORMAT_B8G8R8A8:
     return DXGI_FORMAT_B8G8R8A8_UNORM;
   case FORMAT_B8G8R8X8:
     return DXGI_FORMAT_B8G8R8A8_UNORM;
   case FORMAT_A8:
     return DXGI_FORMAT_A8_UNORM;
-  default:
-    return DXGI_FORMAT_UNKNOWN;
   }
+
+  return DXGI_FORMAT_UNKNOWN;
 }
 
 static inline D2D1_ALPHA_MODE AlphaMode(SurfaceFormat aFormat)
 {
   switch (aFormat) {
   case FORMAT_B8G8R8X8:
     return D2D1_ALPHA_MODE_IGNORE;
-  default:
-    return D2D1_ALPHA_MODE_PREMULTIPLIED;
   }
+
+  return D2D1_ALPHA_MODE_PREMULTIPLIED;
 }
 
 static inline D2D1_PIXEL_FORMAT D2DPixelFormat(SurfaceFormat aFormat)
 {
   return D2D1::PixelFormat(DXGIFormat(aFormat), AlphaMode(aFormat));
 }
 
-static inline bool IsPatternSupportedByD2D(const Pattern &aPattern)
+static bool IsPatternSupportedByD2D(const Pattern &aPattern)
 {
   if (aPattern.GetType() != PATTERN_RADIAL_GRADIENT) {
     return false;
   }
 
   const RadialGradientPattern *pat =
     static_cast<const RadialGradientPattern*>(&aPattern);
   
@@ -170,47 +168,47 @@ struct ShaderConstantRectD3D10
   ShaderConstantRectD3D10(float aX, float aY, float aWidth, float aHeight)
     : mX(aX), mY(aY), mWidth(aWidth), mHeight(aHeight)
   { }
 
   // For easy passing to SetVertexShaderConstantF.
   operator float* () { return &mX; }
 };
 
-static inline DWRITE_MATRIX
+static DWRITE_MATRIX
 DWriteMatrixFromMatrix(Matrix &aMatrix)
 {
   DWRITE_MATRIX mat;
   mat.m11 = aMatrix._11;
   mat.m12 = aMatrix._12;
   mat.m21 = aMatrix._21;
   mat.m22 = aMatrix._22;
   mat.dx = aMatrix._31;
   mat.dy = aMatrix._32;
   return mat;
 }
 
 class AutoDWriteGlyphRun : public DWRITE_GLYPH_RUN
 {
-    static const unsigned kNumAutoGlyphs = 256;
+    static const int kNumAutoGlyphs = 256;
 
 public:
     AutoDWriteGlyphRun() {
         glyphCount = 0;
     }
 
     ~AutoDWriteGlyphRun() {
         if (glyphCount > kNumAutoGlyphs) {
             delete[] glyphIndices;
             delete[] glyphAdvances;
             delete[] glyphOffsets;
         }
     }
 
-    void allocate(unsigned aNumGlyphs) {
+    void allocate(int aNumGlyphs) {
         glyphCount = aNumGlyphs;
         if (aNumGlyphs <= kNumAutoGlyphs) {
             glyphIndices = &mAutoIndices[0];
             glyphAdvances = &mAutoAdvances[0];
             glyphOffsets = &mAutoOffsets[0];
         } else {
             glyphIndices = new UINT16[aNumGlyphs];
             glyphAdvances = new FLOAT[aNumGlyphs];
@@ -219,17 +217,17 @@ public:
     }
 
 private:
     DWRITE_GLYPH_OFFSET mAutoOffsets[kNumAutoGlyphs];
     FLOAT               mAutoAdvances[kNumAutoGlyphs];
     UINT16              mAutoIndices[kNumAutoGlyphs];
 };
 
-static inline void
+static void
 DWriteGlyphRunFromGlyphs(const GlyphBuffer &aGlyphs, ScaledFontDWrite *aFont, AutoDWriteGlyphRun *run)
 {
   run->allocate(aGlyphs.mNumGlyphs);
 
   FLOAT *advances = const_cast<FLOAT*>(run->glyphAdvances);
   UINT16 *indices = const_cast<UINT16*>(run->glyphIndices);
   DWRITE_GLYPH_OFFSET *offsets = const_cast<DWRITE_GLYPH_OFFSET*>(run->glyphOffsets);
 
--- a/gfx/2d/ImageScalingSSE2.cpp
+++ b/gfx/2d/ImageScalingSSE2.cpp
@@ -84,32 +84,38 @@ MOZ_ALWAYS_INLINE __m128i avg_sse2_8x2(_
 #undef shuf1
 #undef shuf2
 #undef shuffle_si128
 
   __m128i sum = _mm_xor_si128(*a, _mm_xor_si128(*b, *c));
 
   __m128i carry = _mm_or_si128(_mm_and_si128(*a, *b), _mm_or_si128(_mm_and_si128(*a, *c), _mm_and_si128(*b, *c)));
 
+  __m128i minusone = _mm_set1_epi32(0xffffffff);
+
   sum = _mm_avg_epu8(_mm_not_si128(sum), _mm_not_si128(*d));
 
   return _mm_not_si128(_mm_avg_epu8(sum, _mm_not_si128(carry)));
 }
 
 MOZ_ALWAYS_INLINE __m128i avg_sse2_4x2_4x1(__m128i a, __m128i b)
 {
+  __m128i minusone = _mm_set1_epi32(0xffffffff);
+
   return _mm_not_si128(_mm_avg_epu8(_mm_not_si128(a), _mm_not_si128(b)));
 }
 
 MOZ_ALWAYS_INLINE __m128i avg_sse2_8x1_4x1(__m128i a, __m128i b)
 {
   __m128i t = _mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(b), _mm_castsi128_ps(a), _MM_SHUFFLE(3, 1, 3, 1)));
   b = _mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(b), _mm_castsi128_ps(a), _MM_SHUFFLE(2, 0, 2, 0)));
   a = t;
 
+  __m128i minusone = _mm_set1_epi32(0xffffffff);
+
   return _mm_not_si128(_mm_avg_epu8(_mm_not_si128(a), _mm_not_si128(b)));
 }
 
 /* Before Nehalem _mm_loadu_si128 could be very slow, this trick is a little
  * faster. Once enough people are on architectures where _mm_loadu_si128 is
  * fast we can migrate to it.
  */
 MOZ_ALWAYS_INLINE __m128i loadUnaligned128(const __m128i *aSource)
--- a/gfx/2d/PathD2D.cpp
+++ b/gfx/2d/PathD2D.cpp
@@ -1,13 +1,15 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#pragma once
+
 #include "PathD2D.h"
 #include "HelpersD2D.h"
 #include <math.h>
 #include "DrawTargetD2D.h"
 #include "Logging.h"
 
 #ifndef M_PI
 #define M_PI 3.14159265358979323846
--- a/gfx/layers/d3d10/ImageLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp
@@ -479,17 +479,17 @@ RemoteDXGITextureImage::GetD3D10TextureB
   nsRefPtr<ID3D10Texture2D> texture;
   aDevice->OpenSharedResource(mHandle, __uuidof(ID3D10Texture2D), getter_AddRefs(texture));
 
   if (!texture) {
     NS_WARNING("Failed to get texture for shared texture handle.");
     return nsnull;
   }
 
-  nsAutoPtr<TextureD3D10BackendData> data(new TextureD3D10BackendData());
+  nsAutoPtr<TextureD3D10BackendData> data = new TextureD3D10BackendData();
 
   data->mTexture = texture;
 
   aDevice->CreateShaderResourceView(texture, NULL, getter_AddRefs(data->mSRView));
 
   SetBackendData(LayerManager::LAYERS_D3D10, data);
 
   return data.forget();