| OLD | NEW |
| 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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/aura/client/window_stacking_client.h" | 23 #include "ui/aura/client/window_stacking_client.h" |
| 24 #include "ui/aura/env.h" | 24 #include "ui/aura/env.h" |
| 25 #include "ui/aura/layout_manager.h" | 25 #include "ui/aura/layout_manager.h" |
| 26 #include "ui/aura/window_delegate.h" | 26 #include "ui/aura/window_delegate.h" |
| 27 #include "ui/aura/window_event_dispatcher.h" | 27 #include "ui/aura/window_event_dispatcher.h" |
| 28 #include "ui/aura/window_observer.h" | 28 #include "ui/aura/window_observer.h" |
| 29 #include "ui/aura/window_tracker.h" | 29 #include "ui/aura/window_tracker.h" |
| 30 #include "ui/aura/window_tree_host.h" | 30 #include "ui/aura/window_tree_host.h" |
| 31 #include "ui/compositor/compositor.h" | 31 #include "ui/compositor/compositor.h" |
| 32 #include "ui/compositor/layer.h" | 32 #include "ui/compositor/layer.h" |
| 33 #include "ui/compositor/paint_context.h" |
| 33 #include "ui/events/event_target_iterator.h" | 34 #include "ui/events/event_target_iterator.h" |
| 34 #include "ui/gfx/canvas.h" | 35 #include "ui/gfx/canvas.h" |
| 35 #include "ui/gfx/path.h" | 36 #include "ui/gfx/path.h" |
| 36 #include "ui/gfx/scoped_canvas.h" | 37 #include "ui/gfx/scoped_canvas.h" |
| 37 #include "ui/gfx/screen.h" | 38 #include "ui/gfx/screen.h" |
| 38 | 39 |
| 39 namespace aura { | 40 namespace aura { |
| 40 | 41 |
| 41 namespace { | 42 namespace { |
| 42 | 43 |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 if (delegate_) | 953 if (delegate_) |
| 953 delegate_->OnWindowTargetVisibilityChanged(visible); | 954 delegate_->OnWindowTargetVisibilityChanged(visible); |
| 954 | 955 |
| 955 NotifyWindowVisibilityChanged(this, visible); | 956 NotifyWindowVisibilityChanged(this, visible); |
| 956 } | 957 } |
| 957 | 958 |
| 958 void Window::SchedulePaint() { | 959 void Window::SchedulePaint() { |
| 959 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); | 960 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); |
| 960 } | 961 } |
| 961 | 962 |
| 962 void Window::Paint(gfx::Canvas* canvas) { | 963 void Window::Paint(const ui::PaintContext& context) { |
| 963 if (delegate_) | 964 if (delegate_) |
| 964 delegate_->OnPaint(canvas); | 965 delegate_->OnPaint(context); |
| 965 PaintLayerlessChildren(canvas); | 966 PaintLayerlessChildren(context); |
| 966 } | 967 } |
| 967 | 968 |
| 968 void Window::PaintLayerlessChildren(gfx::Canvas* canvas) { | 969 void Window::PaintLayerlessChildren(const ui::PaintContext& context) { |
| 969 for (size_t i = 0, count = children_.size(); i < count; ++i) { | 970 for (size_t i = 0, count = children_.size(); i < count; ++i) { |
| 970 Window* child = children_[i]; | 971 Window* child = children_[i]; |
| 971 if (!child->layer() && child->visible_) { | 972 if (!child->layer() && child->visible_) { |
| 973 gfx::Canvas* canvas = context.canvas(); |
| 972 gfx::ScopedCanvas scoped_canvas(canvas); | 974 gfx::ScopedCanvas scoped_canvas(canvas); |
| 973 canvas->ClipRect(child->bounds()); | 975 canvas->ClipRect(child->bounds()); |
| 974 if (!canvas->IsClipEmpty()) { | 976 if (!canvas->IsClipEmpty()) { |
| 975 canvas->Translate(child->bounds().OffsetFromOrigin()); | 977 canvas->Translate(child->bounds().OffsetFromOrigin()); |
| 976 child->Paint(canvas); | 978 child->Paint(context); |
| 977 } | 979 } |
| 978 } | 980 } |
| 979 } | 981 } |
| 980 } | 982 } |
| 981 | 983 |
| 982 Window* Window::GetWindowForPoint(const gfx::Point& local_point, | 984 Window* Window::GetWindowForPoint(const gfx::Point& local_point, |
| 983 bool return_tightest, | 985 bool return_tightest, |
| 984 bool for_event_handling) { | 986 bool for_event_handling) { |
| 985 if (!IsVisible()) | 987 if (!IsVisible()) |
| 986 return NULL; | 988 return NULL; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 state_modified |= | 1372 state_modified |= |
| 1371 ui::GestureRecognizer::Get()->CleanupStateForConsumer(this); | 1373 ui::GestureRecognizer::Get()->CleanupStateForConsumer(this); |
| 1372 for (Window::Windows::iterator iter = children_.begin(); | 1374 for (Window::Windows::iterator iter = children_.begin(); |
| 1373 iter != children_.end(); | 1375 iter != children_.end(); |
| 1374 ++iter) { | 1376 ++iter) { |
| 1375 state_modified |= (*iter)->CleanupGestureState(); | 1377 state_modified |= (*iter)->CleanupGestureState(); |
| 1376 } | 1378 } |
| 1377 return state_modified; | 1379 return state_modified; |
| 1378 } | 1380 } |
| 1379 | 1381 |
| 1380 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 1382 void Window::OnPaintLayer(const ui::PaintContext& context) { |
| 1381 Paint(canvas); | 1383 Paint(context); |
| 1382 } | 1384 } |
| 1383 | 1385 |
| 1384 void Window::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { | 1386 void Window::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { |
| 1385 DCHECK(layer()); | 1387 DCHECK(layer()); |
| 1386 FOR_EACH_OBSERVER(WindowObserver, | 1388 FOR_EACH_OBSERVER(WindowObserver, |
| 1387 observers_, | 1389 observers_, |
| 1388 OnDelegatedFrameDamage(this, damage_rect_in_dip)); | 1390 OnDelegatedFrameDamage(this, damage_rect_in_dip)); |
| 1389 } | 1391 } |
| 1390 | 1392 |
| 1391 base::Closure Window::PrepareForLayerBoundsChange() { | 1393 base::Closure Window::PrepareForLayerBoundsChange() { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 return window; | 1466 return window; |
| 1465 if (offset) | 1467 if (offset) |
| 1466 *offset += window->bounds().OffsetFromOrigin(); | 1468 *offset += window->bounds().OffsetFromOrigin(); |
| 1467 } | 1469 } |
| 1468 if (offset) | 1470 if (offset) |
| 1469 *offset = gfx::Vector2d(); | 1471 *offset = gfx::Vector2d(); |
| 1470 return NULL; | 1472 return NULL; |
| 1471 } | 1473 } |
| 1472 | 1474 |
| 1473 } // namespace aura | 1475 } // namespace aura |
| OLD | NEW |