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

Side by Side Diff: content/renderer/skia_benchmarking_extension.cc

Issue 301883002: Should provide creation context and isolate for WebArrayConverter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed bad coding style Created 6 years, 6 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 | « content/renderer/pepper/v8_var_converter.cc ('k') | content/renderer/v8_value_converter_impl.h » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/skia_benchmarking_extension.h" 5 #include "content/renderer/skia_benchmarking_extension.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 scoped_refptr<cc::Picture> picture = 124 scoped_refptr<cc::Picture> picture =
125 ParsePictureHash(isolate, picture_handle); 125 ParsePictureHash(isolate, picture_handle);
126 if (!picture.get()) 126 if (!picture.get())
127 return; 127 return;
128 128
129 double scale = 1.0; 129 double scale = 1.0;
130 gfx::Rect clip_rect(picture->LayerRect()); 130 gfx::Rect clip_rect(picture->LayerRect());
131 int stop_index = -1; 131 int stop_index = -1;
132 bool overdraw = false; 132 bool overdraw = false;
133 133
134 v8::Handle<v8::Context> context = isolate->GetCurrentContext();
134 if (!args->PeekNext().IsEmpty()) { 135 if (!args->PeekNext().IsEmpty()) {
135 v8::Handle<v8::Value> params; 136 v8::Handle<v8::Value> params;
136 args->GetNext(&params); 137 args->GetNext(&params);
137 scoped_ptr<content::V8ValueConverter> converter( 138 scoped_ptr<content::V8ValueConverter> converter(
138 content::V8ValueConverter::create()); 139 content::V8ValueConverter::create());
139 scoped_ptr<base::Value> params_value( 140 scoped_ptr<base::Value> params_value(
140 converter->FromV8Value(params, isolate->GetCurrentContext())); 141 converter->FromV8Value(params, context));
141 142
142 const base::DictionaryValue* params_dict = NULL; 143 const base::DictionaryValue* params_dict = NULL;
143 if (params_value.get() && params_value->GetAsDictionary(&params_dict)) { 144 if (params_value.get() && params_value->GetAsDictionary(&params_dict)) {
144 params_dict->GetDouble("scale", &scale); 145 params_dict->GetDouble("scale", &scale);
145 params_dict->GetInteger("stop", &stop_index); 146 params_dict->GetInteger("stop", &stop_index);
146 params_dict->GetBoolean("overdraw", &overdraw); 147 params_dict->GetBoolean("overdraw", &overdraw);
147 148
148 const base::Value* clip_value = NULL; 149 const base::Value* clip_value = NULL;
149 if (params_dict->Get("clip", &clip_value)) 150 if (params_dict->Get("clip", &clip_value))
150 cc::MathUtil::FromValue(clip_value, &clip_rect); 151 cc::MathUtil::FromValue(clip_value, &clip_rect);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 buffer_pixels[i + 2] = SkGetPackedB32(c); 197 buffer_pixels[i + 2] = SkGetPackedB32(c);
197 buffer_pixels[i + 3] = SkGetPackedA32(c); 198 buffer_pixels[i + 3] = SkGetPackedA32(c);
198 } 199 }
199 200
200 v8::Handle<v8::Object> result = v8::Object::New(isolate); 201 v8::Handle<v8::Object> result = v8::Object::New(isolate);
201 result->Set(v8::String::NewFromUtf8(isolate, "width"), 202 result->Set(v8::String::NewFromUtf8(isolate, "width"),
202 v8::Number::New(isolate, snapped_clip.width())); 203 v8::Number::New(isolate, snapped_clip.width()));
203 result->Set(v8::String::NewFromUtf8(isolate, "height"), 204 result->Set(v8::String::NewFromUtf8(isolate, "height"),
204 v8::Number::New(isolate, snapped_clip.height())); 205 v8::Number::New(isolate, snapped_clip.height()));
205 result->Set(v8::String::NewFromUtf8(isolate, "data"), 206 result->Set(v8::String::NewFromUtf8(isolate, "data"),
206 blink::WebArrayBufferConverter::toV8Value(&buffer)); 207 blink::WebArrayBufferConverter::toV8Value(
208 &buffer, context->Global(), isolate));
207 209
208 args->Return(result); 210 args->Return(result);
209 } 211 }
210 212
211 void SkiaBenchmarking::GetOps(gin::Arguments* args) { 213 void SkiaBenchmarking::GetOps(gin::Arguments* args) {
212 v8::Isolate* isolate = args->isolate(); 214 v8::Isolate* isolate = args->isolate();
213 if (args->PeekNext().IsEmpty()) 215 if (args->PeekNext().IsEmpty())
214 return; 216 return;
215 v8::Handle<v8::Value> picture_handle; 217 v8::Handle<v8::Value> picture_handle;
216 args->GetNext(&picture_handle); 218 args->GetNext(&picture_handle);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 v8::Handle<v8::Object> result = v8::Object::New(isolate); 306 v8::Handle<v8::Object> result = v8::Object::New(isolate);
305 result->Set(v8::String::NewFromUtf8(isolate, "width"), 307 result->Set(v8::String::NewFromUtf8(isolate, "width"),
306 v8::Number::New(isolate, picture->LayerRect().width())); 308 v8::Number::New(isolate, picture->LayerRect().width()));
307 result->Set(v8::String::NewFromUtf8(isolate, "height"), 309 result->Set(v8::String::NewFromUtf8(isolate, "height"),
308 v8::Number::New(isolate, picture->LayerRect().height())); 310 v8::Number::New(isolate, picture->LayerRect().height()));
309 311
310 args->Return(result); 312 args->Return(result);
311 } 313 }
312 314
313 } // namespace content 315 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/v8_var_converter.cc ('k') | content/renderer/v8_value_converter_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698