Chromium Code Reviews| Index: ash/magnifier/partial_magnification_controller.cc |
| diff --git a/ash/magnifier/partial_magnification_controller.cc b/ash/magnifier/partial_magnification_controller.cc |
| index 3dcdd38448fdee2f915ab2b7949c43dbda4e68ff..30395871d160e74aa9efa54cf92653a96c5a0caf 100644 |
| --- a/ash/magnifier/partial_magnification_controller.cc |
| +++ b/ash/magnifier/partial_magnification_controller.cc |
| @@ -23,6 +23,10 @@ const float kMagnificationScale = 2.f; |
| const int kMagnifierRadius = 200; |
| // Size of the border around the magnifying glass in DIP. |
| const int kBorderSize = 10; |
| +// Thickness of the outline around magnifiying glass border. |
| +const int kBorderOutlineThickness = 2; |
| +const SkColor kBorderColor = SK_ColorWHITE; |
| +const SkColor kBorderOutlineColor = SK_ColorBLACK; |
| // Inset on the zoom filter. |
| const int kZoomInset = 0; |
| // Vertical offset between the center of the magnifier and the tip of the |
| @@ -105,6 +109,54 @@ class PartialMagnificationController::ContentMask : public ui::LayerDelegate { |
| DISALLOW_COPY_AND_ASSIGN(ContentMask); |
| }; |
| +// The border render draws the border as well as outline on both the outer and |
| +// inner radius to increase visibility. |
| +class PartialMagnificationController::BorderRenderer |
| + : public ui::LayerDelegate { |
| + public: |
| + BorderRenderer(const gfx::Rect& bounds) { bounds_ = bounds; } |
|
jdufault
2016/08/25 19:53:25
use ctor list
: bounds_(bounds)
sammiequon
2016/08/26 22:29:16
Done.
|
| + |
| + ~BorderRenderer() override {} |
| + |
| + private: |
| + // Overridden from LayerDelegate. |
|
jdufault
2016/08/25 19:53:25
// ui::LayerDelegate:
sammiequon
2016/08/26 22:29:16
Done.
|
| + void OnPaintLayer(const ui::PaintContext& context) override { |
| + ui::PaintRecorder recorder(context, bounds_.size()); |
| + |
| + // Draw the border. |
| + SkPaint paint; |
| + paint.setAntiAlias(true); |
| + paint.setStrokeWidth(kBorderSize); |
| + paint.setStyle(SkPaint::kStroke_Style); |
| + paint.setColor(kBorderColor); |
| + recorder.canvas()->DrawCircle(bounds_.CenterPoint(), |
| + bounds_.width() / 2 - kBorderSize / 2, paint); |
| + |
| + // Draw the border outlines. |
|
jdufault
2016/08/25 19:53:25
Remove comment?
sammiequon
2016/08/26 22:29:16
Done.
|
| + paint.setStrokeWidth(kBorderOutlineThickness); |
| + paint.setColor(kBorderOutlineColor); |
| + // Draw border outer outline. |
| + recorder.canvas()->DrawCircle( |
| + bounds_.CenterPoint(), |
| + bounds_.width() / 2 - kBorderOutlineThickness / 2, paint); |
| + // Draw border inner outline. |
| + recorder.canvas()->DrawCircle( |
| + bounds_.CenterPoint(), |
| + bounds_.width() / 2 - kBorderSize + kBorderOutlineThickness / 2, paint); |
| + } |
| + |
| + void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} |
| + |
| + void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
| + |
| + base::Closure PrepareForLayerBoundsChange() override { |
| + return base::Closure(); |
| + } |
| + gfx::Rect bounds_; |
|
jdufault
2016/08/25 19:53:25
newline above here
sammiequon
2016/08/26 22:29:16
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(BorderRenderer); |
| +}; |
| + |
| PartialMagnificationController::PartialMagnificationController() { |
| Shell::GetInstance()->AddPreTargetHandler(this); |
| } |
| @@ -243,9 +295,9 @@ void PartialMagnificationController::CreateMagnifierWindow( |
| zoom_layer_->SetBackgroundZoom(kMagnificationScale, kZoomInset); |
| root_layer->Add(zoom_layer_.get()); |
| - border_layer_.reset(new ui::Layer(ui::LayerType::LAYER_SOLID_COLOR)); |
| + border_layer_.reset(new ui::Layer(ui::LayerType::LAYER_TEXTURED)); |
| border_layer_->SetBounds(gfx::Rect(GetWindowSize())); |
| - border_layer_->SetColor(SK_ColorWHITE); |
| + border_layer_->set_delegate(new BorderRenderer(gfx::Rect(GetWindowSize()))); |
| root_layer->Add(border_layer_.get()); |
| border_mask_.reset(new ContentMask(true, GetWindowSize())); |