Setup a experiment to enable background tracing.
[chromium-blink-merge.git] / cc / debug / rasterize_and_record_benchmark.h
blob207254f24c6a8db7d69725a87471cc945ff76a66
1 // Copyright 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.
5 #ifndef CC_DEBUG_RASTERIZE_AND_RECORD_BENCHMARK_H_
6 #define CC_DEBUG_RASTERIZE_AND_RECORD_BENCHMARK_H_
8 #include <map>
9 #include <utility>
10 #include <vector>
12 #include "base/memory/weak_ptr.h"
13 #include "base/single_thread_task_runner.h"
14 #include "base/time/time.h"
15 #include "cc/debug/micro_benchmark_controller.h"
16 #include "cc/playback/picture.h"
18 namespace base {
19 class DictionaryValue;
22 namespace cc {
24 class LayerTreeHost;
25 class Layer;
26 class RasterizeAndRecordBenchmark : public MicroBenchmark {
27 public:
28 explicit RasterizeAndRecordBenchmark(
29 scoped_ptr<base::Value> value,
30 const MicroBenchmark::DoneCallback& callback);
31 ~RasterizeAndRecordBenchmark() override;
33 // Implements MicroBenchmark interface.
34 void DidUpdateLayers(LayerTreeHost* host) override;
35 void RunOnLayer(PictureLayer* layer) override;
37 scoped_ptr<MicroBenchmarkImpl> CreateBenchmarkImpl(
38 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner) override;
40 private:
41 void RunOnDisplayListLayer(PictureLayer* layer,
42 const gfx::Rect& visible_layer_rect);
43 void RunOnPictureLayer(PictureLayer* layer,
44 const gfx::Rect& visible_layer_rect);
46 void RecordRasterResults(scoped_ptr<base::Value> results);
48 struct RecordResults {
49 RecordResults();
50 ~RecordResults();
52 int pixels_recorded;
53 size_t bytes_used;
54 base::TimeDelta total_best_time[RecordingSource::RECORDING_MODE_COUNT];
57 RecordResults record_results_;
58 int record_repeat_count_;
59 scoped_ptr<base::Value> settings_;
60 scoped_ptr<base::DictionaryValue> results_;
62 // The following is used in DCHECKs.
63 bool main_thread_benchmark_done_;
65 LayerTreeHost* host_;
67 base::WeakPtrFactory<RasterizeAndRecordBenchmark> weak_ptr_factory_;
70 } // namespace cc
72 #endif // CC_DEBUG_RASTERIZE_AND_RECORD_BENCHMARK_H_