Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: chrome/browser/chromeos/ui/accessibility_cursor_ring_layer.cc

Issue 2779653003: WindowTreeHostManager::GetRootWindowForDisplayId -> WmShell::GetRoo... (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/immersive_fullscreen_controller_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/wm_shell.h"
7 #include "ash/common/wm_window.h" 8 #include "ash/common/wm_window.h"
8 #include "ash/display/window_tree_host_manager.h"
9 #include "ash/shell.h"
10 #include "base/bind.h"
11 #include "third_party/skia/include/core/SkPaint.h" 9 #include "third_party/skia/include/core/SkPaint.h"
12 #include "third_party/skia/include/core/SkPath.h" 10 #include "third_party/skia/include/core/SkPath.h"
13 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
14 #include "ui/compositor/layer.h" 12 #include "ui/compositor/layer.h"
15 #include "ui/compositor/paint_recorder.h" 13 #include "ui/compositor/paint_recorder.h"
14 #include "ui/display/display.h"
15 #include "ui/display/screen.h"
16 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 namespace { 20 namespace {
21 21
22 // The number of pixels in the color gradient that fades to transparent. 22 // The number of pixels in the color gradient that fades to transparent.
23 const int kGradientWidth = 8; 23 const int kGradientWidth = 8;
24 24
25 // The radius of the ring in pixels. 25 // The radius of the ring in pixels.
(...skipping 15 matching lines...) Expand all
41 41
42 void AccessibilityCursorRingLayer::Set(const gfx::Point& location) { 42 void AccessibilityCursorRingLayer::Set(const gfx::Point& location) {
43 location_ = location; 43 location_ = location;
44 44
45 gfx::Rect bounds = gfx::Rect(location.x(), location.y(), 0, 0); 45 gfx::Rect bounds = gfx::Rect(location.x(), location.y(), 0, 0);
46 int inset = kGradientWidth + kCursorRingRadius + kLayerMargin; 46 int inset = kGradientWidth + kCursorRingRadius + kLayerMargin;
47 bounds.Inset(-inset, -inset, -inset, -inset); 47 bounds.Inset(-inset, -inset, -inset, -inset);
48 48
49 display::Display display = 49 display::Display display =
50 display::Screen::GetScreen()->GetDisplayMatching(bounds); 50 display::Screen::GetScreen()->GetDisplayMatching(bounds);
51 aura::Window* root_window = ash::Shell::GetInstance() 51 ash::WmWindow* root_wm_window =
52 ->window_tree_host_manager() 52 ash::WmShell::Get()->GetRootWindowForDisplayId(display.id());
53 ->GetRootWindowForDisplayId(display.id()); 53 aura::Window* root_window = root_wm_window->aura_window();
54 ash::WmWindow* root_wm_window = ash::WmWindow::Get(root_window);
55 bounds = root_wm_window->ConvertRectFromScreen(bounds); 54 bounds = root_wm_window->ConvertRectFromScreen(bounds);
56 CreateOrUpdateLayer(root_window, "AccessibilityCursorRing", bounds); 55 CreateOrUpdateLayer(root_window, "AccessibilityCursorRing", bounds);
57 } 56 }
58 57
59 void AccessibilityCursorRingLayer::OnPaintLayer( 58 void AccessibilityCursorRingLayer::OnPaintLayer(
60 const ui::PaintContext& context) { 59 const ui::PaintContext& context) {
61 ui::PaintRecorder recorder(context, layer()->size()); 60 ui::PaintRecorder recorder(context, layer()->size());
62 61
63 cc::PaintFlags flags; 62 cc::PaintFlags flags;
64 flags.setAntiAlias(true); 63 flags.setAntiAlias(true);
65 flags.setStyle(cc::PaintFlags::kStroke_Style); 64 flags.setStyle(cc::PaintFlags::kStroke_Style);
66 flags.setStrokeWidth(2); 65 flags.setStrokeWidth(2);
67 66
68 gfx::Rect r = layer()->bounds(); 67 gfx::Rect r = layer()->bounds();
69 r.Offset(-r.OffsetFromOrigin()); 68 r.Offset(-r.OffsetFromOrigin());
70 r.Inset(kLayerMargin, kLayerMargin, kLayerMargin, kLayerMargin); 69 r.Inset(kLayerMargin, kLayerMargin, kLayerMargin, kLayerMargin);
71 const int w = kGradientWidth; 70 const int w = kGradientWidth;
72 for (int i = 0; i < w; ++i) { 71 for (int i = 0; i < w; ++i) {
73 flags.setColor( 72 flags.setColor(
74 SkColorSetARGBMacro(255 * (i) * (i) / (w * w), red_, green_, blue_)); 73 SkColorSetARGBMacro(255 * (i) * (i) / (w * w), red_, green_, blue_));
75 SkPath path; 74 SkPath path;
76 path.addOval(SkRect::MakeXYWH(r.x(), r.y(), r.width(), r.height())); 75 path.addOval(SkRect::MakeXYWH(r.x(), r.y(), r.width(), r.height()));
77 r.Inset(1, 1, 1, 1); 76 r.Inset(1, 1, 1, 1);
78 recorder.canvas()->DrawPath(path, flags); 77 recorder.canvas()->DrawPath(path, flags);
79 } 78 }
80 } 79 }
81 80
82 } // namespace chromeos 81 } // namespace chromeos
OLDNEW
« no previous file with comments | « ash/wm/immersive_fullscreen_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698