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 655119 aa4fde4fc6ad8896797bd5c8d7335ae142a614b5
parent 655118 991e5568fef71af0b6fda7712a9fc2497e6cca34
child 655120 8d0c7e2d39876535b9a458ac51390f50609d662d
push id76778
push userbmo:tom@mozilla.com
push dateTue, 29 Aug 2017 17:35:26 +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