Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2850)

Unified Diff: ash/magnifier/partial_magnification_controller.cc

Issue 2269383002: Magnifier border is now more visible on light backgrounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixed patch set 6 errors. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/magnifier/partial_magnification_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b28485fa2639615453b6c0766aa5feff5e4d75e8 100644
--- a/ash/magnifier/partial_magnification_controller.cc
+++ b/ash/magnifier/partial_magnification_controller.cc
@@ -27,6 +27,12 @@ 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 magnifying glass border in DIP.
+const int kBorderOutlineThickness = 2;
+// The color of the border an its outlines. The border has an outline on both
James Cook 2016/09/14 20:54:00 nit: an -> and
sammiequon 2016/09/14 21:53:51 Done.
+// sides, producing a black/white/black ring.
+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
@@ -88,7 +94,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 +125,56 @@ class PartialMagnificationController::ContentMask : public ui::LayerDelegate {
DISALLOW_COPY_AND_ASSIGN(ContentMask);
};
+// The border renderer draws the border as well as outline on both the outer and
+// inner radius to increase visibility.
+class PartialMagnificationController::BorderRenderer
+ : public ui::LayerDelegate {
+ public:
+ explicit BorderRenderer(const gfx::Rect& bounds)
James Cook 2016/09/14 20:54:00 nit: |bounds| -> |magnifier_bounds|
sammiequon 2016/09/14 21:53:51 Done.
+ : magnifier_bounds_(bounds) {}
+
+ ~BorderRenderer() override {}
+
+ private:
+ // ui::LayerDelegate:
+ void OnPaintLayer(const ui::PaintContext& context) override {
+ ui::PaintRecorder recorder(context, magnifier_bounds_.size());
+
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+
+ const int magnifier_radius = magnifier_bounds_.width() / 2;
+ // Draw the inner border.
+ paint.setStrokeWidth(kBorderSize);
+ paint.setColor(kBorderColor);
+ recorder.canvas()->DrawCircle(magnifier_bounds_.CenterPoint(),
+ magnifier_radius - kBorderSize / 2, paint);
+
+ // Draw border outer outline and then draw the border inner outline.
+ paint.setStrokeWidth(kBorderOutlineThickness);
+ paint.setColor(kBorderOutlineColor);
+ recorder.canvas()->DrawCircle(
+ magnifier_bounds_.CenterPoint(),
+ magnifier_radius - kBorderOutlineThickness / 2, paint);
+ recorder.canvas()->DrawCircle(
+ magnifier_bounds_.CenterPoint(),
+ magnifier_radius - 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 magnifier_bounds_;
+
+ DISALLOW_COPY_AND_ASSIGN(BorderRenderer);
+};
+
PartialMagnificationController::PartialMagnificationController() {
Shell::GetInstance()->AddPreTargetHandler(this);
}
@@ -262,9 +318,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()));
« no previous file with comments | « ash/magnifier/partial_magnification_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698