Merge "fix two-sided multiple-copy jobs" am: 86fdf4a745
am: f6975e3532

Change-Id: I9955f3878ec97815a359af945f3af60d319d3a86
diff --git a/jni/plugins/genPCLm/src/genPCLm.cpp b/jni/plugins/genPCLm/src/genPCLm.cpp
index 5226385..0aab701 100644
--- a/jni/plugins/genPCLm/src/genPCLm.cpp
+++ b/jni/plugins/genPCLm/src/genPCLm.cpp
@@ -1712,10 +1712,13 @@
                 destColorSpace);
     }
 
-#ifdef SUPPORT_WHITE_STRIPS
-    bool whiteStrip = isWhiteStrip(pInBuffer, thisHeight * currSourceWidth * srcNumComponents);
-#else
     bool whiteStrip = false;
+#ifdef SUPPORT_WHITE_STRIPS
+    if (!firstStrip) {
+        // PCLm does not print a blank page if all the strips are marked as "/Name /WhiteStrip"
+        // so only apply /WhiteStrip to strips after the first
+        whiteStrip = isWhiteStrip(pInBuffer, thisHeight * currSourceWidth * srcNumComponents);
+    }
 #endif
 
     if (currCompressionDisposition == compressDCT) {
@@ -1743,8 +1746,8 @@
             }
 
             free(tmpStrip);
-            firstStrip = false;
         }
+        firstStrip = false;
 
         // We are always going to compress the full strip height, even though the image may be less;
         // this allows the compressed images to be symmetric
@@ -1796,8 +1799,8 @@
                         numPartialScanlinesToInject, destColorSpace, true);
             }
             free(tmpStrip);
-            firstStrip = false;
         }
+        firstStrip = false;
 
         if (newStripPtr) {
             result = compress(scratchBuffer, &destSize, (const Bytef *) newStripPtr,
@@ -1836,8 +1839,8 @@
             }
 
             free(tmpStrip);
-            firstStrip = false;
         }
+        firstStrip = false;
 
         if (newStripPtr) {
             compSize = RLEEncodeImage(newStripPtr, scratchBuffer,
diff --git a/jni/plugins/lib_pclm.c b/jni/plugins/lib_pclm.c
index 416a745..5f25e92 100644
--- a/jni/plugins/lib_pclm.c
+++ b/jni/plugins/lib_pclm.c
@@ -273,6 +273,10 @@
     if (page_number == -1) {
         LOGI("_end_page(): writing blank page");
         _start_page(job_info, 0, 0);
+        unsigned char blank_data[1] = {0xFF};
+        PCLmEncapsulate(job_info->pclmgen_obj, (void *) blank_data, 1, 1,
+                (void **) &job_info->pclm_output_buffer, &outBuffSize);
+        _WRITE(job_info, (const char *) job_info->pclm_output_buffer, outBuffSize);
     }
     LOGI("_end_page()");
     PCLmEndPage(job_info->pclmgen_obj, (void **) &job_info->pclm_output_buffer, &outBuffSize);