OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/gpu/gpu_benchmarking_extension.h" | 5 #include "content/renderer/gpu/gpu_benchmarking_extension.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 FilePath dirpath_; | 80 FilePath dirpath_; |
81 int layer_id_; | 81 int layer_id_; |
82 SkPicture picture_; | 82 SkPicture picture_; |
83 }; | 83 }; |
84 | 84 |
85 class RenderingStatsEnumerator : public cc::RenderingStats::Enumerator { | 85 class RenderingStatsEnumerator : public cc::RenderingStats::Enumerator { |
86 public: | 86 public: |
87 RenderingStatsEnumerator(v8::Handle<v8::Object> stats_object) | 87 RenderingStatsEnumerator(v8::Handle<v8::Object> stats_object) |
88 : stats_object(stats_object) { } | 88 : stats_object(stats_object) { } |
89 | 89 |
90 virtual void AddInt64(const char* name, int64 value) { | 90 virtual void AddInt64(const char* name, int64 value) OVERRIDE { |
91 stats_object->Set(v8::String::New(name), v8::Number::New(value)); | 91 stats_object->Set(v8::String::New(name), v8::Number::New(value)); |
92 } | 92 } |
93 | 93 |
94 virtual void AddDouble(const char* name, double value) { | 94 virtual void AddDouble(const char* name, double value) OVERRIDE { |
95 stats_object->Set(v8::String::New(name), v8::Number::New(value)); | 95 stats_object->Set(v8::String::New(name), v8::Number::New(value)); |
96 } | 96 } |
97 | 97 |
98 virtual void AddInt(const char* name, int value) { | 98 virtual void AddInt(const char* name, int value) OVERRIDE { |
99 stats_object->Set(v8::String::New(name), v8::Integer::New(value)); | 99 stats_object->Set(v8::String::New(name), v8::Integer::New(value)); |
100 } | 100 } |
101 | 101 |
102 virtual void AddTimeDeltaInSecondsF(const char* name, | 102 virtual void AddTimeDeltaInSecondsF(const char* name, |
103 const base::TimeDelta& value) { | 103 const base::TimeDelta& value) OVERRIDE { |
104 stats_object->Set(v8::String::New(name), | 104 stats_object->Set(v8::String::New(name), |
105 v8::Number::New(value.InSecondsF())); | 105 v8::Number::New(value.InSecondsF())); |
106 } | 106 } |
107 | 107 |
108 private: | 108 private: |
109 v8::Handle<v8::Object> stats_object; | 109 v8::Handle<v8::Object> stats_object; |
110 }; | 110 }; |
111 | 111 |
112 } // namespace | 112 } // namespace |
113 | 113 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 "chrome.gpuBenchmarking.runRenderingBenchmarks = function(filter) {" | 150 "chrome.gpuBenchmarking.runRenderingBenchmarks = function(filter) {" |
151 " native function RunRenderingBenchmarks();" | 151 " native function RunRenderingBenchmarks();" |
152 " return RunRenderingBenchmarks(filter);" | 152 " return RunRenderingBenchmarks(filter);" |
153 "};" | 153 "};" |
154 "chrome.gpuBenchmarking.beginWindowSnapshotPNG = function(callback) {" | 154 "chrome.gpuBenchmarking.beginWindowSnapshotPNG = function(callback) {" |
155 " native function BeginWindowSnapshotPNG();" | 155 " native function BeginWindowSnapshotPNG();" |
156 " BeginWindowSnapshotPNG(callback);" | 156 " BeginWindowSnapshotPNG(callback);" |
157 "};") {} | 157 "};") {} |
158 | 158 |
159 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 159 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
160 v8::Handle<v8::String> name) { | 160 v8::Handle<v8::String> name) OVERRIDE { |
161 if (name->Equals(v8::String::New("GetRenderingStats"))) | 161 if (name->Equals(v8::String::New("GetRenderingStats"))) |
162 return v8::FunctionTemplate::New(GetRenderingStats); | 162 return v8::FunctionTemplate::New(GetRenderingStats); |
163 if (name->Equals(v8::String::New("PrintToSkPicture"))) | 163 if (name->Equals(v8::String::New("PrintToSkPicture"))) |
164 return v8::FunctionTemplate::New(PrintToSkPicture); | 164 return v8::FunctionTemplate::New(PrintToSkPicture); |
165 if (name->Equals(v8::String::New("BeginSmoothScroll"))) | 165 if (name->Equals(v8::String::New("BeginSmoothScroll"))) |
166 return v8::FunctionTemplate::New(BeginSmoothScroll); | 166 return v8::FunctionTemplate::New(BeginSmoothScroll); |
167 if (name->Equals(v8::String::New("RunRenderingBenchmarks"))) | 167 if (name->Equals(v8::String::New("RunRenderingBenchmarks"))) |
168 return v8::FunctionTemplate::New(RunRenderingBenchmarks); | 168 return v8::FunctionTemplate::New(RunRenderingBenchmarks); |
169 if (name->Equals(v8::String::New("BeginWindowSnapshotPNG"))) | 169 if (name->Equals(v8::String::New("BeginWindowSnapshotPNG"))) |
170 return v8::FunctionTemplate::New(BeginWindowSnapshotPNG); | 170 return v8::FunctionTemplate::New(BeginWindowSnapshotPNG); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 443 |
444 return v8::Undefined(); | 444 return v8::Undefined(); |
445 } | 445 } |
446 }; | 446 }; |
447 | 447 |
448 v8::Extension* GpuBenchmarkingExtension::Get() { | 448 v8::Extension* GpuBenchmarkingExtension::Get() { |
449 return new GpuBenchmarkingWrapper(); | 449 return new GpuBenchmarkingWrapper(); |
450 } | 450 } |
451 | 451 |
452 } // namespace content | 452 } // namespace content |
OLD | NEW |