| OLD | NEW |
| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 if (!picture.get()) | 256 if (!picture.get()) |
| 257 return; | 257 return; |
| 258 | 258 |
| 259 gfx::Rect bounds = picture->LayerRect(); | 259 gfx::Rect bounds = picture->LayerRect(); |
| 260 | 260 |
| 261 // Measure the total time by drawing straight into a bitmap-backed canvas. | 261 // Measure the total time by drawing straight into a bitmap-backed canvas. |
| 262 SkBitmap bitmap; | 262 SkBitmap bitmap; |
| 263 bitmap.allocN32Pixels(bounds.width(), bounds.height()); | 263 bitmap.allocN32Pixels(bounds.width(), bounds.height()); |
| 264 SkCanvas bitmap_canvas(bitmap); | 264 SkCanvas bitmap_canvas(bitmap); |
| 265 bitmap_canvas.clear(SK_ColorTRANSPARENT); | 265 bitmap_canvas.clear(SK_ColorTRANSPARENT); |
| 266 base::TimeTicks t0 = base::TimeTicks::HighResNow(); | 266 base::TimeTicks t0 = base::TimeTicks::Now(); |
| 267 picture->Replay(&bitmap_canvas); | 267 picture->Replay(&bitmap_canvas); |
| 268 base::TimeDelta total_time = base::TimeTicks::HighResNow() - t0; | 268 base::TimeDelta total_time = base::TimeTicks::Now() - t0; |
| 269 | 269 |
| 270 // Gather per-op timing info by drawing into a BenchmarkingCanvas. | 270 // Gather per-op timing info by drawing into a BenchmarkingCanvas. |
| 271 skia::BenchmarkingCanvas benchmarking_canvas(bounds.width(), bounds.height()); | 271 skia::BenchmarkingCanvas benchmarking_canvas(bounds.width(), bounds.height()); |
| 272 picture->Replay(&benchmarking_canvas); | 272 picture->Replay(&benchmarking_canvas); |
| 273 | 273 |
| 274 v8::Local<v8::Array> op_times = | 274 v8::Local<v8::Array> op_times = |
| 275 v8::Array::New(isolate, benchmarking_canvas.CommandCount()); | 275 v8::Array::New(isolate, benchmarking_canvas.CommandCount()); |
| 276 for (size_t i = 0; i < benchmarking_canvas.CommandCount(); ++i) | 276 for (size_t i = 0; i < benchmarking_canvas.CommandCount(); ++i) |
| 277 op_times->Set(i, v8::Number::New(isolate, benchmarking_canvas.GetTime(i))); | 277 op_times->Set(i, v8::Number::New(isolate, benchmarking_canvas.GetTime(i))); |
| 278 | 278 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 298 v8::Handle<v8::Object> result = v8::Object::New(isolate); | 298 v8::Handle<v8::Object> result = v8::Object::New(isolate); |
| 299 result->Set(v8::String::NewFromUtf8(isolate, "width"), | 299 result->Set(v8::String::NewFromUtf8(isolate, "width"), |
| 300 v8::Number::New(isolate, picture->LayerRect().width())); | 300 v8::Number::New(isolate, picture->LayerRect().width())); |
| 301 result->Set(v8::String::NewFromUtf8(isolate, "height"), | 301 result->Set(v8::String::NewFromUtf8(isolate, "height"), |
| 302 v8::Number::New(isolate, picture->LayerRect().height())); | 302 v8::Number::New(isolate, picture->LayerRect().height())); |
| 303 | 303 |
| 304 args->Return(result); | 304 args->Return(result); |
| 305 } | 305 } |
| 306 | 306 |
| 307 } // namespace content | 307 } // namespace content |
| OLD | NEW |