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

Side by Side Diff: chrome/browser/chromeos/ui/focus_ring_layer.cc

Issue 1057873004: Pass a ui::PaintContext from ui::Layer to layer delegates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: layer-paintcontext: mac Created 5 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/ui/focus_ring_layer.h" 5 #include "chrome/browser/chromeos/ui/focus_ring_layer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
9 #include "ui/compositor/layer.h" 9 #include "ui/compositor/layer.h"
10 #include "ui/compositor/paint_context.h"
10 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
11 12
12 namespace chromeos { 13 namespace chromeos {
13 14
14 namespace { 15 namespace {
15 16
16 const int kShadowRadius = 10; 17 const int kShadowRadius = 10;
17 const int kShadowAlpha = 90; 18 const int kShadowAlpha = 90;
18 const SkColor kShadowColor = SkColorSetRGB(77, 144, 254); 19 const SkColor kShadowColor = SkColorSetRGB(77, 144, 254);
19 20
(...skipping 29 matching lines...) Expand all
49 layer_->set_delegate(this); 50 layer_->set_delegate(this);
50 layer_->SetFillsBoundsOpaquely(false); 51 layer_->SetFillsBoundsOpaquely(false);
51 root_layer->Add(layer_.get()); 52 root_layer->Add(layer_.get());
52 } 53 }
53 54
54 // Keep moving it to the top in case new layers have been added 55 // Keep moving it to the top in case new layers have been added
55 // since we created this layer. 56 // since we created this layer.
56 layer_->parent()->StackAtTop(layer_.get()); 57 layer_->parent()->StackAtTop(layer_.get());
57 } 58 }
58 59
59 void FocusRingLayer::OnPaintLayer(gfx::Canvas* canvas) { 60 void FocusRingLayer::OnPaintLayer(const ui::PaintContext& context) {
60 if (!root_window_ || focus_ring_.IsEmpty()) 61 if (!root_window_ || focus_ring_.IsEmpty())
61 return; 62 return;
62 63
64 gfx::Canvas* canvas = context.canvas();
63 gfx::Rect bounds = focus_ring_ - layer_->bounds().OffsetFromOrigin(); 65 gfx::Rect bounds = focus_ring_ - layer_->bounds().OffsetFromOrigin();
64 SkPaint paint; 66 SkPaint paint;
65 paint.setColor(kShadowColor); 67 paint.setColor(kShadowColor);
66 paint.setFlags(SkPaint::kAntiAlias_Flag); 68 paint.setFlags(SkPaint::kAntiAlias_Flag);
67 paint.setStyle(SkPaint::kStroke_Style); 69 paint.setStyle(SkPaint::kStroke_Style);
68 paint.setStrokeWidth(2); 70 paint.setStrokeWidth(2);
69 int r = kShadowRadius; 71 int r = kShadowRadius;
70 for (int i = 0; i < r; i++) { 72 for (int i = 0; i < r; i++) {
71 // Fade out alpha quadratically. 73 // Fade out alpha quadratically.
72 paint.setAlpha((kShadowAlpha * (r - i) * (r - i)) / (r * r)); 74 paint.setAlpha((kShadowAlpha * (r - i) * (r - i)) / (r * r));
(...skipping 10 matching lines...) Expand all
83 void FocusRingLayer::OnDeviceScaleFactorChanged(float device_scale_factor) { 85 void FocusRingLayer::OnDeviceScaleFactorChanged(float device_scale_factor) {
84 if (delegate_) 86 if (delegate_)
85 delegate_->OnDeviceScaleFactorChanged(); 87 delegate_->OnDeviceScaleFactorChanged();
86 } 88 }
87 89
88 base::Closure FocusRingLayer::PrepareForLayerBoundsChange() { 90 base::Closure FocusRingLayer::PrepareForLayerBoundsChange() {
89 return base::Bind(&base::DoNothing); 91 return base::Bind(&base::DoNothing);
90 } 92 }
91 93
92 } // namespace chromeos 94 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/ui/focus_ring_layer.h ('k') | content/browser/renderer_host/render_widget_host_view_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698