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

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

Issue 1066113002: chromeos: Use a PaintRecorder to access the Canvas for painting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/accessibility_focus_ring_layer.h" 5 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/compositor/layer.h" 11 #include "ui/compositor/layer.h"
12 #include "ui/compositor/paint_context.h" 12 #include "ui/compositor/paint_recorder.h"
13 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/canvas.h"
14 14
15 namespace chromeos { 15 namespace chromeos {
16 16
17 namespace { 17 namespace {
18 18
19 // The number of pixels in the color gradient that fades to transparent. 19 // The number of pixels in the color gradient that fades to transparent.
20 const int kGradientWidth = 6; 20 const int kGradientWidth = 6;
21 21
22 // The color of the focus ring. In the future this might be a parameter. 22 // The color of the focus ring. In the future this might be a parameter.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 aura::Window* root_window = ash::Shell::GetInstance()->display_controller() 105 aura::Window* root_window = ash::Shell::GetInstance()->display_controller()
106 ->GetRootWindowForDisplayId(display.id()); 106 ->GetRootWindowForDisplayId(display.id());
107 CreateOrUpdateLayer(root_window, "AccessibilityFocusRing"); 107 CreateOrUpdateLayer(root_window, "AccessibilityFocusRing");
108 108
109 // Update the layer bounds. 109 // Update the layer bounds.
110 layer()->SetBounds(bounds); 110 layer()->SetBounds(bounds);
111 } 111 }
112 112
113 void AccessibilityFocusRingLayer::OnPaintLayer( 113 void AccessibilityFocusRingLayer::OnPaintLayer(
114 const ui::PaintContext& context) { 114 const ui::PaintContext& context) {
115 gfx::Vector2d offset = layer()->bounds().OffsetFromOrigin(); 115 ui::PaintRecorder recorder(context);
116 116
117 SkPaint paint; 117 SkPaint paint;
118 paint.setFlags(SkPaint::kAntiAlias_Flag); 118 paint.setFlags(SkPaint::kAntiAlias_Flag);
119 paint.setStyle(SkPaint::kStroke_Style); 119 paint.setStyle(SkPaint::kStroke_Style);
120 paint.setStrokeWidth(2); 120 paint.setStrokeWidth(2);
121 121
122 gfx::Canvas* canvas = context.canvas();
123
124 SkPath path; 122 SkPath path;
123 gfx::Vector2d offset = layer()->bounds().OffsetFromOrigin();
125 const int w = kGradientWidth; 124 const int w = kGradientWidth;
126 for (int i = 0; i < w; ++i) { 125 for (int i = 0; i < w; ++i) {
127 paint.setColor( 126 paint.setColor(
128 SkColorSetARGBMacro( 127 SkColorSetARGBMacro(
129 255 * (w - i) * (w - i) / (w * w), 128 255 * (w - i) * (w - i) / (w * w),
130 kFocusRingColorRed, kFocusRingColorGreen, kFocusRingColorBlue)); 129 kFocusRingColorRed, kFocusRingColorGreen, kFocusRingColorBlue));
131 path = MakePath(ring_, i, offset); 130 path = MakePath(ring_, i, offset);
132 canvas->DrawPath(path, paint); 131 recorder.canvas()->DrawPath(path, paint);
133 } 132 }
134 } 133 }
135 134
136 } // namespace chromeos 135 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/display/overscan_calibrator.cc ('k') | chrome/browser/chromeos/ui/focus_ring_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698