graphics_utils: unswizzle blocklinear layout for tegra

Apparently the pixel order inside an individual GOB is not linear, so proper
unswizzling is required.

BUG=chromium:655235
TEST=test_that graphics_Sanity, keep and inspect unresized screenshot

Change-Id: Ibaa8603ae7eb8a14334f9ef536813520b785911d
Reviewed-on: https://chromium-review.googlesource.com/397941
Tested-by: Haixia Shi <hshi@chromium.org>
Commit-Queue: Haixia Shi <hshi@chromium.org>
Trybot-Ready: Haixia Shi <hshi@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
diff --git a/client/cros/graphics/drm.py b/client/cros/graphics/drm.py
index 8a5faf4..96dbef7 100644
--- a/client/cros/graphics/drm.py
+++ b/client/cros/graphics/drm.py
@@ -389,13 +389,12 @@
             gob = m.read(gobSize)
             iterGob = iter(gob)
             gobLeft = gobX * gobWidth
-            for y in range(gobHeight):
-                if gobTop + y >= fb.height:
-                    break
-                for x in range(gobWidth):
-                    rgb = unformat(iterGob)
-                    if gobLeft + x < fb.width:
-                        image.putpixel((gobLeft + x, gobTop + y), rgb)
+            for i in range(gobWidth * gobHeight):
+                rgb = unformat(iterGob)
+                x = gobLeft + (((i >> 3) & 8) | ((i >> 1) & 4) | (i & 3))
+                y = gobTop + ((i >> 7 << 3) | ((i >> 3) & 6) | ((i >> 2) & 1))
+                if x < fb.width and y < fb.height:
+                    image.putpixel((x, y), rgb)
             offset += gobSize
     fb.unmap()