summaryrefslogtreecommitdiffstats
path: root/cc/debug/rasterize_and_record_benchmark.h
blob: 3e873ce91f1cf3606369ec8179803076aedb6c6b (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 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.

#ifndef CC_DEBUG_RASTERIZE_AND_RECORD_BENCHMARK_H_
#define CC_DEBUG_RASTERIZE_AND_RECORD_BENCHMARK_H_

#include <map>
#include <utility>
#include <vector>

#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
#include "cc/debug/micro_benchmark_controller.h"
#include "cc/playback/picture.h"

namespace base {
class DictionaryValue;
}

namespace cc {

class LayerTreeHost;
class Layer;
class RasterizeAndRecordBenchmark : public MicroBenchmark {
 public:
  explicit RasterizeAndRecordBenchmark(
      scoped_ptr<base::Value> value,
      const MicroBenchmark::DoneCallback& callback);
  ~RasterizeAndRecordBenchmark() override;

  // Implements MicroBenchmark interface.
  void DidUpdateLayers(LayerTreeHost* host) override;
  void RunOnLayer(PictureLayer* layer) override;

  scoped_ptr<MicroBenchmarkImpl> CreateBenchmarkImpl(
      scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner) override;

 private:
  void RunOnDisplayListLayer(PictureLayer* layer,
                             const gfx::Rect& visible_layer_rect);

  void RecordRasterResults(scoped_ptr<base::Value> results);

  struct RecordResults {
    RecordResults();
    ~RecordResults();

    int pixels_recorded;
    size_t bytes_used;
    base::TimeDelta total_best_time[RecordingSource::RECORDING_MODE_COUNT];
  };

  RecordResults record_results_;
  int record_repeat_count_;
  scoped_ptr<base::Value> settings_;
  scoped_ptr<base::DictionaryValue> results_;

  // The following is used in DCHECKs.
  bool main_thread_benchmark_done_;

  LayerTreeHost* host_;

  base::WeakPtrFactory<RasterizeAndRecordBenchmark> weak_ptr_factory_;
};

}  // namespace cc

#endif  // CC_DEBUG_RASTERIZE_AND_RECORD_BENCHMARK_H_