Index: ash/magnifier/partial_magnification_controller.cc |
diff --git a/ash/magnifier/partial_magnification_controller.cc b/ash/magnifier/partial_magnification_controller.cc |
index 5b51928eb434836f45a8fe10a500f85ce0b54272..e61734dd59496964c04c2e16572ce7869ac887ff 100644 |
--- a/ash/magnifier/partial_magnification_controller.cc |
+++ b/ash/magnifier/partial_magnification_controller.cc |
@@ -27,6 +27,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 in DIP. |
James Cook
2016/09/14 03:04:58
nit: magnifying
sammiequon
2016/09/14 18:02:22
Done.
|
+const int kBorderOutlineThickness = 2; |
+const SkColor kBorderColor = SK_ColorWHITE; |
James Cook
2016/09/14 03:04:59
nit: document what this looks like (is it black /
sammiequon
2016/09/14 18:02:22
Done.
|
+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 |
@@ -88,7 +92,7 @@ class PartialMagnificationController::ContentMask : public ui::LayerDelegate { |
ui::Layer* layer() { return &layer_; } |
private: |
- // Overridden from LayerDelegate. |
+ // ui::LayerDelegate. |
void OnPaintLayer(const ui::PaintContext& context) override { |
ui::PaintRecorder recorder(context, layer()->size()); |
@@ -119,6 +123,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 |
James Cook
2016/09/14 03:04:58
nit: render -> renderer
sammiequon
2016/09/14 18:02:23
Done.
|
+// inner radius to increase visibility. |
+class PartialMagnificationController::BorderRenderer |
James Cook
2016/09/14 03:04:59
I like how you put this in an inner class.
sammiequon
2016/09/14 18:02:22
:)
|
+ : public ui::LayerDelegate { |
+ public: |
+ explicit BorderRenderer(const gfx::Rect& bounds) : bounds_(bounds) {} |
+ |
+ ~BorderRenderer() override {} |
+ |
+ private: |
+ // ui::LayerDelegate. |
James Cook
2016/09/14 03:04:59
super nit: We usually end with a colon, like "ui::
sammiequon
2016/09/14 18:02:23
Done.
|
+ void OnPaintLayer(const ui::PaintContext& context) override { |
+ ui::PaintRecorder recorder(context, bounds_.size()); |
+ |
+ SkPaint paint; |
+ paint.setAntiAlias(true); |
+ paint.setStyle(SkPaint::kStroke_Style); |
+ |
+ // Draw the inner border. |
+ paint.setStrokeWidth(kBorderSize); |
+ paint.setColor(kBorderColor); |
+ recorder.canvas()->DrawCircle(bounds_.CenterPoint(), |
+ bounds_.width() / 2 - kBorderSize / 2, paint); |
James Cook
2016/09/14 03:04:59
optional: I wonder if caching "const int radius =
sammiequon
2016/09/14 18:02:23
Done.
|
+ |
+ // Draw border outer outline and then draw the border inner outline. |
+ paint.setStrokeWidth(kBorderOutlineThickness); |
+ paint.setColor(kBorderOutlineColor); |
+ recorder.canvas()->DrawCircle( |
+ bounds_.CenterPoint(), |
+ bounds_.width() / 2 - kBorderOutlineThickness / 2, paint); |
+ 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_; |
James Cook
2016/09/14 03:04:59
document: bounds of what? or rename to something l
sammiequon
2016/09/14 18:02:23
Done.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(BorderRenderer); |
+}; |
+ |
PartialMagnificationController::PartialMagnificationController() { |
Shell::GetInstance()->AddPreTargetHandler(this); |
} |
@@ -262,9 +314,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())); |