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/values.h" | 7 #include "base/values.h" |
8 #include "cc/resources/picture.h" | 8 #include "cc/resources/picture.h" |
9 #include "content/public/renderer/v8_value_converter.h" | 9 #include "content/public/renderer/v8_value_converter.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebArrayBuffer.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebArrayBuffer.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 v8::String::Value v8_picture(args[0]); | 69 v8::String::Value v8_picture(args[0]); |
70 scoped_ptr<base::Value> picture_value( | 70 scoped_ptr<base::Value> picture_value( |
71 converter->FromV8Value( | 71 converter->FromV8Value( |
72 args[0], v8::Context::GetCurrent())); | 72 args[0], v8::Context::GetCurrent())); |
73 if (!picture_value) | 73 if (!picture_value) |
74 return v8::Undefined(); | 74 return v8::Undefined(); |
75 | 75 |
76 scoped_refptr<cc::Picture> picture = | 76 scoped_refptr<cc::Picture> picture = |
77 cc::Picture::CreateFromValue(picture_value.get()); | 77 cc::Picture::CreateFromValue(picture_value.get()); |
78 if (!picture) | 78 if (!picture.get()) |
79 return v8::Undefined(); | 79 return v8::Undefined(); |
80 | 80 |
81 float scale = 1.0f; | 81 float scale = 1.0f; |
82 if (args.Length() > 1 && args[1]->IsNumber()) | 82 if (args.Length() > 1 && args[1]->IsNumber()) |
83 scale = std::max(0.01, std::min(100.0, args[1]->NumberValue())); | 83 scale = std::max(0.01, std::min(100.0, args[1]->NumberValue())); |
84 | 84 |
85 gfx::RectF clip(picture->LayerRect()); | 85 gfx::RectF clip(picture->LayerRect()); |
86 if (args.Length() > 2 && args[2]->IsArray()) { | 86 if (args.Length() > 2 && args[2]->IsArray()) { |
87 v8::Array* a = v8::Array::Cast(*args[2]); | 87 v8::Array* a = v8::Array::Cast(*args[2]); |
88 if (a->Length() == 4 | 88 if (a->Length() == 4 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // FIXME: remove this after Skia updates SkGraphics::Init() to be | 156 // FIXME: remove this after Skia updates SkGraphics::Init() to be |
157 // thread-safe and idempotent. | 157 // thread-safe and idempotent. |
158 static bool skia_initialized = false; | 158 static bool skia_initialized = false; |
159 if (!skia_initialized) { | 159 if (!skia_initialized) { |
160 SkGraphics::Init(); | 160 SkGraphics::Init(); |
161 skia_initialized = true; | 161 skia_initialized = true; |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 } // namespace content | 165 } // namespace content |
OLD | NEW |