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" |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "content/common/gpu/gpu_rendering_stats.h" | 13 #include "content/common/gpu/gpu_rendering_stats.h" |
14 #include "content/public/renderer/render_thread.h" | 14 #include "content/public/renderer/render_thread.h" |
15 #include "content/renderer/all_rendering_benchmarks.h" | 15 #include "content/renderer/all_rendering_benchmarks.h" |
16 #include "content/renderer/render_view_impl.h" | 16 #include "content/renderer/render_view_impl.h" |
17 #include "content/renderer/rendering_benchmark.h" | 17 #include "content/renderer/rendering_benchmark.h" |
18 #include "third_party/skia/include/core/SkGraphics.h" | 18 #include "third_party/skia/include/core/SkGraphics.h" |
19 #include "third_party/skia/include/core/SkPicture.h" | 19 #include "third_party/skia/include/core/SkPicture.h" |
20 #include "third_party/skia/include/core/SkStream.h" | 20 #include "third_party/skia/include/core/SkStream.h" |
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h
" | |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewBenchmarkSuppo
rt.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewBenchmarkSuppo
rt.h" |
25 #include "v8/include/v8.h" | 24 #include "v8/include/v8.h" |
| 25 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" |
26 | 26 |
27 using WebKit::WebCanvas; | 27 using WebKit::WebCanvas; |
28 using WebKit::WebFrame; | 28 using WebKit::WebFrame; |
29 using WebKit::WebPrivatePtr; | 29 using WebKit::WebPrivatePtr; |
30 using WebKit::WebRenderingStats; | 30 using WebKit::WebRenderingStatsImpl; |
31 using WebKit::WebSize; | 31 using WebKit::WebSize; |
32 using WebKit::WebView; | 32 using WebKit::WebView; |
33 using WebKit::WebViewBenchmarkSupport; | 33 using WebKit::WebViewBenchmarkSupport; |
34 | 34 |
35 const char kGpuBenchmarkingExtensionName[] = "v8/GpuBenchmarking"; | 35 const char kGpuBenchmarkingExtensionName[] = "v8/GpuBenchmarking"; |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 // Always called on the main render thread. | 39 // Always called on the main render thread. |
40 // Does not need to be thread-safe. | 40 // Does not need to be thread-safe. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return v8::Undefined(); | 145 return v8::Undefined(); |
146 | 146 |
147 WebView* web_view = web_frame->view(); | 147 WebView* web_view = web_frame->view(); |
148 if (!web_view) | 148 if (!web_view) |
149 return v8::Undefined(); | 149 return v8::Undefined(); |
150 | 150 |
151 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); | 151 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); |
152 if (!render_view_impl) | 152 if (!render_view_impl) |
153 return v8::Undefined(); | 153 return v8::Undefined(); |
154 | 154 |
155 WebRenderingStats stats; | 155 WebRenderingStatsImpl stats; |
156 render_view_impl->GetRenderingStats(stats); | 156 render_view_impl->GetRenderingStats(stats); |
157 | 157 |
158 content::GpuRenderingStats gpu_stats; | 158 content::GpuRenderingStats gpu_stats; |
159 render_view_impl->GetGpuRenderingStats(&gpu_stats); | 159 render_view_impl->GetGpuRenderingStats(&gpu_stats); |
160 v8::Handle<v8::Object> stats_object = v8::Object::New(); | 160 v8::Handle<v8::Object> stats_object = v8::Object::New(); |
161 stats_object->Set(v8::String::New("numAnimationFrames"), | 161 stats_object->Set(v8::String::New("numAnimationFrames"), |
162 v8::Integer::New(stats.numAnimationFrames)); | 162 v8::Number::New( |
| 163 stats.rendering_stats.numAnimationFrames)); |
163 stats_object->Set(v8::String::New("numFramesSentToScreen"), | 164 stats_object->Set(v8::String::New("numFramesSentToScreen"), |
164 v8::Integer::New(stats.numFramesSentToScreen)); | 165 v8::Number::New( |
| 166 stats.rendering_stats.numFramesSentToScreen)); |
165 stats_object->Set(v8::String::New("droppedFrameCount"), | 167 stats_object->Set(v8::String::New("droppedFrameCount"), |
166 v8::Integer::New(stats.droppedFrameCount)); | 168 v8::Number::New( |
| 169 stats.rendering_stats.droppedFrameCount)); |
167 stats_object->Set(v8::String::New("totalPaintTimeInSeconds"), | 170 stats_object->Set(v8::String::New("totalPaintTimeInSeconds"), |
168 v8::Number::New(stats.totalPaintTimeInSeconds)); | 171 v8::Number::New( |
| 172 stats.rendering_stats.totalPaintTimeInSeconds)); |
169 stats_object->Set(v8::String::New("totalRasterizeTimeInSeconds"), | 173 stats_object->Set(v8::String::New("totalRasterizeTimeInSeconds"), |
170 v8::Number::New(stats.totalRasterizeTimeInSeconds)); | 174 v8::Number::New( |
| 175 stats.rendering_stats.totalRasterizeTimeInSeconds)); |
171 stats_object->Set(v8::String::New("totalCommitTimeInSeconds"), | 176 stats_object->Set(v8::String::New("totalCommitTimeInSeconds"), |
172 v8::Number::New(stats.totalCommitTimeInSeconds)); | 177 v8::Number::New( |
| 178 stats.rendering_stats.totalCommitTimeInSeconds)); |
173 stats_object->Set(v8::String::New("totalCommitCount"), | 179 stats_object->Set(v8::String::New("totalCommitCount"), |
174 v8::Integer::New(stats.totalCommitCount)); | 180 v8::Number::New( |
| 181 stats.rendering_stats.totalCommitCount)); |
175 stats_object->Set(v8::String::New("numImplThreadScrolls"), | 182 stats_object->Set(v8::String::New("numImplThreadScrolls"), |
176 v8::Integer::New(stats.numImplThreadScrolls)); | 183 v8::Number::New( |
| 184 stats.rendering_stats.numImplThreadScrolls)); |
177 stats_object->Set(v8::String::New("numMainThreadScrolls"), | 185 stats_object->Set(v8::String::New("numMainThreadScrolls"), |
178 v8::Integer::New(stats.numMainThreadScrolls)); | 186 v8::Number::New( |
| 187 stats.rendering_stats.numMainThreadScrolls)); |
179 stats_object->Set(v8::String::New("totalPixelsPainted"), | 188 stats_object->Set(v8::String::New("totalPixelsPainted"), |
180 v8::Integer::New(stats.totalPixelsPainted)); | 189 v8::Number::New( |
| 190 stats.rendering_stats.totalPixelsPainted)); |
181 stats_object->Set(v8::String::New("totalPixelsRasterized"), | 191 stats_object->Set(v8::String::New("totalPixelsRasterized"), |
182 v8::Integer::New(stats.totalPixelsRasterized)); | 192 v8::Number::New( |
| 193 stats.rendering_stats.totalPixelsRasterized)); |
183 | 194 |
184 stats_object->Set(v8::String::New("globalTextureUploadCount"), | 195 stats_object->Set(v8::String::New("globalTextureUploadCount"), |
185 v8::Number::New(gpu_stats.global_texture_upload_count)); | 196 v8::Number::New(gpu_stats.global_texture_upload_count)); |
186 stats_object->Set( | 197 stats_object->Set( |
187 v8::String::New("globalTotalTextureUploadTimeInSeconds"), | 198 v8::String::New("globalTotalTextureUploadTimeInSeconds"), |
188 v8::Number::New( | 199 v8::Number::New( |
189 gpu_stats.global_total_texture_upload_time.InSecondsF())); | 200 gpu_stats.global_total_texture_upload_time.InSecondsF())); |
190 stats_object->Set(v8::String::New("textureUploadCount"), | 201 stats_object->Set(v8::String::New("textureUploadCount"), |
191 v8::Number::New(gpu_stats.texture_upload_count)); | 202 v8::Number::New(gpu_stats.texture_upload_count)); |
192 stats_object->Set( | 203 stats_object->Set( |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 383 |
373 return results; | 384 return results; |
374 } | 385 } |
375 }; | 386 }; |
376 | 387 |
377 v8::Extension* GpuBenchmarkingExtension::Get() { | 388 v8::Extension* GpuBenchmarkingExtension::Get() { |
378 return new GpuBenchmarkingWrapper(); | 389 return new GpuBenchmarkingWrapper(); |
379 } | 390 } |
380 | 391 |
381 } // namespace content | 392 } // namespace content |
OLD | NEW |