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