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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
6 | 6 |
7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "third_party/skia/include/core/SkRect.h" | 24 #include "third_party/skia/include/core/SkRect.h" |
25 #include "ui/accessibility/ax_enums.h" | 25 #include "ui/accessibility/ax_enums.h" |
26 #include "ui/base/cursor/cursor.h" | 26 #include "ui/base/cursor/cursor.h" |
27 #include "ui/base/dragdrop/drag_drop_types.h" | 27 #include "ui/base/dragdrop/drag_drop_types.h" |
28 #include "ui/base/ime/input_method.h" | 28 #include "ui/base/ime/input_method.h" |
29 #include "ui/compositor/clip_recorder.h" | 29 #include "ui/compositor/clip_recorder.h" |
30 #include "ui/compositor/compositor.h" | 30 #include "ui/compositor/compositor.h" |
31 #include "ui/compositor/dip_util.h" | 31 #include "ui/compositor/dip_util.h" |
32 #include "ui/compositor/layer.h" | 32 #include "ui/compositor/layer.h" |
33 #include "ui/compositor/layer_animator.h" | 33 #include "ui/compositor/layer_animator.h" |
34 #include "ui/compositor/layer_type.h" | |
34 #include "ui/compositor/paint_context.h" | 35 #include "ui/compositor/paint_context.h" |
35 #include "ui/compositor/paint_recorder.h" | 36 #include "ui/compositor/paint_recorder.h" |
36 #include "ui/compositor/transform_recorder.h" | 37 #include "ui/compositor/transform_recorder.h" |
37 #include "ui/display/screen.h" | 38 #include "ui/display/screen.h" |
38 #include "ui/events/event_target_iterator.h" | 39 #include "ui/events/event_target_iterator.h" |
39 #include "ui/gfx/canvas.h" | 40 #include "ui/gfx/canvas.h" |
40 #include "ui/gfx/geometry/point3_f.h" | 41 #include "ui/gfx/geometry/point3_f.h" |
41 #include "ui/gfx/geometry/point_conversions.h" | 42 #include "ui/gfx/geometry/point_conversions.h" |
42 #include "ui/gfx/interpolated_transform.h" | 43 #include "ui/gfx/interpolated_transform.h" |
43 #include "ui/gfx/path.h" | 44 #include "ui/gfx/path.h" |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 if (transform.IsIdentity()) { | 517 if (transform.IsIdentity()) { |
517 if (layer()) { | 518 if (layer()) { |
518 layer()->SetTransform(transform); | 519 layer()->SetTransform(transform); |
519 if (!paint_to_layer_) | 520 if (!paint_to_layer_) |
520 DestroyLayer(); | 521 DestroyLayer(); |
521 } else { | 522 } else { |
522 // Nothing. | 523 // Nothing. |
523 } | 524 } |
524 } else { | 525 } else { |
525 if (!layer()) | 526 if (!layer()) |
526 CreateLayer(); | 527 CreateLayer(ui::LAYER_TEXTURED); |
527 layer()->SetTransform(transform); | 528 layer()->SetTransform(transform); |
528 layer()->ScheduleDraw(); | 529 layer()->ScheduleDraw(); |
529 } | 530 } |
530 } | 531 } |
531 | 532 |
532 void View::SetPaintToLayer(bool paint_to_layer) { | 533 void View::SetPaintToLayer(ui::LayerType layer_type) { |
533 if (paint_to_layer_ == paint_to_layer) | 534 bool is_paint_layer = !(layer_type == ui::LAYER_NOT_DRAWN); |
sadrul
2017/01/20 19:50:11
layer_type != ui::LAYER_NOT_DRAW
| |
535 if (is_paint_layer == paint_to_layer_) | |
534 return; | 536 return; |
535 | 537 |
536 paint_to_layer_ = paint_to_layer; | 538 paint_to_layer_ = is_paint_layer; |
537 if (paint_to_layer_ && !layer()) { | 539 if (paint_to_layer_ && !layer()) { |
538 CreateLayer(); | 540 CreateLayer(layer_type); |
539 } else if (!paint_to_layer_ && layer()) { | 541 } else if (!paint_to_layer_ && layer()) { |
540 DestroyLayer(); | 542 DestroyLayer(); |
541 } | 543 } |
542 } | 544 } |
543 | 545 |
544 std::unique_ptr<ui::Layer> View::RecreateLayer() { | 546 std::unique_ptr<ui::Layer> View::RecreateLayer() { |
545 std::unique_ptr<ui::Layer> old_layer = LayerOwner::RecreateLayer(); | 547 std::unique_ptr<ui::Layer> old_layer = LayerOwner::RecreateLayer(); |
546 Widget* widget = GetWidget(); | 548 Widget* widget = GetWidget(); |
547 if (widget) | 549 if (widget) |
548 widget->UpdateRootLayers(); | 550 widget->UpdateRootLayers(); |
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2177 bool View::ConvertRectFromAncestor(const View* ancestor, | 2179 bool View::ConvertRectFromAncestor(const View* ancestor, |
2178 gfx::RectF* rect) const { | 2180 gfx::RectF* rect) const { |
2179 gfx::Transform trans; | 2181 gfx::Transform trans; |
2180 bool result = GetTransformRelativeTo(ancestor, &trans); | 2182 bool result = GetTransformRelativeTo(ancestor, &trans); |
2181 trans.TransformRectReverse(rect); | 2183 trans.TransformRectReverse(rect); |
2182 return result; | 2184 return result; |
2183 } | 2185 } |
2184 | 2186 |
2185 // Accelerated painting -------------------------------------------------------- | 2187 // Accelerated painting -------------------------------------------------------- |
2186 | 2188 |
2187 void View::CreateLayer() { | 2189 void View::CreateLayer(ui::LayerType layer_type) { |
2188 // A new layer is being created for the view. So all the layers of the | 2190 // A new layer is being created for the view. So all the layers of the |
2189 // sub-tree can inherit the visibility of the corresponding view. | 2191 // sub-tree can inherit the visibility of the corresponding view. |
2190 { | 2192 { |
2191 internal::ScopedChildrenLock lock(this); | 2193 internal::ScopedChildrenLock lock(this); |
2192 for (auto* child : children_) | 2194 for (auto* child : children_) |
2193 child->UpdateChildLayerVisibility(true); | 2195 child->UpdateChildLayerVisibility(true); |
2194 } | 2196 } |
2195 | 2197 |
2196 SetLayer(base::MakeUnique<ui::Layer>()); | 2198 SetLayer(base::MakeUnique<ui::Layer>(layer_type)); |
2197 layer()->set_delegate(this); | 2199 layer()->set_delegate(this); |
2198 layer()->set_name(GetClassName()); | 2200 layer()->set_name(GetClassName()); |
2199 | 2201 |
2200 UpdateParentLayers(); | 2202 UpdateParentLayers(); |
2201 UpdateLayerVisibility(); | 2203 UpdateLayerVisibility(); |
2202 | 2204 |
2203 // The new layer needs to be ordered in the layer tree according | 2205 // The new layer needs to be ordered in the layer tree according |
2204 // to the view tree. Children of this layer were added in order | 2206 // to the view tree. Children of this layer were added in order |
2205 // in UpdateParentLayers(). | 2207 // in UpdateParentLayers(). |
2206 if (parent()) | 2208 if (parent()) |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2546 // Message the RootView to do the drag and drop. That way if we're removed | 2548 // Message the RootView to do the drag and drop. That way if we're removed |
2547 // the RootView can detect it and avoid calling us back. | 2549 // the RootView can detect it and avoid calling us back. |
2548 gfx::Point widget_location(event.location()); | 2550 gfx::Point widget_location(event.location()); |
2549 ConvertPointToWidget(this, &widget_location); | 2551 ConvertPointToWidget(this, &widget_location); |
2550 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2552 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2551 // WARNING: we may have been deleted. | 2553 // WARNING: we may have been deleted. |
2552 return true; | 2554 return true; |
2553 } | 2555 } |
2554 | 2556 |
2555 } // namespace views | 2557 } // namespace views |
OLD | NEW |