Bug 1393196 Some illustrative examples of gfx/ signed/unsigned comparisons draft
authorTom Ritter <tom@mozilla.com>
Wed, 23 Aug 2017 15:07:32 -0500
changeset 651501 b880c0da518d1e79afa36a478fc4b8baa46d2697
parent 651500 9cf54b1b20781053345cbab6d7ec52e7b03cb333
child 727734 6e59a895a6ff44f4279698411bedad1538058e9a
push id75751
push userbmo:tom@mozilla.com
push dateWed, 23 Aug 2017 20:10:42 +0000
bugs1393196
milestone57.0a1
Bug 1393196 Some illustrative examples of gfx/ signed/unsigned comparisons MozReview-Commit-ID: 3JAolFMhZ9N
gfx/gl/SharedSurfaceANGLE.cpp
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/MLGDeviceD3D11.cpp
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
--- a/gfx/gl/SharedSurfaceANGLE.cpp
+++ b/gfx/gl/SharedSurfaceANGLE.cpp
@@ -278,17 +278,17 @@ SharedSurface_ANGLEShareHandle::Readback
     const uint8_t* data = reinterpret_cast<uint8_t*>(scopedLock.mSubresource.pData);
     uint32_t srcStride = scopedLock.mSubresource.RowPitch;
 
     gfx::DataSourceSurface::ScopedMap map(out_surface, gfx::DataSourceSurface::WRITE);
     if (!map.IsMapped()) {
         return false;
     }
 
-    if (map.GetStride() == srcStride) {
+    if ((uint32_t)map.GetStride() == srcStride) {
         memcpy(map.GetData(), data, out_surface->GetSize().height * map.GetStride());
     } else {
         const uint8_t bytesPerPixel = BytesPerPixel(out_surface->GetFormat());
         for (int32_t i = 0; i < out_surface->GetSize().height; i++) {
             memcpy(map.GetData() + i * map.GetStride(),
                    data + i * srcStride,
                    bytesPerPixel * out_surface->GetSize().width);
         }
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -1254,17 +1254,18 @@ CompositorD3D11::PrepareViewport(const g
 void
 CompositorD3D11::ForcePresent()
 {
   LayoutDeviceIntSize size = mWidget->GetClientSize();
 
   DXGI_SWAP_CHAIN_DESC desc;
   mSwapChain->GetDesc(&desc);
 
-  if (desc.BufferDesc.Width == size.width && desc.BufferDesc.Height == size.height) {
+  MOZ_ASSERT(size.width > 0 && size.height > 0);
+  if (desc.BufferDesc.Width == (unsigned int)size.width && desc.BufferDesc.Height == (unsigned int)size.height) {
     mSwapChain->Present(0, 0);
     if (mIsDoubleBuffered) {
       // Make sure we present what was the front buffer before that we know is completely
       // valid. This non v-synced present should be pretty much 'free' for a flip chain.
       mSwapChain->Present(0, 0);
     }
   }
 }
@@ -1301,18 +1302,18 @@ CompositorD3D11::VerifyBufferSize()
 
   hr = mSwapChain->GetDesc(&swapDesc);
   if (FAILED(hr)) {
     gfxCriticalError() << "Failed to get the description " << hexa(hr) << ", " << mSize << ", " << (int)mVerifyBuffersFailed;
     HandleError(hr);
     return false;
   }
 
-  if (((swapDesc.BufferDesc.Width == mSize.width &&
-       swapDesc.BufferDesc.Height == mSize.height) ||
+  if (((swapDesc.BufferDesc.Width == (unsigned int)mSize.width &&
+        swapDesc.BufferDesc.Height == (unsigned int)mSize.height) ||
        mSize.width <= 0 || mSize.height <= 0) &&
       !mVerifyBuffersFailed) {
     return true;
   }
 
   ID3D11RenderTargetView* view = nullptr;
   mContext->OMSetRenderTargets(1, &view, nullptr);
 
--- a/gfx/layers/d3d11/MLGDeviceD3D11.cpp
+++ b/gfx/layers/d3d11/MLGDeviceD3D11.cpp
@@ -508,17 +508,19 @@ MLGSwapChainD3D11::Present()
 void
 MLGSwapChainD3D11::ForcePresent()
 {
   DXGI_SWAP_CHAIN_DESC desc;
   mSwapChain->GetDesc(&desc);
 
   LayoutDeviceIntSize size = mWidget->GetClientSize();
 
-  if (desc.BufferDesc.Width != size.width || desc.BufferDesc.Height != size.height) {
+
+  MOZ_ASSERT(size.width > 0 && size.height > 0);
+  if (desc.BufferDesc.Width != (unsigned int)size.width || desc.BufferDesc.Height != (unsigned int)size.height) {
     return;
   }
 
   mSwapChain->Present(0, 0);
   if (mIsDoubleBuffered) {
     // Make sure we present the old front buffer since we know it is completely
     // valid. This non-vsynced present should be pretty much 'free' for a flip
     // chain.
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -1332,17 +1332,18 @@ DataTextureSourceD3D11::Update(DataSourc
   if ((mSize.width <= maxSize && mSize.height <= maxSize) ||
       (mFlags & TextureFlags::DISALLOW_BIGIMAGE)) {
 
     if (mTexture) {
       D3D11_TEXTURE2D_DESC currentDesc;
       mTexture->GetDesc(&currentDesc);
 
       // Make sure there's no size mismatch, if there is, recreate.
-      if (currentDesc.Width != mSize.width || currentDesc.Height != mSize.height ||
+      MOZ_ASSERT(mSize.width > 0 && mSize.height > 0);
+      if (currentDesc.Width != (unsigned int)mSize.width || currentDesc.Height != (unsigned int)mSize.height ||
           currentDesc.Format != dxgiFormat) {
         mTexture = nullptr;
         // Make sure we upload the whole surface.
         aDestRegion = nullptr;
       }
     }
 
     nsIntRegion *regionToUpdate = aDestRegion;
--- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
@@ -290,17 +290,18 @@ CrossProcessCompositorBridgeParent::Recv
   ContentDeviceData compositor;
 
   DeviceManagerDx* dm = DeviceManagerDx::Get();
 
   // Check that the D3D11 device sequence numbers match.
   D3D11DeviceStatus status;
   dm->ExportDeviceInfo(&status);
 
-  if (sequenceNum == status.sequenceNumber() && !dm->HasDeviceReset()) {
+  MOZ_RELEASE_ASSERT(status.sequenceNumber() > 0);
+  if (sequenceNum == (unsigned int)status.sequenceNumber() && !dm->HasDeviceReset()) {
     *isContentOnlyTDR = true;
   }
 
 #endif
   return IPC_OK();
 };
 
 void