| OLD | NEW |
| 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 "ash/utility/partial_screenshot_controller.h" | 5 #include "ash/utility/partial_screenshot_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "ash/screenshot_delegate.h" | 9 #include "ash/screenshot_delegate.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/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "ui/compositor/paint_context.h" | 13 #include "ui/compositor/paint_context.h" |
| 14 #include "ui/compositor/paint_recorder.h" |
| 14 #include "ui/events/event_handler.h" | 15 #include "ui/events/event_handler.h" |
| 15 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 16 #include "ui/wm/core/cursor_manager.h" | 17 #include "ui/wm/core/cursor_manager.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // The size to increase the invalidated area in the layer to repaint. The area | 23 // The size to increase the invalidated area in the layer to repaint. The area |
| 23 // should be slightly bigger than the actual region because the region indicator | 24 // should be slightly bigger than the actual region because the region indicator |
| (...skipping 30 matching lines...) Expand all Loading... |
| 54 region_ = region; | 55 region_ = region; |
| 55 layer()->SchedulePaint(union_rect); | 56 layer()->SchedulePaint(union_rect); |
| 56 } | 57 } |
| 57 | 58 |
| 58 private: | 59 private: |
| 59 // ui::LayerDelegate: | 60 // ui::LayerDelegate: |
| 60 void OnPaintLayer(const ui::PaintContext& context) override { | 61 void OnPaintLayer(const ui::PaintContext& context) override { |
| 61 if (region_.IsEmpty()) | 62 if (region_.IsEmpty()) |
| 62 return; | 63 return; |
| 63 | 64 |
| 64 gfx::Canvas* canvas = context.canvas(); | |
| 65 // Screenshot area representation: black rectangle with white | 65 // Screenshot area representation: black rectangle with white |
| 66 // rectangle inside. To avoid capturing these rectangles when mouse | 66 // rectangle inside. To avoid capturing these rectangles when mouse |
| 67 // release, they should be outside of the actual capturing area. | 67 // release, they should be outside of the actual capturing area. |
| 68 ui::PaintRecorder recorder(context); |
| 68 gfx::Rect rect(region_); | 69 gfx::Rect rect(region_); |
| 69 rect.Inset(-1, -1); | 70 rect.Inset(-1, -1); |
| 70 canvas->DrawRect(rect, SK_ColorWHITE); | 71 recorder.canvas()->DrawRect(rect, SK_ColorWHITE); |
| 71 rect.Inset(-1, -1); | 72 rect.Inset(-1, -1); |
| 72 canvas->DrawRect(rect, SK_ColorBLACK); | 73 recorder.canvas()->DrawRect(rect, SK_ColorBLACK); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} | 76 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} |
| 76 | 77 |
| 77 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} | 78 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
| 78 | 79 |
| 79 base::Closure PrepareForLayerBoundsChange() override { | 80 base::Closure PrepareForLayerBoundsChange() override { |
| 80 return base::Closure(); | 81 return base::Closure(); |
| 81 } | 82 } |
| 82 | 83 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 return; | 257 return; |
| 257 Cancel(); | 258 Cancel(); |
| 258 } | 259 } |
| 259 | 260 |
| 260 void PartialScreenshotController::OnDisplayMetricsChanged( | 261 void PartialScreenshotController::OnDisplayMetricsChanged( |
| 261 const gfx::Display& display, | 262 const gfx::Display& display, |
| 262 uint32_t changed_metrics) { | 263 uint32_t changed_metrics) { |
| 263 } | 264 } |
| 264 | 265 |
| 265 } // namespace ash | 266 } // namespace ash |
| OLD | NEW |