Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / src / gpu / state_view.js
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 'use strict';
6
7 tvcm.requireStylesheet('gpu.state_view');
8
9 tvcm.require('tracing.analysis.object_snapshot_view');
10 tvcm.require('tracing.analysis.util');
11
12 tvcm.exportTo('gpu', function() {
13
14   /*
15    * Displays a GPU state snapshot in a human readable form.
16    * @constructor
17    */
18   var StateSnapshotView = tvcm.ui.define(
19       'gpu-state-snapshot-view',
20       tracing.analysis.ObjectSnapshotView);
21
22   StateSnapshotView.prototype = {
23     __proto__: tracing.analysis.ObjectSnapshotView.prototype,
24
25     decorate: function() {
26       this.classList.add('gpu-state-snapshot-view');
27       this.screenshotImage_ = document.createElement('img');
28       this.appendChild(this.screenshotImage_);
29     },
30
31     updateContents: function() {
32       if (this.objectSnapshot_ && this.objectSnapshot_.screenshot) {
33         this.screenshotImage_.src = 'data:image/png;base64,' +
34             this.objectSnapshot_.screenshot;
35       }
36     }
37   };
38
39   tracing.analysis.ObjectSnapshotView.register(
40       'gpu::State', StateSnapshotView);
41
42   return {
43     StateSnapshotView: StateSnapshotView
44   };
45
46 });