Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: third_party/WebKit/ManualTests/compositor-worker/parallax.js

Issue 1547893003: WIP - compositor worker mega patch. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/ManualTests/compositor-worker/parallax.js
diff --git a/third_party/WebKit/ManualTests/compositor-worker/parallax.js b/third_party/WebKit/ManualTests/compositor-worker/parallax.js
new file mode 100644
index 0000000000000000000000000000000000000000..f92be635e54d3e7a6edac711f0bdf8da8ef1037f
--- /dev/null
+++ b/third_party/WebKit/ManualTests/compositor-worker/parallax.js
@@ -0,0 +1,50 @@
+(function(scope) {
+ "use strict";
+
+ scope.isMain = function() {
+ return scope.window;
+ };
+
+ scope.tick = function(timestamp) {
+ console.log("tick (scrollTop = " + scroller.scrollTop + ", transform = " +
+ bg.transform + ")");
+ var t = bg.transform;
+ t.m42 = Math.round(scroller.scrollTop);
+ bg.transform = t;
+ var t = bg_parallax.transform;
+ t.m42 = 0.8 * scroller.scrollTop;
+ bg_parallax.transform = t;
+ scope.requestAnimationFrame(tick);
+ };
+
+ scope.initWorker = function() {
+ console.log("init worker");
+
+ self.onmessage = function(e) {
+ console.log("onmessage");
+
+ scope.scroller = e.data[0];
+ scope.bg = e.data[1];
+ scope.bg_parallax = e.data[2];
+
+ scope.requestAnimationFrame(tick);
+ };
+ };
+
+ scope.initMain = function() {
+ console.log("init main");
+
+ scope.worker = new CompositorWorker("parallax.js");
+
+ scope.scroller = new CompositorProxy(document.getElementById("scroller"), ['scrollTop']);
+ scope.bg = new CompositorProxy(document.getElementById("bg"), ['transform']);
+ scope.bg_parallax = new CompositorProxy(document.getElementById("bg-parallax"), ['transform']);
+
+ worker.postMessage([scroller, bg, bg_parallax]);
+ };
+
+ if (isMain())
+ initMain();
+ else
+ initWorker();
+})(self);

Powered by Google App Engine
This is Rietveld 408576698