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

Unified Diff: sky/examples/fps-counter.sky

Issue 980323003: Clean up examples directory (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « sky/examples/flights-app/index.sky ('k') | sky/examples/htmlish/framework/element.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/fps-counter.sky
diff --git a/sky/examples/fps-counter.sky b/sky/examples/fps-counter.sky
deleted file mode 100644
index 4e1c881bb1fca6c204e3df9063bf28ec9495cad6..0000000000000000000000000000000000000000
--- a/sky/examples/fps-counter.sky
+++ /dev/null
@@ -1,68 +0,0 @@
-#!mojo mojo:sky_viewer
-<!--
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
--->
-<import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement" />
-
-<sky-element name="fps-counter" attributes="showHistory:boolean">
-<template>
- <template if="{{ showHistory }}">
- <template repeat="{{ deltas }}">
- <div>{{ roundedValue }} ms</div>
- </template>
- <div>max = {{ max }} ms</div>
- </template>
- <div>fps = {{ frameRate }} Hz</div>
-</template>
-<script>
-const kMaxDeltaLength = 10;
-
-class Delta {
- constructor(value) {
- this.value = value;
- this.roundedValue = value.toFixed(2);
- Object.preventExtensions(this);
- }
-}
-
-module.exports = class extends SkyElement {
- created() {
- this.frameRate = "...";
- this.max = 0;
- this.sum = 0;
- this.lastTimeStamp = 0;
- this.rafId = 0;
- this.deltas = [];
- for (var i = 0; i < kMaxDeltaLength; ++i)
- this.deltas[i] = new Delta(0);
- }
- attached() {
- this.scheduleTick();
- }
- detached() {
- cancelAnimationFrame(this.rafId);
- this.rafId = 0;
- }
- scheduleTick() {
- this.rafId = requestAnimationFrame(this.tick.bind(this));
- }
- tick(timeStamp) {
- this.scheduleTick();
- var lastTimeStamp = this.lastTimeStamp;
- this.lastTimeStamp = timeStamp;
- if (!lastTimeStamp)
- return;
- var delta = new Delta(timeStamp - lastTimeStamp);
- var removedDelta = this.deltas.shift();
- this.deltas.push(delta);
- this.sum -= removedDelta.value;
- this.sum += delta.value;
- var avg = this.sum / this.deltas.length;
- this.frameRate = (1000 / avg).toFixed(2);
- this.max = Math.max(delta.value, this.max).toFixed(2);
- }
-}.register();
-</script>
-</sky-element>
« no previous file with comments | « sky/examples/flights-app/index.sky ('k') | sky/examples/htmlish/framework/element.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698