3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
8 <link rel="import" href="/tvcm.html">
12 tvcm.exportTo('cc', function() {
16 function PictureAsImageData(picture, errorOrImageData) {
17 this.picture_ = picture;
18 if (errorOrImageData instanceof ImageData) {
19 this.error_ = undefined;
20 this.imageData_ = errorOrImageData;
22 this.error_ = errorOrImageData;
23 this.imageData_ = undefined;
28 * Creates a new pending PictureAsImageData (no image data and no error).
30 * @return {PictureAsImageData} a new pending PictureAsImageData.
32 PictureAsImageData.Pending = function(picture) {
33 return new PictureAsImageData(picture, undefined);
36 PictureAsImageData.prototype = {
46 return this.imageData_;
49 isPending: function() {
50 return this.error_ === undefined && this.imageData_ === undefined;
53 asCanvas: function() {
57 var canvas = document.createElement('canvas');
58 var ctx = canvas.getContext('2d');
60 canvas.width = this.imageData_.width;
61 canvas.height = this.imageData_.height;
62 ctx.putImageData(this.imageData_, 0, 0);
68 PictureAsImageData: PictureAsImageData