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/chromeos/ui/accessibility_focus_ring_layer.h" | 5 #include "chrome/browser/chromeos/ui/accessibility_focus_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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 gfx::Rect bounds = ring.GetBounds(); | 101 gfx::Rect bounds = ring.GetBounds(); |
102 int inset = kGradientWidth; | 102 int inset = kGradientWidth; |
103 bounds.Inset(-inset, -inset, -inset, -inset); | 103 bounds.Inset(-inset, -inset, -inset, -inset); |
104 | 104 |
105 display::Display display = | 105 display::Display display = |
106 display::Screen::GetScreen()->GetDisplayMatching(bounds); | 106 display::Screen::GetScreen()->GetDisplayMatching(bounds); |
107 aura::Window* root_window = ash::Shell::GetInstance() | 107 aura::Window* root_window = ash::Shell::GetInstance() |
108 ->window_tree_host_manager() | 108 ->window_tree_host_manager() |
109 ->GetRootWindowForDisplayId(display.id()); | 109 ->GetRootWindowForDisplayId(display.id()); |
110 CreateOrUpdateLayer(root_window, "AccessibilityFocusRing"); | 110 CreateOrUpdateLayer(root_window, "AccessibilityFocusRing", bounds); |
111 | |
112 // Update the layer bounds. | |
113 layer()->SetBounds(bounds); | |
114 } | 111 } |
115 | 112 |
116 void AccessibilityFocusRingLayer::OnPaintLayer( | 113 void AccessibilityFocusRingLayer::OnPaintLayer( |
117 const ui::PaintContext& context) { | 114 const ui::PaintContext& context) { |
118 ui::PaintRecorder recorder(context, layer()->size()); | 115 ui::PaintRecorder recorder(context, layer()->size()); |
119 | 116 |
120 SkPaint paint; | 117 SkPaint paint; |
121 paint.setFlags(SkPaint::kAntiAlias_Flag); | 118 paint.setFlags(SkPaint::kAntiAlias_Flag); |
122 paint.setStyle(SkPaint::kStroke_Style); | 119 paint.setStyle(SkPaint::kStroke_Style); |
123 paint.setStrokeWidth(2); | 120 paint.setStrokeWidth(2); |
124 | 121 |
125 SkPath path; | 122 SkPath path; |
126 gfx::Vector2d offset = layer()->bounds().OffsetFromOrigin(); | 123 gfx::Vector2d offset = layer()->bounds().OffsetFromOrigin(); |
127 const int w = kGradientWidth; | 124 const int w = kGradientWidth; |
128 for (int i = 0; i < w; ++i) { | 125 for (int i = 0; i < w; ++i) { |
129 paint.setColor( | 126 paint.setColor( |
130 SkColorSetARGBMacro( | 127 SkColorSetARGBMacro( |
131 255 * (w - i) * (w - i) / (w * w), | 128 255 * (w - i) * (w - i) / (w * w), |
132 kFocusRingColorRed, kFocusRingColorGreen, kFocusRingColorBlue)); | 129 kFocusRingColorRed, kFocusRingColorGreen, kFocusRingColorBlue)); |
133 path = MakePath(ring_, i, offset); | 130 path = MakePath(ring_, i, offset); |
134 recorder.canvas()->DrawPath(path, paint); | 131 recorder.canvas()->DrawPath(path, paint); |
135 } | 132 } |
136 } | 133 } |
137 | 134 |
138 } // namespace chromeos | 135 } // namespace chromeos |
OLD | NEW |