OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/focus_ring_layer.h" | 5 #include "chrome/browser/chromeos/ui/focus_ring_layer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
9 #include "ui/compositor/layer.h" | 9 #include "ui/compositor/layer.h" |
| 10 #include "ui/compositor/paint_context.h" |
10 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
11 | 12 |
12 namespace chromeos { | 13 namespace chromeos { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 const int kShadowRadius = 10; | 17 const int kShadowRadius = 10; |
17 const int kShadowAlpha = 90; | 18 const int kShadowAlpha = 90; |
18 const SkColor kShadowColor = SkColorSetRGB(77, 144, 254); | 19 const SkColor kShadowColor = SkColorSetRGB(77, 144, 254); |
19 | 20 |
(...skipping 29 matching lines...) Expand all Loading... |
49 layer_->set_delegate(this); | 50 layer_->set_delegate(this); |
50 layer_->SetFillsBoundsOpaquely(false); | 51 layer_->SetFillsBoundsOpaquely(false); |
51 root_layer->Add(layer_.get()); | 52 root_layer->Add(layer_.get()); |
52 } | 53 } |
53 | 54 |
54 // Keep moving it to the top in case new layers have been added | 55 // Keep moving it to the top in case new layers have been added |
55 // since we created this layer. | 56 // since we created this layer. |
56 layer_->parent()->StackAtTop(layer_.get()); | 57 layer_->parent()->StackAtTop(layer_.get()); |
57 } | 58 } |
58 | 59 |
59 void FocusRingLayer::OnPaintLayer(gfx::Canvas* canvas) { | 60 void FocusRingLayer::OnPaintLayer(const ui::PaintContext& context) { |
60 if (!root_window_ || focus_ring_.IsEmpty()) | 61 if (!root_window_ || focus_ring_.IsEmpty()) |
61 return; | 62 return; |
62 | 63 |
| 64 gfx::Canvas* canvas = context.canvas(); |
63 gfx::Rect bounds = focus_ring_ - layer_->bounds().OffsetFromOrigin(); | 65 gfx::Rect bounds = focus_ring_ - layer_->bounds().OffsetFromOrigin(); |
64 SkPaint paint; | 66 SkPaint paint; |
65 paint.setColor(kShadowColor); | 67 paint.setColor(kShadowColor); |
66 paint.setFlags(SkPaint::kAntiAlias_Flag); | 68 paint.setFlags(SkPaint::kAntiAlias_Flag); |
67 paint.setStyle(SkPaint::kStroke_Style); | 69 paint.setStyle(SkPaint::kStroke_Style); |
68 paint.setStrokeWidth(2); | 70 paint.setStrokeWidth(2); |
69 int r = kShadowRadius; | 71 int r = kShadowRadius; |
70 for (int i = 0; i < r; i++) { | 72 for (int i = 0; i < r; i++) { |
71 // Fade out alpha quadratically. | 73 // Fade out alpha quadratically. |
72 paint.setAlpha((kShadowAlpha * (r - i) * (r - i)) / (r * r)); | 74 paint.setAlpha((kShadowAlpha * (r - i) * (r - i)) / (r * r)); |
(...skipping 10 matching lines...) Expand all Loading... |
83 void FocusRingLayer::OnDeviceScaleFactorChanged(float device_scale_factor) { | 85 void FocusRingLayer::OnDeviceScaleFactorChanged(float device_scale_factor) { |
84 if (delegate_) | 86 if (delegate_) |
85 delegate_->OnDeviceScaleFactorChanged(); | 87 delegate_->OnDeviceScaleFactorChanged(); |
86 } | 88 } |
87 | 89 |
88 base::Closure FocusRingLayer::PrepareForLayerBoundsChange() { | 90 base::Closure FocusRingLayer::PrepareForLayerBoundsChange() { |
89 return base::Bind(&base::DoNothing); | 91 return base::Bind(&base::DoNothing); |
90 } | 92 } |
91 | 93 |
92 } // namespace chromeos | 94 } // namespace chromeos |
OLD | NEW |