public RectInt32 GetDefaultDifferentialMaxBounds(TChanges oldChanges, TChanges newChanges)
        {
            if (oldChanges.Equals((ReferenceValue)newChanges))
            {
                return(new RectInt32(newChanges.GetMaxRenderBounds().Location, SizeInt32.Zero));
            }
            RectInt32 maxRenderBounds = oldChanges.GetMaxRenderBounds();
            RectInt32 b = newChanges.GetMaxRenderBounds();

            return(RectInt32.Union(maxRenderBounds, b));
        }
 private void UpdateLayerOverlay()
 {
     this.tool.VerifyAccess <TTool>();
     using (this.updateLayerOverlayRegion.UseEnterScope())
     {
         TChanges  local;
         RectInt32?nullable;
         RectInt32?nullable2;
         RectInt32?nullable3;
         RectInt32?nullable4;
         BitmapLayerToolLayerOverlay <TTool, TChanges> overlay2;
         RectInt32 differentialMaxBounds;
         RectInt32 num3;
         BitmapLayerToolLayerOverlay <TTool, TChanges> layerOverlay = this.layerOverlay;
         if (layerOverlay == null)
         {
             local     = default(TChanges);
             nullable  = null;
             nullable2 = null;
         }
         else
         {
             local     = layerOverlay.Changes;
             nullable  = new RectInt32?(local.GetMaxRenderBounds());
             nullable2 = new RectInt32?(layerOverlay.AffectedBounds);
         }
         TChanges changes = this.tool.Changes;
         if (changes == null)
         {
             nullable3 = null;
             nullable4 = null;
             overlay2  = null;
         }
         else
         {
             nullable3 = new RectInt32?(changes.GetMaxRenderBounds());
             overlay2  = this.CreateLayerOverlay(this.tool.ActiveLayer, changes);
             if (overlay2 == null)
             {
                 ExceptionUtil.ThrowInternalErrorException("CreateLayerOverlay() -> null");
             }
             nullable4 = new RectInt32?(overlay2.AffectedBounds);
         }
         RectInt32 num = this.tool.Document.Bounds();
         if ((local == null) && (changes != null))
         {
             differentialMaxBounds = nullable3.Value;
             num3 = nullable4.Value;
         }
         else if ((local != null) && (changes == null))
         {
             differentialMaxBounds = nullable.Value;
             num3 = nullable2.Value;
         }
         else
         {
             differentialMaxBounds = this.tool.GetDifferentialMaxBounds(local, changes);
             num3 = RectInt32.Union(nullable2.Value, nullable4.Value);
         }
         RectInt32 num4 = RectInt32.Intersect(differentialMaxBounds, num3);
         this.layerOverlay = overlay2;
         this.tool.DocumentCanvas.ReplaceLayerOverlay(this.tool.ActiveLayer, layerOverlay, overlay2, new RectInt32?(num4));
     }
 }