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