Skip to content

Instantly share code, notes, and snippets.

@sfoster
Created November 3, 2011 22:44
Show Gist options
  • Save sfoster/1338146 to your computer and use it in GitHub Desktop.
Save sfoster/1338146 to your computer and use it in GitHub Desktop.
Steppe rgba buffer data micro-optimization
diff --git a/js/Steppe/Renderer.js b/js/Steppe/Renderer.js
index 77bf78b..22f16bc 100644
--- a/js/Steppe/Renderer.js
+++ b/js/Steppe/Renderer.js
@@ -361,20 +361,15 @@ var Steppe = (function(Steppe) {
(top * (framebufferImageData.width << 2)) +
(ray << 2);
-
- var bufferR = (color >> 24) & 0xff,
- bufferG = (color >> 16) & 0xff,
- bufferB = (color >> 8) & 0xff,
- bufferA = 0xff;
for (var j = 0; j < bottom - top + 1; ++j) {
for (var i = 0; i < _quality; ++i) {
framebufferData[index] =
- bufferR;
+ (color >> 24) & 0xff;
framebufferData[index + 1] =
- bufferG;
+ (color >> 16) & 0xff;
framebufferData[index + 2] =
- bufferB;
- framebufferData[index + 3] = bufferA;
+ (color >> 8) & 0xff;
+ framebufferData[index + 3] = 0xff;
index += 4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment