| 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/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/resources/picture.h" | 10 #include "cc/resources/picture.h" |
| 11 #include "content/public/renderer/v8_value_converter.h" | 11 #include "content/public/renderer/v8_value_converter.h" |
| 12 #include "skia/ext/benchmarking_canvas.h" | 12 #include "skia/ext/benchmarking_canvas.h" |
| 13 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" | 13 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
| 14 #include "third_party/WebKit/public/web/WebFrame.h" | 14 #include "third_party/WebKit/public/web/WebFrame.h" |
| 15 #include "third_party/skia/include/core/SkBitmapDevice.h" |
| 15 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
| 16 #include "third_party/skia/include/core/SkColorPriv.h" | 17 #include "third_party/skia/include/core/SkColorPriv.h" |
| 17 #include "third_party/skia/include/core/SkDevice.h" | |
| 18 #include "third_party/skia/include/core/SkGraphics.h" | 18 #include "third_party/skia/include/core/SkGraphics.h" |
| 19 #include "third_party/skia/src/utils/debugger/SkDebugCanvas.h" | 19 #include "third_party/skia/src/utils/debugger/SkDebugCanvas.h" |
| 20 #include "third_party/skia/src/utils/debugger/SkDrawCommand.h" | 20 #include "third_party/skia/src/utils/debugger/SkDrawCommand.h" |
| 21 #include "ui/gfx/rect_conversions.h" | 21 #include "ui/gfx/rect_conversions.h" |
| 22 #include "ui/gfx/skia_util.h" | 22 #include "ui/gfx/skia_util.h" |
| 23 #include "v8/include/v8.h" | 23 #include "v8/include/v8.h" |
| 24 | 24 |
| 25 using WebKit::WebFrame; | 25 using WebKit::WebFrame; |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 if (args.Length() != 1) | 243 if (args.Length() != 1) |
| 244 return; | 244 return; |
| 245 | 245 |
| 246 scoped_refptr<cc::Picture> picture = ParsePictureArg(args[0]); | 246 scoped_refptr<cc::Picture> picture = ParsePictureArg(args[0]); |
| 247 if (!picture.get()) | 247 if (!picture.get()) |
| 248 return; | 248 return; |
| 249 | 249 |
| 250 gfx::Rect bounds = picture->LayerRect(); | 250 gfx::Rect bounds = picture->LayerRect(); |
| 251 | 251 |
| 252 // Measure the total time by drawing straight into a bitmap-backed canvas. | 252 // Measure the total time by drawing straight into a bitmap-backed canvas. |
| 253 skia::RefPtr<SkDevice> device = skia::AdoptRef(SkNEW_ARGS(SkDevice, | 253 skia::RefPtr<SkBaseDevice> device = skia::AdoptRef( |
| 254 (SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()))); | 254 SkNEW_ARGS(SkBitmapDevice, |
| 255 (SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()))); |
| 255 SkCanvas bitmap_canvas(device.get()); | 256 SkCanvas bitmap_canvas(device.get()); |
| 256 bitmap_canvas.clear(SK_ColorTRANSPARENT); | 257 bitmap_canvas.clear(SK_ColorTRANSPARENT); |
| 257 base::TimeTicks t0 = base::TimeTicks::HighResNow(); | 258 base::TimeTicks t0 = base::TimeTicks::HighResNow(); |
| 258 picture->Replay(&bitmap_canvas); | 259 picture->Replay(&bitmap_canvas); |
| 259 base::TimeDelta total_time = base::TimeTicks::HighResNow() - t0; | 260 base::TimeDelta total_time = base::TimeTicks::HighResNow() - t0; |
| 260 | 261 |
| 261 // Gather per-op timing info by drawing into a BenchmarkingCanvas. | 262 // Gather per-op timing info by drawing into a BenchmarkingCanvas. |
| 262 skia::BenchmarkingCanvas benchmarking_canvas(bounds.width(), | 263 skia::BenchmarkingCanvas benchmarking_canvas(bounds.width(), |
| 263 bounds.height()); | 264 bounds.height()); |
| 264 picture->Replay(&benchmarking_canvas); | 265 picture->Replay(&benchmarking_canvas); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 291 // FIXME: remove this after Skia updates SkGraphics::Init() to be | 292 // FIXME: remove this after Skia updates SkGraphics::Init() to be |
| 292 // thread-safe and idempotent. | 293 // thread-safe and idempotent. |
| 293 static bool skia_initialized = false; | 294 static bool skia_initialized = false; |
| 294 if (!skia_initialized) { | 295 if (!skia_initialized) { |
| 295 SkGraphics::Init(); | 296 SkGraphics::Init(); |
| 296 skia_initialized = true; | 297 skia_initialized = true; |
| 297 } | 298 } |
| 298 } | 299 } |
| 299 | 300 |
| 300 } // namespace content | 301 } // namespace content |
| OLD | NEW |