Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(924)

Side by Side Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 10916292: Adaptively throttle texture uploads (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add tests. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return v8::FunctionTemplate::New(PrintToSkPicture); 130 return v8::FunctionTemplate::New(PrintToSkPicture);
131 if (name->Equals(v8::String::New("BeginSmoothScroll"))) 131 if (name->Equals(v8::String::New("BeginSmoothScroll")))
132 return v8::FunctionTemplate::New(BeginSmoothScroll); 132 return v8::FunctionTemplate::New(BeginSmoothScroll);
133 if (name->Equals(v8::String::New("RunRenderingBenchmarks"))) 133 if (name->Equals(v8::String::New("RunRenderingBenchmarks")))
134 return v8::FunctionTemplate::New(RunRenderingBenchmarks); 134 return v8::FunctionTemplate::New(RunRenderingBenchmarks);
135 135
136 return v8::Handle<v8::FunctionTemplate>(); 136 return v8::Handle<v8::FunctionTemplate>();
137 } 137 }
138 138
139 static v8::Handle<v8::Value> GetRenderingStats(const v8::Arguments& args) { 139 static v8::Handle<v8::Value> GetRenderingStats(const v8::Arguments& args) {
140
140 WebFrame* web_frame = WebFrame::frameForEnteredContext(); 141 WebFrame* web_frame = WebFrame::frameForEnteredContext();
141 if (!web_frame) 142 if (!web_frame)
142 return v8::Undefined(); 143 return v8::Undefined();
143 144
144 WebView* web_view = web_frame->view(); 145 WebView* web_view = web_frame->view();
145 if (!web_view) 146 if (!web_view)
146 return v8::Undefined(); 147 return v8::Undefined();
147 148
148 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); 149 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view);
149 if (!render_view_impl) 150 if (!render_view_impl)
150 return v8::Undefined(); 151 return v8::Undefined();
151 152
152 WebRenderingStats stats; 153 WebRenderingStats stats;
153 render_view_impl->GetRenderingStats(stats); 154 render_view_impl->GetRenderingStats(stats);
154 155
155 content::GpuRenderingStats gpu_stats; 156 content::GpuRenderingStats gpu_stats;
156 render_view_impl->GetGpuRenderingStats(&gpu_stats); 157 render_view_impl->GetGpuRenderingStats(&gpu_stats);
157 158
158 v8::Handle<v8::Object> stats_object = v8::Object::New(); 159 v8::Handle<v8::Object> stats_object = v8::Object::New();
159 stats_object->Set(v8::String::New("numAnimationFrames"), 160 stats_object->Set(v8::String::New("numAnimationFrames"),
160 v8::Integer::New(stats.numAnimationFrames)); 161 v8::Integer::New(stats.numAnimationFrames));
161 stats_object->Set(v8::String::New("numFramesSentToScreen"), 162 stats_object->Set(v8::String::New("numFramesSentToScreen"),
162 v8::Integer::New(stats.numFramesSentToScreen)); 163 v8::Integer::New(stats.numFramesSentToScreen));
163 stats_object->Set(v8::String::New("droppedFrameCount"), 164 stats_object->Set(v8::String::New("droppedFrameCount"),
164 v8::Integer::New(stats.droppedFrameCount)); 165 v8::Integer::New(stats.droppedFrameCount));
165 stats_object->Set(v8::String::New("totalPaintTimeInSeconds"), 166 stats_object->Set(v8::String::New("totalPaintTimeInSeconds"),
166 v8::Number::New(stats.totalPaintTimeInSeconds)); 167 v8::Number::New(stats.totalPaintTimeInSeconds));
167 stats_object->Set(v8::String::New("totalRasterizeTimeInSeconds"), 168 stats_object->Set(v8::String::New("totalRasterizeTimeInSeconds"),
168 v8::Number::New(stats.totalRasterizeTimeInSeconds)); 169 v8::Number::New(stats.totalRasterizeTimeInSeconds));
170 stats_object->Set(v8::String::New("totalCommitTimeInSeconds"),
171 v8::Number::New(stats.totalCommitTimeInSeconds));
172 stats_object->Set(v8::String::New("totalCommitCount"),
173 v8::Integer::New(stats.totalCommitCount));
174
169 stats_object->Set(v8::String::New("globalTextureUploadCount"), 175 stats_object->Set(v8::String::New("globalTextureUploadCount"),
170 v8::Number::New(gpu_stats.global_texture_upload_count)); 176 v8::Number::New(gpu_stats.global_texture_upload_count));
171 stats_object->Set( 177 stats_object->Set(
172 v8::String::New("globalTotalTextureUploadTimeInSeconds"), 178 v8::String::New("globalTotalTextureUploadTimeInSeconds"),
173 v8::Number::New( 179 v8::Number::New(
174 gpu_stats.global_total_texture_upload_time.InSecondsF())); 180 gpu_stats.global_total_texture_upload_time.InSecondsF()));
175 stats_object->Set(v8::String::New("textureUploadCount"), 181 stats_object->Set(v8::String::New("textureUploadCount"),
176 v8::Number::New(gpu_stats.texture_upload_count)); 182 v8::Number::New(gpu_stats.texture_upload_count));
177 stats_object->Set( 183 stats_object->Set(
178 v8::String::New("totalTextureUploadTimeInSeconds"), 184 v8::String::New("totalTextureUploadTimeInSeconds"),
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 341
336 return results; 342 return results;
337 } 343 }
338 }; 344 };
339 345
340 v8::Extension* GpuBenchmarkingExtension::Get() { 346 v8::Extension* GpuBenchmarkingExtension::Get() {
341 return new GpuBenchmarkingWrapper(); 347 return new GpuBenchmarkingWrapper();
342 } 348 }
343 349
344 } // namespace content 350 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698