| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/devtools/devtools_eye_dropper.h" | 5 #include "chrome/browser/devtools/devtools_eye_dropper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
| 10 #include "content/public/browser/render_widget_host.h" | 10 #include "content/public/browser/render_widget_host.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 return true; | 119 return true; |
| 120 | 120 |
| 121 if (event.button == blink::WebMouseEvent::Button::kLeft && | 121 if (event.button == blink::WebMouseEvent::Button::kLeft && |
| 122 (event.GetType() == blink::WebInputEvent::kMouseDown || | 122 (event.GetType() == blink::WebInputEvent::kMouseDown || |
| 123 event.GetType() == blink::WebInputEvent::kMouseMove)) { | 123 event.GetType() == blink::WebInputEvent::kMouseMove)) { |
| 124 if (last_cursor_x_ < 0 || last_cursor_x_ >= frame_.width() || | 124 if (last_cursor_x_ < 0 || last_cursor_x_ >= frame_.width() || |
| 125 last_cursor_y_ < 0 || last_cursor_y_ >= frame_.height()) { | 125 last_cursor_y_ < 0 || last_cursor_y_ >= frame_.height()) { |
| 126 return true; | 126 return true; |
| 127 } | 127 } |
| 128 | 128 |
| 129 SkAutoLockPixels lock_image(frame_); | |
| 130 SkColor sk_color = frame_.getColor(last_cursor_x_, last_cursor_y_); | 129 SkColor sk_color = frame_.getColor(last_cursor_x_, last_cursor_y_); |
| 131 callback_.Run(SkColorGetR(sk_color), SkColorGetG(sk_color), | 130 callback_.Run(SkColorGetR(sk_color), SkColorGetG(sk_color), |
| 132 SkColorGetB(sk_color), SkColorGetA(sk_color)); | 131 SkColorGetB(sk_color), SkColorGetA(sk_color)); |
| 133 } | 132 } |
| 134 UpdateCursor(); | 133 UpdateCursor(); |
| 135 return true; | 134 return true; |
| 136 } | 135 } |
| 137 | 136 |
| 138 void DevToolsEyeDropper::UpdateCursor() { | 137 void DevToolsEyeDropper::UpdateCursor() { |
| 139 if (!host_ || frame_.drawsNothing()) | 138 if (!host_ || frame_.drawsNothing()) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 canvas.drawCircle(kCursorSize / 2, kCursorSize / 2, kDiameter / 2, paint); | 240 canvas.drawCircle(kCursorSize / 2, kCursorSize / 2, kDiameter / 2, paint); |
| 242 | 241 |
| 243 content::CursorInfo cursor_info; | 242 content::CursorInfo cursor_info; |
| 244 cursor_info.type = blink::WebCursorInfo::kTypeCustom; | 243 cursor_info.type = blink::WebCursorInfo::kTypeCustom; |
| 245 cursor_info.image_scale_factor = device_scale_factor; | 244 cursor_info.image_scale_factor = device_scale_factor; |
| 246 cursor_info.custom_image = result; | 245 cursor_info.custom_image = result; |
| 247 cursor_info.hotspot = gfx::Point(kHotspotOffset * device_scale_factor, | 246 cursor_info.hotspot = gfx::Point(kHotspotOffset * device_scale_factor, |
| 248 kHotspotOffset * device_scale_factor); | 247 kHotspotOffset * device_scale_factor); |
| 249 host_->SetCursor(cursor_info); | 248 host_->SetCursor(cursor_info); |
| 250 } | 249 } |
| OLD | NEW |