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

Side by Side Diff: chrome/browser/chromeos/display/overscan_calibrator.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
« no previous file with comments | « no previous file | chrome/browser/chromeos/ui/accessibility_focus_ring_layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/display/overscan_calibrator.h" 5 #include "chrome/browser/chromeos/display/overscan_calibrator.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/display_info.h" 8 #include "ash/display/display_info.h"
9 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 #include "ui/compositor/layer.h" 14 #include "ui/compositor/layer.h"
15 #include "ui/compositor/paint_context.h" 15 #include "ui/compositor/paint_recorder.h"
16 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 namespace { 19 namespace {
20 20
21 // The opacity for the arrows of the overscan calibration. 21 // The opacity for the arrows of the overscan calibration.
22 const float kArrowOpacity = 0.8; 22 const float kArrowOpacity = 0.8;
23 23
24 // The height in pixel for the arrows to show the overscan calibration. 24 // The height in pixel for the arrows to show the overscan calibration.
25 const int kCalibrationArrowHeight = 50; 25 const int kCalibrationArrowHeight = 50;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 void OverscanCalibrator::UpdateInsets(const gfx::Insets& insets) { 111 void OverscanCalibrator::UpdateInsets(const gfx::Insets& insets) {
112 insets_.Set(std::max(insets.top(), 0), 112 insets_.Set(std::max(insets.top(), 0),
113 std::max(insets.left(), 0), 113 std::max(insets.left(), 0),
114 std::max(insets.bottom(), 0), 114 std::max(insets.bottom(), 0),
115 std::max(insets.right(), 0)); 115 std::max(insets.right(), 0));
116 calibration_layer_->SchedulePaint(calibration_layer_->bounds()); 116 calibration_layer_->SchedulePaint(calibration_layer_->bounds());
117 } 117 }
118 118
119 void OverscanCalibrator::OnPaintLayer(const ui::PaintContext& context) { 119 void OverscanCalibrator::OnPaintLayer(const ui::PaintContext& context) {
120 gfx::Canvas* canvas = context.canvas(); 120 ui::PaintRecorder recorder(context);
121 static const SkColor kTransparent = SkColorSetARGB(0, 0, 0, 0); 121 static const SkColor kTransparent = SkColorSetARGB(0, 0, 0, 0);
122 gfx::Rect full_bounds = calibration_layer_->bounds(); 122 gfx::Rect full_bounds = calibration_layer_->bounds();
123 gfx::Rect inner_bounds = full_bounds; 123 gfx::Rect inner_bounds = full_bounds;
124 inner_bounds.Inset(insets_); 124 inner_bounds.Inset(insets_);
125 canvas->FillRect(full_bounds, SK_ColorBLACK); 125 recorder.canvas()->FillRect(full_bounds, SK_ColorBLACK);
126 canvas->FillRect(inner_bounds, kTransparent, SkXfermode::kClear_Mode); 126 recorder.canvas()->FillRect(inner_bounds, kTransparent,
127 SkXfermode::kClear_Mode);
127 128
128 gfx::Point center = inner_bounds.CenterPoint(); 129 gfx::Point center = inner_bounds.CenterPoint();
129 int vertical_offset = inner_bounds.height() / 2 - kArrowGapWidth; 130 int vertical_offset = inner_bounds.height() / 2 - kArrowGapWidth;
130 int horizontal_offset = inner_bounds.width() / 2 - kArrowGapWidth; 131 int horizontal_offset = inner_bounds.width() / 2 - kArrowGapWidth;
131 132
133 gfx::Canvas* canvas = recorder.canvas();
132 DrawTriangle(center.x(), center.y() + vertical_offset, 0, canvas); 134 DrawTriangle(center.x(), center.y() + vertical_offset, 0, canvas);
133 DrawTriangle(center.x(), center.y() - vertical_offset, 180, canvas); 135 DrawTriangle(center.x(), center.y() - vertical_offset, 180, canvas);
134 DrawTriangle(center.x() - horizontal_offset, center.y(), 90, canvas); 136 DrawTriangle(center.x() - horizontal_offset, center.y(), 90, canvas);
135 DrawTriangle(center.x() + horizontal_offset, center.y(), -90, canvas); 137 DrawTriangle(center.x() + horizontal_offset, center.y(), -90, canvas);
136 } 138 }
137 139
138 void OverscanCalibrator::OnDelegatedFrameDamage( 140 void OverscanCalibrator::OnDelegatedFrameDamage(
139 const gfx::Rect& damage_rect_in_dip) { 141 const gfx::Rect& damage_rect_in_dip) {
140 } 142 }
141 143
142 void OverscanCalibrator::OnDeviceScaleFactorChanged( 144 void OverscanCalibrator::OnDeviceScaleFactorChanged(
143 float device_scale_factor) { 145 float device_scale_factor) {
144 // TODO(mukai): Cancel the overscan calibration when the device 146 // TODO(mukai): Cancel the overscan calibration when the device
145 // configuration has changed. 147 // configuration has changed.
146 } 148 }
147 149
148 base::Closure OverscanCalibrator::PrepareForLayerBoundsChange() { 150 base::Closure OverscanCalibrator::PrepareForLayerBoundsChange() {
149 return base::Closure(); 151 return base::Closure();
150 } 152 }
151 153
152 } // namespace chromeos 154 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/ui/accessibility_focus_ring_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698