OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/laser/laser_pointer_view.h" | 5 #include "ash/laser/laser_pointer_view.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "ash/laser/laser_pointer_points.h" | 9 #include "ash/laser/laser_pointer_points.h" |
10 #include "ash/laser/laser_segment_utils.h" | 10 #include "ash/laser/laser_segment_utils.h" |
11 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
15 #include "third_party/skia/include/core/SkPaint.h" | |
16 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
17 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
18 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
19 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
20 | 19 |
21 namespace ash { | 20 namespace ash { |
22 namespace { | 21 namespace { |
23 | 22 |
24 // Variables for rendering the laser. Radius in DIP. | 23 // Variables for rendering the laser. Radius in DIP. |
25 const float kPointInitialRadius = 5.0f; | 24 const float kPointInitialRadius = 5.0f; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 bounding_box.set_width(bounding_box.width() + (kPointInitialRadius * 2)); | 211 bounding_box.set_width(bounding_box.width() + (kPointInitialRadius * 2)); |
213 bounding_box.set_height(bounding_box.height() + (kPointInitialRadius * 2)); | 212 bounding_box.set_height(bounding_box.height() + (kPointInitialRadius * 2)); |
214 widget_->SetBounds(bounding_box); | 213 widget_->SetBounds(bounding_box); |
215 SchedulePaint(); | 214 SchedulePaint(); |
216 } | 215 } |
217 | 216 |
218 void LaserPointerView::OnPaint(gfx::Canvas* canvas) { | 217 void LaserPointerView::OnPaint(gfx::Canvas* canvas) { |
219 if (laser_points_.IsEmpty()) | 218 if (laser_points_.IsEmpty()) |
220 return; | 219 return; |
221 | 220 |
222 SkPaint paint; | 221 cc::PaintFlags paint; |
223 paint.setStyle(SkPaint::kFill_Style); | 222 paint.setStyle(cc::PaintFlags::kFill_Style); |
224 paint.setAntiAlias(true); | 223 paint.setAntiAlias(true); |
225 | 224 |
226 // Compute the offset of the current widget. | 225 // Compute the offset of the current widget. |
227 gfx::Vector2d widget_offset( | 226 gfx::Vector2d widget_offset( |
228 widget_->GetNativeView()->GetBoundsInRootWindow().origin().x(), | 227 widget_->GetNativeView()->GetBoundsInRootWindow().origin().x(), |
229 widget_->GetNativeView()->GetBoundsInRootWindow().origin().y()); | 228 widget_->GetNativeView()->GetBoundsInRootWindow().origin().y()); |
230 | 229 |
231 int num_points = laser_points_.GetNumberOfPoints(); | 230 int num_points = laser_points_.GetNumberOfPoints(); |
232 DCHECK(num_points > 0); | 231 DCHECK(num_points > 0); |
233 LaserPointerPoints::LaserPoint previous_point = laser_points_.GetOldest(); | 232 LaserPointerPoints::LaserPoint previous_point = laser_points_.GetOldest(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 SkPath path = current_segment.path(); | 264 SkPath path = current_segment.path(); |
266 paint.setColor(SkColorSetA(kPointColor, current_opacity)); | 265 paint.setColor(SkColorSetA(kPointColor, current_opacity)); |
267 canvas->DrawPath(path, paint); | 266 canvas->DrawPath(path, paint); |
268 | 267 |
269 previous_segment_points = current_segment.path_points(); | 268 previous_segment_points = current_segment.path_points(); |
270 previous_radius = current_radius; | 269 previous_radius = current_radius; |
271 previous_point = current_point; | 270 previous_point = current_point; |
272 } | 271 } |
273 // Draw the last point as a circle. | 272 // Draw the last point as a circle. |
274 paint.setColor(SkColorSetA(kPointColor, current_opacity)); | 273 paint.setColor(SkColorSetA(kPointColor, current_opacity)); |
275 paint.setStyle(SkPaint::kFill_Style); | 274 paint.setStyle(cc::PaintFlags::kFill_Style); |
276 canvas->DrawCircle(current_point.location, kPointInitialRadius, paint); | 275 canvas->DrawCircle(current_point.location, kPointInitialRadius, paint); |
277 } | 276 } |
278 } // namespace ash | 277 } // namespace ash |
OLD | NEW |