| 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 "chrome/browser/chromeos/ui/accessibility_cursor_ring_layer.h" | 5 #include "chrome/browser/chromeos/ui/accessibility_cursor_ring_layer.h" |
| 6 | 6 |
| 7 #include "ash/display/window_tree_host_manager.h" | 7 #include "ash/display/window_tree_host_manager.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "third_party/skia/include/core/SkPaint.h" | 10 #include "third_party/skia/include/core/SkPaint.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 bounds.Inset(-inset, -inset, -inset, -inset); | 46 bounds.Inset(-inset, -inset, -inset, -inset); |
| 47 | 47 |
| 48 display::Display display = | 48 display::Display display = |
| 49 display::Screen::GetScreen()->GetDisplayMatching(bounds); | 49 display::Screen::GetScreen()->GetDisplayMatching(bounds); |
| 50 aura::Window* root_window = ash::Shell::GetInstance() | 50 aura::Window* root_window = ash::Shell::GetInstance() |
| 51 ->window_tree_host_manager() | 51 ->window_tree_host_manager() |
| 52 ->GetRootWindowForDisplayId(display.id()); | 52 ->GetRootWindowForDisplayId(display.id()); |
| 53 CreateOrUpdateLayer(root_window, "AccessibilityCursorRing", bounds); | 53 CreateOrUpdateLayer(root_window, "AccessibilityCursorRing", bounds); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void AccessibilityCursorRingLayer::SetOpacity(float opacity) { | |
| 57 layer()->SetOpacity(opacity); | |
| 58 } | |
| 59 | |
| 60 void AccessibilityCursorRingLayer::OnPaintLayer( | 56 void AccessibilityCursorRingLayer::OnPaintLayer( |
| 61 const ui::PaintContext& context) { | 57 const ui::PaintContext& context) { |
| 62 ui::PaintRecorder recorder(context, layer()->size()); | 58 ui::PaintRecorder recorder(context, layer()->size()); |
| 63 | 59 |
| 64 SkPaint paint; | 60 SkPaint paint; |
| 65 paint.setFlags(SkPaint::kAntiAlias_Flag); | 61 paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 66 paint.setStyle(SkPaint::kStroke_Style); | 62 paint.setStyle(SkPaint::kStroke_Style); |
| 67 paint.setStrokeWidth(2); | 63 paint.setStrokeWidth(2); |
| 68 | 64 |
| 69 gfx::Rect r = layer()->bounds(); | 65 gfx::Rect r = layer()->bounds(); |
| 70 r.Offset(-r.OffsetFromOrigin()); | 66 r.Offset(-r.OffsetFromOrigin()); |
| 71 r.Inset(kLayerMargin, kLayerMargin, kLayerMargin, kLayerMargin); | 67 r.Inset(kLayerMargin, kLayerMargin, kLayerMargin, kLayerMargin); |
| 72 const int w = kGradientWidth; | 68 const int w = kGradientWidth; |
| 73 for (int i = 0; i < w; ++i) { | 69 for (int i = 0; i < w; ++i) { |
| 74 paint.setColor( | 70 paint.setColor( |
| 75 SkColorSetARGBMacro(255 * (i) * (i) / (w * w), red_, green_, blue_)); | 71 SkColorSetARGBMacro(255 * (i) * (i) / (w * w), red_, green_, blue_)); |
| 76 SkPath path; | 72 SkPath path; |
| 77 path.addOval(SkRect::MakeXYWH(r.x(), r.y(), r.width(), r.height())); | 73 path.addOval(SkRect::MakeXYWH(r.x(), r.y(), r.width(), r.height())); |
| 78 r.Inset(1, 1, 1, 1); | 74 r.Inset(1, 1, 1, 1); |
| 79 recorder.canvas()->DrawPath(path, paint); | 75 recorder.canvas()->DrawPath(path, paint); |
| 80 } | 76 } |
| 81 } | 77 } |
| 82 | 78 |
| 83 } // namespace chromeos | 79 } // namespace chromeos |
| OLD | NEW |