Chromium Code Reviews| 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/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 DCHECK(file.isValid()); | 74 DCHECK(file.isValid()); |
| 75 picture_.serialize(&file); | 75 picture_.serialize(&file); |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 FilePath dirpath_; | 79 FilePath dirpath_; |
| 80 int layer_id_; | 80 int layer_id_; |
| 81 SkPicture picture_; | 81 SkPicture picture_; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 class RenderingStatsEnumerator | |
| 85 : public WebRenderingStats::Enumerator, | |
| 86 public content::GpuRenderingStats::Enumerator { | |
| 87 public: | |
| 88 RenderingStatsEnumerator(v8::Handle<v8::Object> stats_object) | |
| 89 : stats_object_(stats_object) { } | |
| 90 | |
| 91 virtual void addInt(const char* name, int value) { | |
| 92 stats_object_->Set(v8::String::New(name), v8::Integer::New(value)); | |
| 93 } | |
| 94 | |
| 95 virtual void addDouble(const char* name, double value) { | |
| 96 stats_object_->Set(v8::String::New(name), v8::Number::New(value)); | |
| 97 } | |
| 98 | |
| 99 virtual void addTimeDelta(const char* name, base::TimeDelta value) { | |
| 100 stats_object_->Set(v8::String::New(name), | |
| 101 v8::Number::New(value.InSecondsF())); | |
| 102 } | |
| 103 | |
| 104 private: | |
| 105 v8::Handle<v8::Object> stats_object_; | |
| 106 }; | |
| 107 | |
| 108 } // namespace | 84 } // namespace |
| 109 | 85 |
| 110 namespace content { | 86 namespace content { |
| 111 | 87 |
| 112 class GpuBenchmarkingWrapper : public v8::Extension { | 88 class GpuBenchmarkingWrapper : public v8::Extension { |
| 113 public: | 89 public: |
| 114 GpuBenchmarkingWrapper() : | 90 GpuBenchmarkingWrapper() : |
| 115 v8::Extension(kGpuBenchmarkingExtensionName, | 91 v8::Extension(kGpuBenchmarkingExtensionName, |
| 116 "if (typeof(chrome) == 'undefined') {" | 92 "if (typeof(chrome) == 'undefined') {" |
| 117 " chrome = {};" | 93 " chrome = {};" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 | 163 |
| 188 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); | 164 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); |
| 189 if (!render_view_impl) | 165 if (!render_view_impl) |
| 190 return v8::Undefined(); | 166 return v8::Undefined(); |
| 191 | 167 |
| 192 WebRenderingStats stats; | 168 WebRenderingStats stats; |
| 193 render_view_impl->GetRenderingStats(stats); | 169 render_view_impl->GetRenderingStats(stats); |
| 194 | 170 |
| 195 content::GpuRenderingStats gpu_stats; | 171 content::GpuRenderingStats gpu_stats; |
| 196 render_view_impl->GetGpuRenderingStats(&gpu_stats); | 172 render_view_impl->GetGpuRenderingStats(&gpu_stats); |
| 173 v8::Handle<v8::Object> stats_object = v8::Object::New(); | |
| 174 stats_object->Set(v8::String::New("numAnimationFrames"), | |
| 175 v8::Integer::New(stats.numAnimationFrames)); | |
| 176 stats_object->Set(v8::String::New("numFramesSentToScreen"), | |
| 177 v8::Integer::New(stats.numFramesSentToScreen)); | |
| 178 stats_object->Set(v8::String::New("droppedFrameCount"), | |
| 179 v8::Integer::New(stats.droppedFrameCount)); | |
| 180 stats_object->Set(v8::String::New("totalPaintTimeInSeconds"), | |
| 181 v8::Number::New(stats.totalPaintTimeInSeconds)); | |
| 182 stats_object->Set(v8::String::New("totalRasterizeTimeInSeconds"), | |
| 183 v8::Number::New(stats.totalRasterizeTimeInSeconds)); | |
| 184 stats_object->Set(v8::String::New("totalCommitTimeInSeconds"), | |
| 185 v8::Number::New(stats.totalCommitTimeInSeconds)); | |
| 186 stats_object->Set(v8::String::New("totalCommitCount"), | |
| 187 v8::Integer::New(stats.totalCommitCount)); | |
|
brianderson
2012/10/19 18:54:31
A straight up revert compiles, but leaves out impl
| |
| 197 | 188 |
| 198 v8::Handle<v8::Object> stats_object = v8::Object::New(); | 189 stats_object->Set(v8::String::New("globalTextureUploadCount"), |
| 199 RenderingStatsEnumerator enumerator(stats_object); | 190 v8::Number::New(gpu_stats.global_texture_upload_count)); |
| 200 stats.enumerateFields(&enumerator); | 191 stats_object->Set( |
| 201 gpu_stats.enumerateFields(&enumerator); | 192 v8::String::New("globalTotalTextureUploadTimeInSeconds"), |
| 193 v8::Number::New( | |
| 194 gpu_stats.global_total_texture_upload_time.InSecondsF())); | |
| 195 stats_object->Set(v8::String::New("textureUploadCount"), | |
| 196 v8::Number::New(gpu_stats.texture_upload_count)); | |
| 197 stats_object->Set( | |
| 198 v8::String::New("totalTextureUploadTimeInSeconds"), | |
| 199 v8::Number::New(gpu_stats.total_texture_upload_time.InSecondsF())); | |
| 200 stats_object->Set( | |
| 201 v8::String::New("globalTotalProcessingCommandsTimeInSeconds"), | |
| 202 v8::Number::New( | |
| 203 gpu_stats.global_total_processing_commands_time.InSecondsF())); | |
| 204 stats_object->Set( | |
| 205 v8::String::New("totalProcessingCommandsTimeInSeconds"), | |
| 206 v8::Number::New( | |
| 207 gpu_stats.total_processing_commands_time.InSecondsF())); | |
| 202 return stats_object; | 208 return stats_object; |
| 203 } | 209 } |
| 204 | 210 |
| 205 static v8::Handle<v8::Value> PrintToSkPicture(const v8::Arguments& args) { | 211 static v8::Handle<v8::Value> PrintToSkPicture(const v8::Arguments& args) { |
| 206 if (args.Length() != 1) | 212 if (args.Length() != 1) |
| 207 return v8::Undefined(); | 213 return v8::Undefined(); |
| 208 | 214 |
| 209 v8::String::AsciiValue dirname(args[0]); | 215 v8::String::AsciiValue dirname(args[0]); |
| 210 if (dirname.length() == 0) | 216 if (dirname.length() == 0) |
| 211 return v8::Undefined(); | 217 return v8::Undefined(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 | 379 |
| 374 return results; | 380 return results; |
| 375 } | 381 } |
| 376 }; | 382 }; |
| 377 | 383 |
| 378 v8::Extension* GpuBenchmarkingExtension::Get() { | 384 v8::Extension* GpuBenchmarkingExtension::Get() { |
| 379 return new GpuBenchmarkingWrapper(); | 385 return new GpuBenchmarkingWrapper(); |
| 380 } | 386 } |
| 381 | 387 |
| 382 } // namespace content | 388 } // namespace content |
| OLD | NEW |