| 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" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 bounding_box.set_width(bounding_box.width() + (kPointInitialRadius * 2)); | 211 bounding_box.set_width(bounding_box.width() + (kPointInitialRadius * 2)); |
| 212 bounding_box.set_height(bounding_box.height() + (kPointInitialRadius * 2)); | 212 bounding_box.set_height(bounding_box.height() + (kPointInitialRadius * 2)); |
| 213 widget_->SetBounds(bounding_box); | 213 widget_->SetBounds(bounding_box); |
| 214 SchedulePaint(); | 214 SchedulePaint(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void LaserPointerView::OnPaint(gfx::Canvas* canvas) { | 217 void LaserPointerView::OnPaint(gfx::Canvas* canvas) { |
| 218 if (laser_points_.IsEmpty()) | 218 if (laser_points_.IsEmpty()) |
| 219 return; | 219 return; |
| 220 | 220 |
| 221 cc::PaintFlags paint; | 221 cc::PaintFlags flags; |
| 222 paint.setStyle(cc::PaintFlags::kFill_Style); | 222 flags.setStyle(cc::PaintFlags::kFill_Style); |
| 223 paint.setAntiAlias(true); | 223 flags.setAntiAlias(true); |
| 224 | 224 |
| 225 // Compute the offset of the current widget. | 225 // Compute the offset of the current widget. |
| 226 gfx::Vector2d widget_offset( | 226 gfx::Vector2d widget_offset( |
| 227 widget_->GetNativeView()->GetBoundsInRootWindow().origin().x(), | 227 widget_->GetNativeView()->GetBoundsInRootWindow().origin().x(), |
| 228 widget_->GetNativeView()->GetBoundsInRootWindow().origin().y()); | 228 widget_->GetNativeView()->GetBoundsInRootWindow().origin().y()); |
| 229 | 229 |
| 230 int num_points = laser_points_.GetNumberOfPoints(); | 230 int num_points = laser_points_.GetNumberOfPoints(); |
| 231 DCHECK(num_points > 0); | 231 DCHECK(num_points > 0); |
| 232 LaserPointerPoints::LaserPoint previous_point = laser_points_.GetOldest(); | 232 LaserPointerPoints::LaserPoint previous_point = laser_points_.GetOldest(); |
| 233 previous_point.location -= widget_offset; | 233 previous_point.location -= widget_offset; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 255 i != num_points - 1) { | 255 i != num_points - 1) { |
| 256 continue; | 256 continue; |
| 257 } | 257 } |
| 258 | 258 |
| 259 LaserSegment current_segment( | 259 LaserSegment current_segment( |
| 260 previous_segment_points, gfx::PointF(previous_point.location), | 260 previous_segment_points, gfx::PointF(previous_point.location), |
| 261 gfx::PointF(current_point.location), previous_radius, current_radius, | 261 gfx::PointF(current_point.location), previous_radius, current_radius, |
| 262 i == num_points - 1); | 262 i == num_points - 1); |
| 263 | 263 |
| 264 SkPath path = current_segment.path(); | 264 SkPath path = current_segment.path(); |
| 265 paint.setColor(SkColorSetA(kPointColor, current_opacity)); | 265 flags.setColor(SkColorSetA(kPointColor, current_opacity)); |
| 266 canvas->DrawPath(path, paint); | 266 canvas->DrawPath(path, flags); |
| 267 | 267 |
| 268 previous_segment_points = current_segment.path_points(); | 268 previous_segment_points = current_segment.path_points(); |
| 269 previous_radius = current_radius; | 269 previous_radius = current_radius; |
| 270 previous_point = current_point; | 270 previous_point = current_point; |
| 271 } | 271 } |
| 272 // Draw the last point as a circle. | 272 // Draw the last point as a circle. |
| 273 paint.setColor(SkColorSetA(kPointColor, current_opacity)); | 273 flags.setColor(SkColorSetA(kPointColor, current_opacity)); |
| 274 paint.setStyle(cc::PaintFlags::kFill_Style); | 274 flags.setStyle(cc::PaintFlags::kFill_Style); |
| 275 canvas->DrawCircle(current_point.location, kPointInitialRadius, paint); | 275 canvas->DrawCircle(current_point.location, kPointInitialRadius, flags); |
| 276 } | 276 } |
| 277 } // namespace ash | 277 } // namespace ash |
| OLD | NEW |