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

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

Issue 2931393003: [Content] Update V8ValueConverter::create to return a std::unique_ptr (Closed)
Patch Set: rebase Created 3 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 } 70 }
71 if (img && subset) 71 if (img && subset)
72 img = img->makeSubset(*subset); 72 img = img->makeSubset(*subset);
73 return img; 73 return img;
74 } 74 }
75 }; 75 };
76 76
77 std::unique_ptr<base::Value> ParsePictureArg(v8::Isolate* isolate, 77 std::unique_ptr<base::Value> ParsePictureArg(v8::Isolate* isolate,
78 v8::Local<v8::Value> arg) { 78 v8::Local<v8::Value> arg) {
79 std::unique_ptr<content::V8ValueConverter> converter( 79 return content::V8ValueConverter::Create()->FromV8Value(
80 content::V8ValueConverter::create()); 80 arg, isolate->GetCurrentContext());
81 return std::unique_ptr<base::Value>(
82 converter->FromV8Value(arg, isolate->GetCurrentContext()));
83 } 81 }
84 82
85 std::unique_ptr<Picture> CreatePictureFromEncodedString( 83 std::unique_ptr<Picture> CreatePictureFromEncodedString(
86 const std::string& encoded) { 84 const std::string& encoded) {
87 std::string decoded; 85 std::string decoded;
88 base::Base64Decode(encoded, &decoded); 86 base::Base64Decode(encoded, &decoded);
89 SkMemoryStream stream(decoded.data(), decoded.size()); 87 SkMemoryStream stream(decoded.data(), decoded.size());
90 GfxImageDeserializer deserializer; 88 GfxImageDeserializer deserializer;
91 sk_sp<SkPicture> skpicture = 89 sk_sp<SkPicture> skpicture =
92 SkPicture::MakeFromStream(&stream, &deserializer); 90 SkPicture::MakeFromStream(&stream, &deserializer);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 return; 200 return;
203 201
204 double scale = 1.0; 202 double scale = 1.0;
205 gfx::Rect clip_rect(picture->layer_rect); 203 gfx::Rect clip_rect(picture->layer_rect);
206 int stop_index = -1; 204 int stop_index = -1;
207 205
208 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 206 v8::Local<v8::Context> context = isolate->GetCurrentContext();
209 if (!args->PeekNext().IsEmpty()) { 207 if (!args->PeekNext().IsEmpty()) {
210 v8::Local<v8::Value> params; 208 v8::Local<v8::Value> params;
211 args->GetNext(&params); 209 args->GetNext(&params);
212 std::unique_ptr<content::V8ValueConverter> converter( 210 std::unique_ptr<base::Value> params_value =
213 content::V8ValueConverter::create()); 211 content::V8ValueConverter::Create()->FromV8Value(params, context);
214 std::unique_ptr<base::Value> params_value(
215 converter->FromV8Value(params, context));
216 212
217 const base::DictionaryValue* params_dict = NULL; 213 const base::DictionaryValue* params_dict = NULL;
218 if (params_value.get() && params_value->GetAsDictionary(&params_dict)) { 214 if (params_value.get() && params_value->GetAsDictionary(&params_dict)) {
219 params_dict->GetDouble("scale", &scale); 215 params_dict->GetDouble("scale", &scale);
220 params_dict->GetInteger("stop", &stop_index); 216 params_dict->GetInteger("stop", &stop_index);
221 217
222 const base::Value* clip_value = NULL; 218 const base::Value* clip_value = NULL;
223 if (params_dict->Get("clip", &clip_value)) 219 if (params_dict->Get("clip", &clip_value))
224 cc::MathUtil::FromValue(clip_value, &clip_rect); 220 cc::MathUtil::FromValue(clip_value, &clip_rect);
225 } 221 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 args->GetNext(&picture_handle); 271 args->GetNext(&picture_handle);
276 std::unique_ptr<Picture> picture = ParsePictureHash(isolate, picture_handle); 272 std::unique_ptr<Picture> picture = ParsePictureHash(isolate, picture_handle);
277 if (!picture.get()) 273 if (!picture.get())
278 return; 274 return;
279 275
280 SkCanvas canvas(picture->layer_rect.width(), picture->layer_rect.height()); 276 SkCanvas canvas(picture->layer_rect.width(), picture->layer_rect.height());
281 skia::BenchmarkingCanvas benchmarking_canvas(&canvas); 277 skia::BenchmarkingCanvas benchmarking_canvas(&canvas);
282 picture->picture->playback(&benchmarking_canvas); 278 picture->picture->playback(&benchmarking_canvas);
283 279
284 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 280 v8::Local<v8::Context> context = isolate->GetCurrentContext();
285 std::unique_ptr<content::V8ValueConverter> converter(
286 content::V8ValueConverter::create());
287 281
288 args->Return(converter->ToV8Value(&benchmarking_canvas.Commands(), context)); 282 args->Return(content::V8ValueConverter::Create()->ToV8Value(
283 &benchmarking_canvas.Commands(), context));
289 } 284 }
290 285
291 void SkiaBenchmarking::GetOpTimings(gin::Arguments* args) { 286 void SkiaBenchmarking::GetOpTimings(gin::Arguments* args) {
292 v8::Isolate* isolate = args->isolate(); 287 v8::Isolate* isolate = args->isolate();
293 if (args->PeekNext().IsEmpty()) 288 if (args->PeekNext().IsEmpty())
294 return; 289 return;
295 v8::Local<v8::Value> picture_handle; 290 v8::Local<v8::Value> picture_handle;
296 args->GetNext(&picture_handle); 291 args->GetNext(&picture_handle);
297 std::unique_ptr<Picture> picture = ParsePictureHash(isolate, picture_handle); 292 std::unique_ptr<Picture> picture = ParsePictureHash(isolate, picture_handle);
298 if (!picture.get()) 293 if (!picture.get())
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 v8::Local<v8::Object> result = v8::Object::New(isolate); 337 v8::Local<v8::Object> result = v8::Object::New(isolate);
343 result->Set(v8::String::NewFromUtf8(isolate, "width"), 338 result->Set(v8::String::NewFromUtf8(isolate, "width"),
344 v8::Number::New(isolate, picture->layer_rect.width())); 339 v8::Number::New(isolate, picture->layer_rect.width()));
345 result->Set(v8::String::NewFromUtf8(isolate, "height"), 340 result->Set(v8::String::NewFromUtf8(isolate, "height"),
346 v8::Number::New(isolate, picture->layer_rect.height())); 341 v8::Number::New(isolate, picture->layer_rect.height()));
347 342
348 args->Return(result); 343 args->Return(result);
349 } 344 }
350 345
351 } // namespace content 346 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/java/gin_java_bridge_value_converter.cc ('k') | content/renderer/web_ui_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698