Description: Use deterministic values for gradients
 Previously, Prawn used #hash for gradients. Unfortunately, this uses
 #object_id internally and prevent Prawn to create PDF using gradients
 in a reproducible manner.
 .
 We now instead use an internal Hash with an incremental index starting
 at 1.
Author: Jérémy Bobbio <lunar@debian.org>
Forwarded: https://github.com/prawnpdf/prawn/pull/844
Last-Update: 2016-06-07

--- a/lib/prawn/graphics/patterns.rb
+++ b/lib/prawn/graphics/patterns.rb
@@ -78,7 +78,7 @@
       def gradient_registry_key(gradient, opts)
         _x1, _y1, x2, y2, transformation = gradient_coordinates(gradient, opts)
 
-        if gradient[1].is_a?(Array) # axial
+        key = if gradient[1].is_a?(Array) # axial
           [
             transformation,
             x2, y2,
@@ -92,7 +92,16 @@
             gradient[3],
             gradient[4], gradient[5]
           ]
-        end.hash
+        end
+        unless @gradient_key_registry
+          @gradient_key_registry ||= {}
+          @gradient_key_index = 1
+        end
+        unless @gradient_key_registry.include?(key)
+          @gradient_key_registry[key] = @gradient_key_index
+          @gradient_key_index += 1
+        end
+        @gradient_key_registry[key]
       end
 
       def gradient_registry
