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

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

Issue 22320018: Delete chrome.gpuBenchmarking.runRenderingBenchmarks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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/base64.h" 9 #include "base/base64.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "content/common/browser_rendering_stats.h" 14 #include "content/common/browser_rendering_stats.h"
15 #include "content/common/gpu/gpu_rendering_stats.h" 15 #include "content/common/gpu/gpu_rendering_stats.h"
16 #include "content/public/renderer/render_thread.h" 16 #include "content/public/renderer/render_thread.h"
17 #include "content/renderer/all_rendering_benchmarks.h"
18 #include "content/renderer/gpu/render_widget_compositor.h" 17 #include "content/renderer/gpu/render_widget_compositor.h"
19 #include "content/renderer/render_view_impl.h" 18 #include "content/renderer/render_view_impl.h"
20 #include "content/renderer/rendering_benchmark.h" 19 #include "content/renderer/rendering_benchmark.h"
21 #include "content/renderer/skia_benchmarking_extension.h" 20 #include "content/renderer/skia_benchmarking_extension.h"
22 #include "third_party/WebKit/public/web/WebFrame.h" 21 #include "third_party/WebKit/public/web/WebFrame.h"
23 #include "third_party/WebKit/public/web/WebImageCache.h" 22 #include "third_party/WebKit/public/web/WebImageCache.h"
24 #include "third_party/WebKit/public/web/WebView.h" 23 #include "third_party/WebKit/public/web/WebView.h"
25 #include "third_party/WebKit/public/web/WebViewBenchmarkSupport.h" 24 #include "third_party/WebKit/public/web/WebViewBenchmarkSupport.h"
26 #include "third_party/skia/include/core/SkData.h" 25 #include "third_party/skia/include/core/SkData.h"
27 #include "third_party/skia/include/core/SkGraphics.h" 26 #include "third_party/skia/include/core/SkGraphics.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 " opt_mouse_event_x, opt_mouse_event_y);" 205 " opt_mouse_event_x, opt_mouse_event_y);"
207 " } else {" 206 " } else {"
208 " return BeginSmoothScroll(pixels_to_scroll >= 0, callback," 207 " return BeginSmoothScroll(pixels_to_scroll >= 0, callback,"
209 " Math.abs(pixels_to_scroll));" 208 " Math.abs(pixels_to_scroll));"
210 " }" 209 " }"
211 "};" 210 "};"
212 "chrome.gpuBenchmarking.smoothScrollBySendsTouch = function() {" 211 "chrome.gpuBenchmarking.smoothScrollBySendsTouch = function() {"
213 " native function SmoothScrollSendsTouch();" 212 " native function SmoothScrollSendsTouch();"
214 " return SmoothScrollSendsTouch();" 213 " return SmoothScrollSendsTouch();"
215 "};" 214 "};"
216 "chrome.gpuBenchmarking.runRenderingBenchmarks = function(filter) {"
217 " native function RunRenderingBenchmarks();"
218 " return RunRenderingBenchmarks(filter);"
219 "};"
220 "chrome.gpuBenchmarking.beginWindowSnapshotPNG = function(callback) {" 215 "chrome.gpuBenchmarking.beginWindowSnapshotPNG = function(callback) {"
221 " native function BeginWindowSnapshotPNG();" 216 " native function BeginWindowSnapshotPNG();"
222 " BeginWindowSnapshotPNG(callback);" 217 " BeginWindowSnapshotPNG(callback);"
223 "};" 218 "};"
224 "chrome.gpuBenchmarking.clearImageCache = function() {" 219 "chrome.gpuBenchmarking.clearImageCache = function() {"
225 " native function ClearImageCache();" 220 " native function ClearImageCache();"
226 " ClearImageCache();" 221 " ClearImageCache();"
227 "};") {} 222 "};") {}
228 223
229 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 224 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
230 v8::Handle<v8::String> name) OVERRIDE { 225 v8::Handle<v8::String> name) OVERRIDE {
231 if (name->Equals(v8::String::New("SetNeedsDisplayOnAllLayers"))) 226 if (name->Equals(v8::String::New("SetNeedsDisplayOnAllLayers")))
232 return v8::FunctionTemplate::New(SetNeedsDisplayOnAllLayers); 227 return v8::FunctionTemplate::New(SetNeedsDisplayOnAllLayers);
233 if (name->Equals(v8::String::New("SetRasterizeOnlyVisibleContent"))) 228 if (name->Equals(v8::String::New("SetRasterizeOnlyVisibleContent")))
234 return v8::FunctionTemplate::New(SetRasterizeOnlyVisibleContent); 229 return v8::FunctionTemplate::New(SetRasterizeOnlyVisibleContent);
235 if (name->Equals(v8::String::New("GetRenderingStats"))) 230 if (name->Equals(v8::String::New("GetRenderingStats")))
236 return v8::FunctionTemplate::New(GetRenderingStats); 231 return v8::FunctionTemplate::New(GetRenderingStats);
237 if (name->Equals(v8::String::New("PrintToSkPicture"))) 232 if (name->Equals(v8::String::New("PrintToSkPicture")))
238 return v8::FunctionTemplate::New(PrintToSkPicture); 233 return v8::FunctionTemplate::New(PrintToSkPicture);
239 if (name->Equals(v8::String::New("BeginSmoothScroll"))) 234 if (name->Equals(v8::String::New("BeginSmoothScroll")))
240 return v8::FunctionTemplate::New(BeginSmoothScroll); 235 return v8::FunctionTemplate::New(BeginSmoothScroll);
241 if (name->Equals(v8::String::New("SmoothScrollSendsTouch"))) 236 if (name->Equals(v8::String::New("SmoothScrollSendsTouch")))
242 return v8::FunctionTemplate::New(SmoothScrollSendsTouch); 237 return v8::FunctionTemplate::New(SmoothScrollSendsTouch);
243 if (name->Equals(v8::String::New("RunRenderingBenchmarks")))
244 return v8::FunctionTemplate::New(RunRenderingBenchmarks);
245 if (name->Equals(v8::String::New("BeginWindowSnapshotPNG"))) 238 if (name->Equals(v8::String::New("BeginWindowSnapshotPNG")))
246 return v8::FunctionTemplate::New(BeginWindowSnapshotPNG); 239 return v8::FunctionTemplate::New(BeginWindowSnapshotPNG);
247 if (name->Equals(v8::String::New("ClearImageCache"))) 240 if (name->Equals(v8::String::New("ClearImageCache")))
248 return v8::FunctionTemplate::New(ClearImageCache); 241 return v8::FunctionTemplate::New(ClearImageCache);
249 242
250 return v8::Handle<v8::FunctionTemplate>(); 243 return v8::Handle<v8::FunctionTemplate>();
251 } 244 }
252 245
253 static void SetNeedsDisplayOnAllLayers( 246 static void SetNeedsDisplayOnAllLayers(
254 const v8::FunctionCallbackInfo<v8::Value>& args) { 247 const v8::FunctionCallbackInfo<v8::Value>& args) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 scroll_down, 437 scroll_down,
445 base::Bind(&OnSmoothScrollCompleted, 438 base::Bind(&OnSmoothScrollCompleted,
446 callback_and_context), 439 callback_and_context),
447 pixels_to_scroll, 440 pixels_to_scroll,
448 mouse_event_x, 441 mouse_event_x,
449 mouse_event_y); 442 mouse_event_y);
450 443
451 args.GetReturnValue().Set(true); 444 args.GetReturnValue().Set(true);
452 } 445 }
453 446
454 static void RunRenderingBenchmarks(
455 const v8::FunctionCallbackInfo<v8::Value>& args) {
456 // For our name filter, the argument can be undefined or null to run
457 // all benchmarks, or a string for filtering by name.
458 if (!args.Length() ||
459 (!args[0]->IsString() &&
460 !(args[0]->IsNull() || args[0]->IsUndefined()))) {
461 return;
462 }
463
464 std::string name_filter;
465 if (args[0]->IsNull() || args[0]->IsUndefined()) {
466 name_filter = "";
467 } else {
468 char filter[256];
469 args[0]->ToString()->WriteUtf8(filter, sizeof(filter)-1);
470 name_filter = std::string(filter);
471 }
472
473 WebFrame* web_frame = WebFrame::frameForCurrentContext();
474 if (!web_frame)
475 return;
476
477 WebView* web_view = web_frame->view();
478 if (!web_view)
479 return;
480
481 WebViewBenchmarkSupport* support = web_view->benchmarkSupport();
482 if (!support)
483 return;
484
485 ScopedVector<RenderingBenchmark> benchmarks = AllRenderingBenchmarks();
486
487 v8::Handle<v8::Array> results = v8::Array::New(0);
488 ScopedVector<RenderingBenchmark>::const_iterator it;
489 for (it = benchmarks.begin(); it != benchmarks.end(); it++) {
490 RenderingBenchmark* benchmark = *it;
491 const std::string& name = benchmark->name();
492 if (name_filter != "" &&
493 std::string::npos == name.find(name_filter)) {
494 continue;
495 }
496 benchmark->SetUp(support);
497 double result = benchmark->Run(support);
498 benchmark->TearDown(support);
499
500 v8::Handle<v8::Object> result_object = v8::Object::New();
501 result_object->Set(v8::String::New("benchmark", 9),
502 v8::String::New(name.c_str(), -1));
503 result_object->Set(v8::String::New("result", 6), v8::Number::New(result));
504 results->Set(results->Length(), result_object);
505 }
506
507 args.GetReturnValue().Set(results);
508 }
509
510 static void OnSnapshotCompleted(CallbackAndContext* callback_and_context, 447 static void OnSnapshotCompleted(CallbackAndContext* callback_and_context,
511 const gfx::Size& size, 448 const gfx::Size& size,
512 const std::vector<unsigned char>& png) { 449 const std::vector<unsigned char>& png) {
513 v8::HandleScope scope(callback_and_context->isolate()); 450 v8::HandleScope scope(callback_and_context->isolate());
514 v8::Handle<v8::Context> context = callback_and_context->GetContext(); 451 v8::Handle<v8::Context> context = callback_and_context->GetContext();
515 v8::Context::Scope context_scope(context); 452 v8::Context::Scope context_scope(context);
516 WebFrame* frame = WebFrame::frameForContext(context); 453 WebFrame* frame = WebFrame::frameForContext(context);
517 if (frame) { 454 if (frame) {
518 455
519 v8::Handle<v8::Value> result; 456 v8::Handle<v8::Value> result;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 const v8::FunctionCallbackInfo<v8::Value>& args) { 517 const v8::FunctionCallbackInfo<v8::Value>& args) {
581 WebImageCache::clear(); 518 WebImageCache::clear();
582 } 519 }
583 }; 520 };
584 521
585 v8::Extension* GpuBenchmarkingExtension::Get() { 522 v8::Extension* GpuBenchmarkingExtension::Get() {
586 return new GpuBenchmarkingWrapper(); 523 return new GpuBenchmarkingWrapper();
587 } 524 }
588 525
589 } // namespace content 526 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/all_rendering_benchmarks.cc ('k') | tools/telemetry/examples/rendering_microbenchmark_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698