[Pkg-javascript-commits] [pdf.js] 26/161: JBIG2 20% faster SimpleSegmentVisitor_drawBitmap

David Prévot taffit at moszumanska.debian.org
Sat Apr 19 14:16:19 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit e862c64bb88ed6bbdfafb4fb804055f9cfa4473c
Author: p01 <p01 at opera.com>
Date:   Mon Mar 3 11:52:24 2014 +0100

    JBIG2 20% faster SimpleSegmentVisitor_drawBitmap
    
    Moved the switch(combinationOperator) outside the width and height loops
    Check bitmap[i][j] before applying the switch(combinationOperator)
---
 src/core/jbig2.js | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 22d8c91..945c382 100755
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -938,34 +938,42 @@ var Jbig2Image = (function Jbig2ImageClosure() {
       var combinationOperator = pageInfo.combinationOperatorOverride ?
         regionInfo.combinationOperator : pageInfo.combinationOperator;
       var buffer = this.buffer;
-      for (var i = 0; i < height; i++) {
-        var mask = 128 >> (regionInfo.x & 7);
-        var offset = (i + regionInfo.y) * rowSize + (regionInfo.x >> 3);
-        switch (combinationOperator) {
-          case 0: // OR
+      switch (combinationOperator) {
+        case 0: // OR
+          for (var i = 0; i < height; i++) {
+            var mask = 128 >> (regionInfo.x & 7);
+            var offset = (i + regionInfo.y) * rowSize + (regionInfo.x >> 3);
             for (var j = 0; j < width; j++) {
-              buffer[offset] |= bitmap[i][j] ? mask : 0;
+              if (bitmap[i][j]) {
+                buffer[offset] |= mask;
+              }
               mask >>= 1;
               if (!mask) {
                 mask = 128;
                 offset++;
               }
             }
-            break;
-          case 2: // XOR
+          }
+        break;
+        case 2: // XOR
+          for (var i = 0; i < height; i++) {
+            var mask = 128 >> (regionInfo.x & 7);
+            var offset = (i + regionInfo.y) * rowSize + (regionInfo.x >> 3);
             for (var j = 0; j < width; j++) {
-              buffer[offset] ^= bitmap[i][j] ? mask : 0;
+              if (bitmap[i][j]) {
+                buffer[offset] ^= mask;
+              }
               mask >>= 1;
               if (!mask) {
                 mask = 128;
                 offset++;
               }
             }
-            break;
-          default:
-            error('JBIG2 error: operator ' + combinationOperator +
-                  ' is not supported');
-        }
+          }
+          break;
+        default:
+          error('JBIG2 error: operator ' + combinationOperator +
+                ' is not supported');
       }
     },
     onImmediateGenericRegion:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list