From 61502911db84cd4ce44dedb7df662389d6a321be Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 4 Jun 2012 13:02:02 +0200 Subject: [PATCH] Bug 756996 - GCC warnings in gfx/2d r=bas --- gfx/2d/DrawTargetD2D.cpp | 15 +++++++----- gfx/2d/HelpersD2D.h | 34 +++++++++++++++------------- gfx/2d/ImageScalingSSE2.cpp | 6 ----- gfx/2d/PathD2D.cpp | 2 -- gfx/layers/d3d10/ImageLayerD3D10.cpp | 2 +- 5 files changed, 28 insertions(+), 31 deletions(-) diff --git a/gfx/2d/DrawTargetD2D.cpp b/gfx/2d/DrawTargetD2D.cpp index 0091545b2ea2..3428dd6a8653 100644 --- a/gfx/2d/DrawTargetD2D.cpp +++ b/gfx/2d/DrawTargetD2D.cpp @@ -129,8 +129,7 @@ public: RefPtr sink; invClippedArea->Open(byRef(sink)); - HRESULT hr = rectGeom->CombineWithGeometry(mClippedArea, D2D1_COMBINE_MODE_EXCLUDE, - NULL, sink); + rectGeom->CombineWithGeometry(mClippedArea, D2D1_COMBINE_MODE_EXCLUDE, NULL, sink); sink->Close(); RefPtr brush; @@ -293,6 +292,8 @@ DrawTargetD2D::DrawSurface(SourceSurface *aSurface, srcRect.y -= (uint32_t)aSource.y; } break; + default: + break; } rt->DrawBitmap(bitmap, D2DRect(aDest), aOptions.mAlpha, D2DFilter(aSurfOptions.mFilter), D2DRect(srcRect)); @@ -699,6 +700,8 @@ DrawTargetD2D::CopySurface(SourceSurface *aSurface, AddDependencyOnSource(srcSurf); } break; + default: + return; } if (!bitmap) { @@ -2009,6 +2012,8 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha) } } break; + default: + break; } mRT->CreateBitmapBrush(bitmap, @@ -2276,8 +2281,6 @@ DrawTargetD2D::CreatePartialBitmapForSurface(DataSourceSurface *aSurface, Matrix 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)), @@ -2311,13 +2314,13 @@ DrawTargetD2D::CreatePartialBitmapForSurface(DataSourceSurface *aSurface, Matrix scaleSize.width = max(Distance(topRight, topLeft), Distance(bottomRight, bottomLeft)); scaleSize.height = max(Distance(topRight, bottomRight), Distance(topLeft, bottomLeft)); - if (scaleSize.width > mRT->GetMaximumBitmapSize()) { + if (unsigned(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 (scaleSize.height > mRT->GetMaximumBitmapSize()) { + if (unsigned(scaleSize.height) > mRT->GetMaximumBitmapSize()) { scaleSize.height = 4095; } diff --git a/gfx/2d/HelpersD2D.h b/gfx/2d/HelpersD2D.h index c32095e1925d..4386c0eebdea 100644 --- a/gfx/2d/HelpersD2D.h +++ b/gfx/2d/HelpersD2D.h @@ -32,7 +32,7 @@ static inline D2D1_RECT_F D2DRect(const Rect &aRect) static inline D2D1_EXTEND_MODE D2DExtend(ExtendMode aExtendMode) { - D2D1_EXTEND_MODE extend = D2D1_EXTEND_MODE_CLAMP; + D2D1_EXTEND_MODE extend; switch (aExtendMode) { case EXTEND_REPEAT: extend = D2D1_EXTEND_MODE_WRAP; @@ -40,6 +40,8 @@ static inline D2D1_EXTEND_MODE D2DExtend(ExtendMode aExtendMode) case EXTEND_REFLECT: extend = D2D1_EXTEND_MODE_MIRROR; break; + default: + extend = D2D1_EXTEND_MODE_CLAMP; } return extend; @@ -50,9 +52,9 @@ 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) @@ -60,9 +62,9 @@ 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) @@ -93,9 +95,9 @@ static inline SurfaceFormat ToPixelFormat(const D2D1_PIXEL_FORMAT &aFormat) } else { return FORMAT_B8G8R8A8; } + default: + return FORMAT_B8G8R8A8; } - - return FORMAT_B8G8R8A8; } static inline Rect ToRect(const D2D1_RECT_F &aRect) @@ -112,9 +114,9 @@ static inline DXGI_FORMAT DXGIFormat(SurfaceFormat aFormat) 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) @@ -122,9 +124,9 @@ 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) @@ -132,7 +134,7 @@ static inline D2D1_PIXEL_FORMAT D2DPixelFormat(SurfaceFormat aFormat) return D2D1::PixelFormat(DXGIFormat(aFormat), AlphaMode(aFormat)); } -static bool IsPatternSupportedByD2D(const Pattern &aPattern) +static inline bool IsPatternSupportedByD2D(const Pattern &aPattern) { if (aPattern.GetType() != PATTERN_RADIAL_GRADIENT) { return false; @@ -173,7 +175,7 @@ struct ShaderConstantRectD3D10 operator float* () { return &mX; } }; -static DWRITE_MATRIX +static inline DWRITE_MATRIX DWriteMatrixFromMatrix(Matrix &aMatrix) { DWRITE_MATRIX mat; @@ -188,7 +190,7 @@ DWriteMatrixFromMatrix(Matrix &aMatrix) class AutoDWriteGlyphRun : public DWRITE_GLYPH_RUN { - static const int kNumAutoGlyphs = 256; + static const unsigned kNumAutoGlyphs = 256; public: AutoDWriteGlyphRun() { @@ -203,7 +205,7 @@ public: } } - void allocate(int aNumGlyphs) { + void allocate(unsigned aNumGlyphs) { glyphCount = aNumGlyphs; if (aNumGlyphs <= kNumAutoGlyphs) { glyphIndices = &mAutoIndices[0]; @@ -222,7 +224,7 @@ private: UINT16 mAutoIndices[kNumAutoGlyphs]; }; -static void +static inline void DWriteGlyphRunFromGlyphs(const GlyphBuffer &aGlyphs, ScaledFontDWrite *aFont, AutoDWriteGlyphRun *run) { run->allocate(aGlyphs.mNumGlyphs); diff --git a/gfx/2d/ImageScalingSSE2.cpp b/gfx/2d/ImageScalingSSE2.cpp index 390b370c7efc..334fce60d97d 100644 --- a/gfx/2d/ImageScalingSSE2.cpp +++ b/gfx/2d/ImageScalingSSE2.cpp @@ -89,8 +89,6 @@ MOZ_ALWAYS_INLINE __m128i avg_sse2_8x2(__m128i *a, __m128i *b, __m128i *c, __m12 __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))); @@ -98,8 +96,6 @@ MOZ_ALWAYS_INLINE __m128i avg_sse2_8x2(__m128i *a, __m128i *b, __m128i *c, __m12 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))); } @@ -109,8 +105,6 @@ MOZ_ALWAYS_INLINE __m128i avg_sse2_8x1_4x1(__m128i a, __m128i b) 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))); } diff --git a/gfx/2d/PathD2D.cpp b/gfx/2d/PathD2D.cpp index 5ff6eb83f78c..41681fcf9a6a 100644 --- a/gfx/2d/PathD2D.cpp +++ b/gfx/2d/PathD2D.cpp @@ -3,8 +3,6 @@ * 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 diff --git a/gfx/layers/d3d10/ImageLayerD3D10.cpp b/gfx/layers/d3d10/ImageLayerD3D10.cpp index 0a392787aa12..fb13993893e7 100644 --- a/gfx/layers/d3d10/ImageLayerD3D10.cpp +++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp @@ -484,7 +484,7 @@ RemoteDXGITextureImage::GetD3D10TextureBackendData(ID3D10Device *aDevice) return nsnull; } - nsAutoPtr data = new TextureD3D10BackendData(); + nsAutoPtr data(new TextureD3D10BackendData()); data->mTexture = texture;