Bug 982275 - Followup: Fix some compiler warnings that were errors on gcc. r=bustage
authorBas Schouten <bschouten@mozilla.com>
Wed, 12 Mar 2014 03:55:07 +0100
changeset 191322 e358272c309364ea14f2afe9743adc6310948af3
parent 191321 244a1a183d2a83ba2103b885e56c0c762a521a4f
child 191323 6c80860a2266fc9ca31fd48cde00d9ce98b1a96d
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs982275
milestone30.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 982275 - Followup: Fix some compiler warnings that were errors on gcc. r=bustage
gfx/layers/composite/ContainerLayerComposite.cpp
gfx/layers/composite/TextRenderer.cpp
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -133,17 +133,17 @@ static void DrawLayerInfo(const nsIntRec
     return;
   }
 
   nsAutoCString layerInfo;
   aLayer->PrintInfo(layerInfo, "");
 
   nsIntRegion visibleRegion = aLayer->GetVisibleRegion();
 
-  uint32_t maxWidth = visibleRegion.GetBounds().width < 500 ? visibleRegion.GetBounds().width : 500;
+  uint32_t maxWidth = std::min<uint32_t>(visibleRegion.GetBounds().width, 500);
 
   nsIntPoint topLeft = visibleRegion.GetBounds().TopLeft();
   aManager->GetTextRenderer()->RenderText(layerInfo.get(), gfx::IntPoint(topLeft.x, topLeft.y),
                                           aLayer->GetEffectiveTransform(), 16,
                                           maxWidth);
 
 }
 
--- a/gfx/layers/composite/TextRenderer.cpp
+++ b/gfx/layers/composite/TextRenderer.cpp
@@ -28,17 +28,17 @@ static void PNGAPI info_callback(png_str
 static void PNGAPI row_callback(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass)
 {
   MOZ_ASSERT(sTextureFormat == SurfaceFormat::B8G8R8A8);
 
   DataSourceSurface::MappedSurface map = static_cast<TextRenderer*>(png_get_progressive_ptr(png_ptr))->GetSurfaceMap();
 
   uint32_t* dst = (uint32_t*)(map.mData + map.mStride * row_num);
 
-  for (int x = 0; x < sTextureWidth; x++) {
+  for (uint32_t x = 0; x < sTextureWidth; x++) {
     // We blend to a transparent white background, this will make text readable
     // even if it's on a dark background. Without hurting our ability to
     // interact with the content behind the text.
     Float alphaValue = Float(0xFF - new_row[x]) / 255.0f;
     Float baseValue = sBackgroundOpacity * (1.0f - alphaValue);
     Color pixelColor(baseValue, baseValue, baseValue, baseValue + alphaValue);
     dst[x] = pixelColor.ToABGR();
   }
@@ -63,27 +63,27 @@ TextRenderer::RenderText(const string& a
   Float scaleFactor = Float(aTextSize) / Float(sCellHeight);
 
   aTargetPixelWidth /= scaleFactor;
 
   uint32_t numLines = 1;
   uint32_t maxWidth = 0;
   uint32_t lineWidth = 0;
   // Calculate the size of the surface needed to draw all the glyphs.
-  for (int i = 0; i < aText.length(); i++) {
+  for (uint32_t i = 0; i < aText.length(); i++) {
     // Insert a line break if we go past the TargetPixelWidth.
     // XXX - this has the downside of overrunning the intended width, causing
     // things at the edge of a window to be cut off.
     if (aText[i] == '\n' || (aText[i] == ' ' && lineWidth > aTargetPixelWidth)) {
       numLines++;
       lineWidth = 0;
       continue;
     }
 
-    lineWidth += sGlyphWidths[aText[i]];
+    lineWidth += sGlyphWidths[uint32_t(aText[i])];
     maxWidth = std::max(lineWidth, maxWidth);
   }
 
   // Create a surface to draw our glyphs to.
   RefPtr<DataSourceSurface> textSurf =
     Factory::CreateDataSourceSurface(IntSize(maxWidth, numLines * sCellHeight), sTextureFormat);
 
   DataSourceSurface::MappedSurface map;
@@ -92,34 +92,34 @@ TextRenderer::RenderText(const string& a
   // Initialize the surface to transparent white.
   memset(map.mData, uint8_t(sBackgroundOpacity * 255.0f),
          numLines * sCellHeight * map.mStride);
 
   uint32_t currentXPos = 0;
   uint32_t currentYPos = 0;
 
   // Copy our glyphs onto the surface.
-  for (int i = 0; i < aText.length(); i++) {
+  for (uint32_t i = 0; i < aText.length(); i++) {
     if (aText[i] == '\n' || (aText[i] == ' ' && currentXPos > aTargetPixelWidth)) {
       currentYPos += sCellHeight;
       currentXPos = 0;
       continue;
     }
 
     uint32_t glyphXOffset = aText[i] % (sTextureWidth / sCellWidth) * sCellWidth * BytesPerPixel(sTextureFormat);
     uint32_t truncatedLine = aText[i] / (sTextureWidth / sCellWidth);
     uint32_t glyphYOffset =  truncatedLine * sCellHeight * mMap.mStride;
 
     for (int y = 0; y < 16; y++) {
       memcpy(map.mData + (y + currentYPos) * map.mStride + currentXPos * BytesPerPixel(sTextureFormat),
              mMap.mData + glyphYOffset + y * mMap.mStride + glyphXOffset,
-             sGlyphWidths[aText[i]] * BytesPerPixel(sTextureFormat));
+             sGlyphWidths[uint32_t(aText[i])] * BytesPerPixel(sTextureFormat));
     }
 
-    currentXPos += sGlyphWidths[aText[i]];
+    currentXPos += sGlyphWidths[uint32_t(aText[i])];
   }
 
   textSurf->Unmap();
 
   RefPtr<DataTextureSource> src = mCompositor->CreateDataTextureSource();
 
   if (!src->Update(textSurf)) {
     // Upload failed.