summaryrefslogtreecommitdiff
path: root/chromium/third_party/trace-viewer/src/gpu/state_view.js
blob: cb7f0e09d38ff772f8de836ca2e72520a9081c04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2013 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';

base.requireStylesheet('gpu.state_view');

base.require('tracing.analysis.object_snapshot_view');
base.require('tracing.analysis.util');

base.exportTo('gpu', function() {

  /*
   * Displays a GPU state snapshot in a human readable form.
   * @constructor
   */
  var StateSnapshotView = ui.define(
      'gpu-state-snapshot-view',
      tracing.analysis.ObjectSnapshotView);

  StateSnapshotView.prototype = {
    __proto__: tracing.analysis.ObjectSnapshotView.prototype,

    decorate: function() {
      this.classList.add('gpu-state-snapshot-view');
      this.screenshotImage_ = document.createElement('img');
      this.appendChild(this.screenshotImage_);
    },

    updateContents: function() {
      if (this.objectSnapshot_ && this.objectSnapshot_.screenshot) {
        this.screenshotImage_.src = 'data:image/png;base64,' +
            this.objectSnapshot_.screenshot;
      }
    }
  };

  tracing.analysis.ObjectSnapshotView.register(
      'gpu::State', StateSnapshotView);

  return {
    StateSnapshotView: StateSnapshotView
  };

});