OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/magnifier/partial_magnification_controller.h" | 5 #include "ash/magnifier/partial_magnification_controller.h" |
6 | 6 |
7 #include "ash/common/system/chromeos/palette/palette_utils.h" | 7 #include "ash/common/system/chromeos/palette/palette_utils.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "third_party/skia/include/core/SkDrawLooper.h" | 9 #include "third_party/skia/include/core/SkDrawLooper.h" |
10 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 ~ContentMask() override { layer_.set_delegate(nullptr); } | 98 ~ContentMask() override { layer_.set_delegate(nullptr); } |
99 | 99 |
100 ui::Layer* layer() { return &layer_; } | 100 ui::Layer* layer() { return &layer_; } |
101 | 101 |
102 private: | 102 private: |
103 // ui::LayerDelegate: | 103 // ui::LayerDelegate: |
104 void OnPaintLayer(const ui::PaintContext& context) override { | 104 void OnPaintLayer(const ui::PaintContext& context) override { |
105 ui::PaintRecorder recorder(context, layer()->size()); | 105 ui::PaintRecorder recorder(context, layer()->size()); |
106 | 106 |
107 SkPaint paint; | 107 cc::PaintFlags paint; |
108 paint.setAlpha(255); | 108 paint.setAlpha(255); |
109 paint.setAntiAlias(true); | 109 paint.setAntiAlias(true); |
110 // Stroke is used for clipping the border which consists of the rendered | 110 // Stroke is used for clipping the border which consists of the rendered |
111 // border |kBorderSize| and the magnifier shadow |kShadowThickness| and | 111 // border |kBorderSize| and the magnifier shadow |kShadowThickness| and |
112 // |kShadowOffset|. | 112 // |kShadowOffset|. |
113 paint.setStrokeWidth(kBorderSize + kShadowThickness + kShadowOffset); | 113 paint.setStrokeWidth(kBorderSize + kShadowThickness + kShadowOffset); |
114 paint.setStyle(is_border_ ? SkPaint::kStroke_Style : SkPaint::kFill_Style); | 114 paint.setStyle(is_border_ ? cc::PaintFlags::kStroke_Style |
| 115 : cc::PaintFlags::kFill_Style); |
115 | 116 |
116 // If we want to clip the magnifier zone use the magnifiers radius. | 117 // If we want to clip the magnifier zone use the magnifiers radius. |
117 // Otherwise we want to clip the border, shadow and shadow offset so we | 118 // Otherwise we want to clip the border, shadow and shadow offset so we |
118 // start | 119 // start |
119 // at the halfway point of the stroke width. | 120 // at the halfway point of the stroke width. |
120 gfx::Rect rect(layer()->bounds().size()); | 121 gfx::Rect rect(layer()->bounds().size()); |
121 int clipping_radius = kMagnifierRadius; | 122 int clipping_radius = kMagnifierRadius; |
122 if (is_border_) | 123 if (is_border_) |
123 clipping_radius += (kShadowThickness + kShadowOffset + kBorderSize) / 2; | 124 clipping_radius += (kShadowThickness + kShadowOffset + kBorderSize) / 2; |
124 recorder.canvas()->DrawCircle(rect.CenterPoint(), clipping_radius, paint); | 125 recorder.canvas()->DrawCircle(rect.CenterPoint(), clipping_radius, paint); |
(...skipping 25 matching lines...) Expand all Loading... |
150 } | 151 } |
151 | 152 |
152 ~BorderRenderer() override {} | 153 ~BorderRenderer() override {} |
153 | 154 |
154 private: | 155 private: |
155 // ui::LayerDelegate: | 156 // ui::LayerDelegate: |
156 void OnPaintLayer(const ui::PaintContext& context) override { | 157 void OnPaintLayer(const ui::PaintContext& context) override { |
157 ui::PaintRecorder recorder(context, magnifier_window_bounds_.size()); | 158 ui::PaintRecorder recorder(context, magnifier_window_bounds_.size()); |
158 | 159 |
159 // Draw the shadow. | 160 // Draw the shadow. |
160 SkPaint shadow_paint; | 161 cc::PaintFlags shadow_paint; |
161 shadow_paint.setAntiAlias(true); | 162 shadow_paint.setAntiAlias(true); |
162 shadow_paint.setColor(SK_ColorTRANSPARENT); | 163 shadow_paint.setColor(SK_ColorTRANSPARENT); |
163 shadow_paint.setLooper( | 164 shadow_paint.setLooper( |
164 gfx::CreateShadowDrawLooperCorrectBlur(magnifier_shadows_)); | 165 gfx::CreateShadowDrawLooperCorrectBlur(magnifier_shadows_)); |
165 gfx::Rect shadow_bounds(magnifier_window_bounds_.size()); | 166 gfx::Rect shadow_bounds(magnifier_window_bounds_.size()); |
166 recorder.canvas()->DrawCircle( | 167 recorder.canvas()->DrawCircle( |
167 shadow_bounds.CenterPoint(), | 168 shadow_bounds.CenterPoint(), |
168 shadow_bounds.width() / 2 - kShadowThickness - kShadowOffset, | 169 shadow_bounds.width() / 2 - kShadowThickness - kShadowOffset, |
169 shadow_paint); | 170 shadow_paint); |
170 | 171 |
171 SkPaint border_paint; | 172 cc::PaintFlags border_paint; |
172 border_paint.setAntiAlias(true); | 173 border_paint.setAntiAlias(true); |
173 border_paint.setStyle(SkPaint::kStroke_Style); | 174 border_paint.setStyle(cc::PaintFlags::kStroke_Style); |
174 | 175 |
175 // The radius of the magnifier and its border. | 176 // The radius of the magnifier and its border. |
176 const int magnifier_radius = kMagnifierRadius + kBorderSize; | 177 const int magnifier_radius = kMagnifierRadius + kBorderSize; |
177 | 178 |
178 // Draw the inner border. | 179 // Draw the inner border. |
179 border_paint.setStrokeWidth(kBorderSize); | 180 border_paint.setStrokeWidth(kBorderSize); |
180 border_paint.setColor(kBorderColor); | 181 border_paint.setColor(kBorderColor); |
181 recorder.canvas()->DrawCircle(magnifier_window_bounds_.CenterPoint(), | 182 recorder.canvas()->DrawCircle(magnifier_window_bounds_.CenterPoint(), |
182 magnifier_radius - kBorderSize / 2, | 183 magnifier_radius - kBorderSize / 2, |
183 border_paint); | 184 border_paint); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 372 |
372 void PartialMagnificationController::RemoveZoomWidgetObservers() { | 373 void PartialMagnificationController::RemoveZoomWidgetObservers() { |
373 DCHECK(host_widget_); | 374 DCHECK(host_widget_); |
374 host_widget_->RemoveObserver(this); | 375 host_widget_->RemoveObserver(this); |
375 aura::Window* root_window = host_widget_->GetNativeView()->GetRootWindow(); | 376 aura::Window* root_window = host_widget_->GetNativeView()->GetRootWindow(); |
376 DCHECK(root_window); | 377 DCHECK(root_window); |
377 root_window->RemoveObserver(this); | 378 root_window->RemoveObserver(this); |
378 } | 379 } |
379 | 380 |
380 } // namespace ash | 381 } // namespace ash |
OLD | NEW |