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

Unified Diff: tools/cc-frame-viewer/src/base/range.js

Issue 12225131: [cc] Initial checkin of cc-frame-viewer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 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 | « tools/cc-frame-viewer/src/base/gl_matrix_test.html ('k') | tools/cc-frame-viewer/src/base/range_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/cc-frame-viewer/src/base/range.js
diff --git a/tools/cc-frame-viewer/src/base/range.js b/tools/cc-frame-viewer/src/base/range.js
new file mode 100644
index 0000000000000000000000000000000000000000..9dd9009f9be979fccd4170c4fca5aa649481af89
--- /dev/null
+++ b/tools/cc-frame-viewer/src/base/range.js
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 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.
+'use strict';
+
+/**
+ * @fileoverview Quick range computations.
+ */
+base.exportTo('base', function() {
+
+ function Range() {
+ this.isEmpty_ = true;
+ this.min_ = undefined;
+ this.max_ = undefined;
+ };
+
+ Range.prototype = {
+ __proto__: Object.prototype,
+
+ reset: function() {
+ this.isEmpty_ = true;
+ this.min_ = undefined;
+ this.max_ = undefined;
+ },
+
+ get isEmpty() {
+ return this.isEmpty_;
+ },
+
+ addRange: function(range) {
+ if (range.isEmpty)
+ return;
+ this.addValue(range.min);
+ this.addValue(range.max);
+ },
+
+ addValue: function(value) {
+ if (this.isEmpty_) {
+ this.max_ = value;
+ this.min_ = value;
+ this.isEmpty_ = false;
+ return;
+ }
+ this.max_ = Math.max(this.max_, value);
+ this.min_ = Math.min(this.min_, value);
+ },
+
+ get min() {
+ if (this.isEmpty_)
+ return undefined;
+ return this.min_;
+ },
+
+ get max() {
+ if (this.isEmpty_)
+ return undefined;
+ return this.max_;
+ },
+ };
+
+ return {
+ Range: Range
+ };
+
+});
« no previous file with comments | « tools/cc-frame-viewer/src/base/gl_matrix_test.html ('k') | tools/cc-frame-viewer/src/base/range_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698