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

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

Issue 10787025: Expose a gpu-benchmark-only measureRecordTime API to JS. This function measures the time it takes t… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/renderer/render_view_impl.h" 6 #include "content/renderer/render_view_impl.h"
7 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h " 7 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h "
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
(...skipping 17 matching lines...) Expand all
28 "if (typeof(chrome) == 'undefined') {" 28 "if (typeof(chrome) == 'undefined') {"
29 " chrome = {};" 29 " chrome = {};"
30 "};" 30 "};"
31 "if (typeof(chrome.gpuBenchmarking) == 'undefined') {" 31 "if (typeof(chrome.gpuBenchmarking) == 'undefined') {"
32 " chrome.gpuBenchmarking = {};" 32 " chrome.gpuBenchmarking = {};"
33 "};" 33 "};"
34 "chrome.gpuBenchmarking.renderingStats = function() {" 34 "chrome.gpuBenchmarking.renderingStats = function() {"
35 " native function GetRenderingStats();" 35 " native function GetRenderingStats();"
36 " return GetRenderingStats();" 36 " return GetRenderingStats();"
37 "};" 37 "};"
38 "chrome.gpuBenchmarking.measureRecordTime = function(dump) {"
nduca 2012/07/16 22:28:40 How about dumpToSkPicture = function(filename)
alokp 2012/07/16 22:38:09 I chose this name because it seemed more appropria
dmurph 2012/07/17 00:11:54 There's a sister patch for all rending microbenchm
39 " dump = dump || false;"
40 " native function MeasureRecordTime();"
41 " return MeasureRecordTime(dump);"
42 "};"
38 "chrome.gpuBenchmarking.beginSmoothScrollDown = " 43 "chrome.gpuBenchmarking.beginSmoothScrollDown = "
39 " function(scroll_far) {" 44 " function(scroll_far) {"
40 " scroll_far = scroll_far || false;" 45 " scroll_far = scroll_far || false;"
41 " native function BeginSmoothScroll();" 46 " native function BeginSmoothScroll();"
42 " return BeginSmoothScroll(true, scroll_far);" 47 " return BeginSmoothScroll(true, scroll_far);"
43 "};" 48 "};"
44 "chrome.gpuBenchmarking.beginSmoothScrollUp = function(scroll_far) {" 49 "chrome.gpuBenchmarking.beginSmoothScrollUp = function(scroll_far) {"
45 " scroll_far = scroll_far || false;" 50 " scroll_far = scroll_far || false;"
46 " native function BeginSmoothScroll();" 51 " native function BeginSmoothScroll();"
47 " return BeginSmoothScroll(false, scroll_far);" 52 " return BeginSmoothScroll(false, scroll_far);"
48 "};") {} 53 "};") {}
49 54
50 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 55 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
51 v8::Handle<v8::String> name) { 56 v8::Handle<v8::String> name) {
52 if (name->Equals(v8::String::New("GetRenderingStats"))) 57 if (name->Equals(v8::String::New("GetRenderingStats")))
53 return v8::FunctionTemplate::New(GetRenderingStats); 58 return v8::FunctionTemplate::New(GetRenderingStats);
59 if (name->Equals(v8::String::New("MeasureRecordTime")))
60 return v8::FunctionTemplate::New(MeasureRecordTime);
54 if (name->Equals(v8::String::New("BeginSmoothScroll"))) 61 if (name->Equals(v8::String::New("BeginSmoothScroll")))
55 return v8::FunctionTemplate::New(BeginSmoothScroll); 62 return v8::FunctionTemplate::New(BeginSmoothScroll);
56 63
57 return v8::Handle<v8::FunctionTemplate>(); 64 return v8::Handle<v8::FunctionTemplate>();
58 } 65 }
59 66
60 static v8::Handle<v8::Value> GetRenderingStats(const v8::Arguments& args) { 67 static v8::Handle<v8::Value> GetRenderingStats(const v8::Arguments& args) {
61 WebFrame* web_frame = WebFrame::frameForEnteredContext(); 68 WebFrame* web_frame = WebFrame::frameForEnteredContext();
62 if (!web_frame) 69 if (!web_frame)
63 return v8::Undefined(); 70 return v8::Undefined();
(...skipping 10 matching lines...) Expand all
74 stats_object->Set(v8::String::New("numAnimationFrames"), 81 stats_object->Set(v8::String::New("numAnimationFrames"),
75 v8::Integer::New(stats.numAnimationFrames), 82 v8::Integer::New(stats.numAnimationFrames),
76 v8::ReadOnly); 83 v8::ReadOnly);
77 if (stats.numFramesSentToScreen) 84 if (stats.numFramesSentToScreen)
78 stats_object->Set(v8::String::New("numFramesSentToScreen"), 85 stats_object->Set(v8::String::New("numFramesSentToScreen"),
79 v8::Integer::New(stats.numFramesSentToScreen), 86 v8::Integer::New(stats.numFramesSentToScreen),
80 v8::ReadOnly); 87 v8::ReadOnly);
81 return stats_object; 88 return stats_object;
82 } 89 }
83 90
91 static v8::Handle<v8::Value> MeasureRecordTime(const v8::Arguments& args) {
92 if (args.Length() != 1 || !args[0]->IsBoolean())
93 return v8::False();
94 bool dump = args[0]->BooleanValue();
95
96 WebFrame* web_frame = WebFrame::frameForEnteredContext();
97 if (!web_frame)
98 return v8::Undefined();
99
100 WebView* web_view = web_frame->view();
101 if (!web_view)
102 return v8::Undefined();
103
104 // TODO(alokp): Implement recroding time after patch for WKBUG 88271 lands.
105 double record_time = 0.0;
106 if (dump) {
nduca 2012/07/16 22:28:40 I'm not sure you need to measure recording time. Y
107 // Launch file chooser dialog to select the file into which the
108 // resulting SkPicture will be dumped.
nduca 2012/07/16 22:28:40 Use the filename that the script provides. The aut
alokp 2012/07/16 22:38:09 Makes it even easier. Will do.
109 // Note that for this to work Chrome needs to be launched with
110 // --no-sandbox command-line flag.
111 }
112 return v8::Number::New(record_time);
113 }
114
84 static v8::Handle<v8::Value> BeginSmoothScroll(const v8::Arguments& args) { 115 static v8::Handle<v8::Value> BeginSmoothScroll(const v8::Arguments& args) {
85 WebFrame* web_frame = WebFrame::frameForEnteredContext(); 116 WebFrame* web_frame = WebFrame::frameForEnteredContext();
86 if (!web_frame) 117 if (!web_frame)
87 return v8::Undefined(); 118 return v8::Undefined();
88 119
89 WebView* web_view = web_frame->view(); 120 WebView* web_view = web_frame->view();
90 if (!web_view) 121 if (!web_view)
91 return v8::Undefined(); 122 return v8::Undefined();
92 123
93 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); 124 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view);
94 if (!render_view_impl) 125 if (!render_view_impl)
95 return v8::Undefined(); 126 return v8::Undefined();
96 127
97 if (args.Length() != 2 || !args[0]->IsBoolean() || !args[1]->IsBoolean()) 128 if (args.Length() != 2 || !args[0]->IsBoolean() || !args[1]->IsBoolean())
98 return v8::False(); 129 return v8::False();
99 130
100 bool scroll_down = args[0]->BooleanValue(); 131 bool scroll_down = args[0]->BooleanValue();
101 bool scroll_far = args[1]->BooleanValue(); 132 bool scroll_far = args[1]->BooleanValue();
102 133
103 render_view_impl->BeginSmoothScroll(scroll_down, scroll_far); 134 render_view_impl->BeginSmoothScroll(scroll_down, scroll_far);
104 return v8::True(); 135 return v8::True();
105 } 136 }
106 }; 137 };
107 138
108 v8::Extension* GpuBenchmarkingExtension::Get() { 139 v8::Extension* GpuBenchmarkingExtension::Get() {
109 return new GpuBenchmarkingWrapper(); 140 return new GpuBenchmarkingWrapper();
110 } 141 }
111 142
112 } // namespace content 143 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698