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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 if (!context.IsRectInvalidated(GetLocalBounds())) | 773 if (!context.IsRectInvalidated(GetLocalBounds())) |
774 return; | 774 return; |
775 } | 775 } |
776 | 776 |
777 TRACE_EVENT1("views", "View::Paint", "class", GetClassName()); | 777 TRACE_EVENT1("views", "View::Paint", "class", GetClassName()); |
778 | 778 |
779 // If the view is backed by a layer, it should paint with itself as the origin | 779 // If the view is backed by a layer, it should paint with itself as the origin |
780 // rather than relative to its parent. | 780 // rather than relative to its parent. |
781 scoped_ptr<ui::ClipTransformRecorder> clip_transform_recorder; | 781 scoped_ptr<ui::ClipTransformRecorder> clip_transform_recorder; |
782 if (!layer()) { | 782 if (!layer()) { |
| 783 clip_transform_recorder.reset(new ui::ClipTransformRecorder(context)); |
| 784 |
783 // Set the clip rect to the bounds of this View. Note that the X (or left) | 785 // Set the clip rect to the bounds of this View. Note that the X (or left) |
784 // position we pass to ClipRect takes into consideration whether or not the | 786 // position we pass to ClipRect takes into consideration whether or not the |
785 // View uses a right-to-left layout so that we paint the View in its | 787 // View uses a right-to-left layout so that we paint the View in its |
786 // mirrored position if need be. | 788 // mirrored position if need be. |
787 gfx::Rect clip_rect_in_parent = bounds(); | 789 gfx::Rect clip_rect_in_parent = bounds(); |
788 clip_rect_in_parent.Inset(clip_insets_); | 790 clip_rect_in_parent.Inset(clip_insets_); |
789 if (parent_) | 791 if (parent_) |
790 clip_rect_in_parent.set_x( | 792 clip_rect_in_parent.set_x( |
791 parent_->GetMirroredXForRect(clip_rect_in_parent)); | 793 parent_->GetMirroredXForRect(clip_rect_in_parent)); |
| 794 clip_transform_recorder->ClipRect(clip_rect_in_parent); |
792 | 795 |
793 // Translate the graphics such that 0,0 corresponds to where | 796 // Translate the graphics such that 0,0 corresponds to where |
794 // this View is located relative to its parent. | 797 // this View is located relative to its parent. |
795 gfx::Transform transform_from_parent; | 798 gfx::Transform transform_from_parent; |
796 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin(); | 799 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin(); |
797 transform_from_parent.Translate(offset_from_parent.x(), | 800 transform_from_parent.Translate(offset_from_parent.x(), |
798 offset_from_parent.y()); | 801 offset_from_parent.y()); |
799 transform_from_parent.PreconcatTransform(GetTransform()); | 802 transform_from_parent.PreconcatTransform(GetTransform()); |
800 | 803 clip_transform_recorder->Transform(transform_from_parent); |
801 clip_transform_recorder = make_scoped_ptr(new ui::ClipTransformRecorder( | |
802 context, clip_rect_in_parent, transform_from_parent)); | |
803 } | 804 } |
804 | 805 |
805 { | 806 { |
806 ui::PaintRecorder recorder(context); | 807 ui::PaintRecorder recorder(context); |
807 gfx::Canvas* canvas = recorder.canvas(); | 808 gfx::Canvas* canvas = recorder.canvas(); |
808 gfx::ScopedCanvas scoped_canvas(canvas); | 809 gfx::ScopedCanvas scoped_canvas(canvas); |
809 | 810 |
810 // If the View we are about to paint requested the canvas to be flipped, we | 811 // If the View we are about to paint requested the canvas to be flipped, we |
811 // should change the transform appropriately. | 812 // should change the transform appropriately. |
812 // The canvas mirroring is undone once the View is done painting so that we | 813 // The canvas mirroring is undone once the View is done painting so that we |
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2366 // Message the RootView to do the drag and drop. That way if we're removed | 2367 // Message the RootView to do the drag and drop. That way if we're removed |
2367 // the RootView can detect it and avoid calling us back. | 2368 // the RootView can detect it and avoid calling us back. |
2368 gfx::Point widget_location(event.location()); | 2369 gfx::Point widget_location(event.location()); |
2369 ConvertPointToWidget(this, &widget_location); | 2370 ConvertPointToWidget(this, &widget_location); |
2370 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2371 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2371 // WARNING: we may have been deleted. | 2372 // WARNING: we may have been deleted. |
2372 return true; | 2373 return true; |
2373 } | 2374 } |
2374 | 2375 |
2375 } // namespace views | 2376 } // namespace views |
OLD | NEW |