| 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/events/event_handler.h" | 14 #include "ui/events/event_handler.h" |
| 14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 15 #include "ui/wm/core/cursor_manager.h" | 16 #include "ui/wm/core/cursor_manager.h" |
| 16 | 17 |
| 17 namespace ash { | 18 namespace ash { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // The size to increase the invalidated area in the layer to repaint. The area | 22 // The size to increase the invalidated area in the layer to repaint. The area |
| 22 // should be slightly bigger than the actual region because the region indicator | 23 // should be slightly bigger than the actual region because the region indicator |
| (...skipping 26 matching lines...) Expand all Loading... |
| 49 union_rect.Inset(-kInvalidateRegionAdditionalSize, | 50 union_rect.Inset(-kInvalidateRegionAdditionalSize, |
| 50 -kInvalidateRegionAdditionalSize); | 51 -kInvalidateRegionAdditionalSize); |
| 51 union_rect.Intersects(layer()->bounds()); | 52 union_rect.Intersects(layer()->bounds()); |
| 52 | 53 |
| 53 region_ = region; | 54 region_ = region; |
| 54 layer()->SchedulePaint(union_rect); | 55 layer()->SchedulePaint(union_rect); |
| 55 } | 56 } |
| 56 | 57 |
| 57 private: | 58 private: |
| 58 // ui::LayerDelegate: | 59 // ui::LayerDelegate: |
| 59 void OnPaintLayer(gfx::Canvas* canvas) override { | 60 void OnPaintLayer(const ui::PaintContext& context) override { |
| 60 if (region_.IsEmpty()) | 61 if (region_.IsEmpty()) |
| 61 return; | 62 return; |
| 62 | 63 |
| 64 gfx::Canvas* canvas = context.canvas(); |
| 63 // Screenshot area representation: black rectangle with white | 65 // Screenshot area representation: black rectangle with white |
| 64 // rectangle inside. To avoid capturing these rectangles when mouse | 66 // rectangle inside. To avoid capturing these rectangles when mouse |
| 65 // release, they should be outside of the actual capturing area. | 67 // release, they should be outside of the actual capturing area. |
| 66 gfx::Rect rect(region_); | 68 gfx::Rect rect(region_); |
| 67 rect.Inset(-1, -1); | 69 rect.Inset(-1, -1); |
| 68 canvas->DrawRect(rect, SK_ColorWHITE); | 70 canvas->DrawRect(rect, SK_ColorWHITE); |
| 69 rect.Inset(-1, -1); | 71 rect.Inset(-1, -1); |
| 70 canvas->DrawRect(rect, SK_ColorBLACK); | 72 canvas->DrawRect(rect, SK_ColorBLACK); |
| 71 } | 73 } |
| 72 | 74 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 return; | 256 return; |
| 255 Cancel(); | 257 Cancel(); |
| 256 } | 258 } |
| 257 | 259 |
| 258 void PartialScreenshotController::OnDisplayMetricsChanged( | 260 void PartialScreenshotController::OnDisplayMetricsChanged( |
| 259 const gfx::Display& display, | 261 const gfx::Display& display, |
| 260 uint32_t changed_metrics) { | 262 uint32_t changed_metrics) { |
| 261 } | 263 } |
| 262 | 264 |
| 263 } // namespace ash | 265 } // namespace ash |
| OLD | NEW |