| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 458 |
| 459 /** | 459 /** |
| 460 * @param {?string} data | 460 * @param {?string} data |
| 461 * @return {!Promise<!HTMLImageElement>} | 461 * @return {!Promise<!HTMLImageElement>} |
| 462 */ | 462 */ |
| 463 function createImage(data) { | 463 function createImage(data) { |
| 464 var fulfill; | 464 var fulfill; |
| 465 var promise = new Promise(f => fulfill = f); | 465 var promise = new Promise(f => fulfill = f); |
| 466 | 466 |
| 467 var image = /** @type {!HTMLImageElement} */ (createElement('img')); | 467 var image = /** @type {!HTMLImageElement} */ (createElement('img')); |
| 468 if (data) | 468 if (data) { |
| 469 image.src = 'data:image/jpg;base64,' + data; | 469 image.src = 'data:image/jpg;base64,' + data; |
| 470 if (image.complete) { | |
| 471 fulfill(image); | |
| 472 } else { | |
| 473 image.addEventListener('load', () => fulfill(image)); | 470 image.addEventListener('load', () => fulfill(image)); |
| 474 image.addEventListener('error', () => fulfill(image)); | 471 image.addEventListener('error', () => fulfill(image)); |
| 472 } else { |
| 473 fulfill(image); |
| 475 } | 474 } |
| 476 return promise; | 475 return promise; |
| 477 } | 476 } |
| 478 } | 477 } |
| 479 | 478 |
| 480 /** | 479 /** |
| 481 * @param {number} imageWidth | 480 * @param {number} imageWidth |
| 482 * @param {number} imageHeight | 481 * @param {number} imageHeight |
| 483 */ | 482 */ |
| 484 _drawFrames(imageWidth, imageHeight) { | 483 _drawFrames(imageWidth, imageHeight) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 counters[group] = this._quantDuration; | 778 counters[group] = this._quantDuration; |
| 780 this._callback(counters); | 779 this._callback(counters); |
| 781 interval -= this._quantDuration; | 780 interval -= this._quantDuration; |
| 782 } | 781 } |
| 783 this._counters = []; | 782 this._counters = []; |
| 784 this._counters[group] = interval; | 783 this._counters[group] = interval; |
| 785 this._lastTime = time; | 784 this._lastTime = time; |
| 786 this._remainder = this._quantDuration - interval; | 785 this._remainder = this._quantDuration - interval; |
| 787 } | 786 } |
| 788 }; | 787 }; |
| OLD | NEW |