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. 4 5 #ifndef CC_DEBUG_RASTERIZE_AND_RECORD_BENCHMARK_H_ 6 #define CC_DEBUG_RASTERIZE_AND_RECORD_BENCHMARK_H_ 7 8 #include <map> 9 #include <utility> 10 #include <vector> 11 12 #include "base/memory/weak_ptr.h" 13 #include "base/time/time.h" 14 #include "cc/debug/micro_benchmark_controller.h" 15 16 namespace base { 17 class DictionaryValue; 18 } 19 20 namespace cc { 21 22 class LayerTreeHost; 23 class Layer; 24 class RasterizeAndRecordBenchmark : public MicroBenchmark { 25 public: 26 explicit RasterizeAndRecordBenchmark( 27 scoped_ptr<base::Value> value, 28 const MicroBenchmark::DoneCallback& callback); 29 virtual ~RasterizeAndRecordBenchmark(); 30 31 // Implements MicroBenchmark interface. 32 virtual void DidUpdateLayers(LayerTreeHost* host) OVERRIDE; 33 virtual void RunOnLayer(PictureLayer* layer) OVERRIDE; 34 35 virtual scoped_ptr<MicroBenchmarkImpl> CreateBenchmarkImpl( 36 scoped_refptr<base::MessageLoopProxy> origin_loop) OVERRIDE; 37 38 private: 39 void Run(Layer* layer); 40 41 void RecordRasterResults(scoped_ptr<base::Value> results); 42 43 struct RecordResults { 44 RecordResults(); 45 ~RecordResults(); 46 47 int pixels_recorded; 48 base::TimeDelta total_best_time; 49 }; 50 51 RecordResults record_results_; 52 int record_repeat_count_; 53 scoped_ptr<base::Value> settings_; 54 scoped_ptr<base::DictionaryValue> results_; 55 56 // The following is used in DCHECKs. 57 bool main_thread_benchmark_done_; 58 59 LayerTreeHost* host_; 60 61 base::WeakPtrFactory<RasterizeAndRecordBenchmark> weak_ptr_factory_; 62 }; 63 64 } // namespace cc 65 66 #endif // CC_DEBUG_RASTERIZE_AND_RECORD_BENCHMARK_H_ 67