| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 // Namespace object for the utilities. | 6 // Namespace object for the utilities. |
| 7 function ImageUtil() {} | 7 function ImageUtil() {} |
| 8 | 8 |
| 9 // Performance trace. | 9 // Performance trace. |
| 10 ImageUtil.trace = (function() { | 10 ImageUtil.trace = (function() { |
| 11 function PerformanceTrace() { | 11 function PerformanceTrace() { |
| 12 this.lines_ = {}; | 12 this.lines_ = {}; |
| 13 this.timers_ = {}; | 13 this.timers_ = {}; |
| 14 this.container_ = null; | 14 this.container_ = null; |
| 15 } | 15 } |
| 16 | 16 |
| 17 PerformanceTrace.prototype.bindToDOM = function(container) { |
| 18 this.container_ = container; |
| 19 }; |
| 20 |
| 17 PerformanceTrace.prototype.report_ = function(key, value) { | 21 PerformanceTrace.prototype.report_ = function(key, value) { |
| 18 if (!this.container_) { | 22 if (!this.container_) return; |
| 19 this.container_ = document.getElementById('debug-output'); | |
| 20 if (!this.container_) return; | |
| 21 } | |
| 22 if (!(key in this.lines_)) { | 23 if (!(key in this.lines_)) { |
| 23 var div = this.lines_[key] = document.createElement('div'); | 24 var div = this.lines_[key] = document.createElement('div'); |
| 24 this.container_.appendChild(div); | 25 this.container_.appendChild(div); |
| 25 } | 26 } |
| 26 this.lines_[key].textContent = key + ': ' + value; | 27 this.lines_[key].textContent = key + ': ' + value; |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 PerformanceTrace.prototype.resetTimer = function(key) { | 30 PerformanceTrace.prototype.resetTimer = function(key) { |
| 30 this.timers_[key] = Date.now(); | 31 this.timers_[key] = Date.now(); |
| 31 } | 32 } |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 this.x = x; | 223 this.x = x; |
| 223 this.y = y; | 224 this.y = y; |
| 224 this.squaredR = R * R; | 225 this.squaredR = R * R; |
| 225 }; | 226 }; |
| 226 | 227 |
| 227 Circle.prototype.inside = function(x, y) { | 228 Circle.prototype.inside = function(x, y) { |
| 228 x -= this.x; | 229 x -= this.x; |
| 229 y -= this.y; | 230 y -= this.y; |
| 230 return x * x + y * y <= this.squaredR; | 231 return x * x + y * y <= this.squaredR; |
| 231 }; | 232 }; |
| OLD | NEW |