Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Side by Side Diff: ui/views/view.cc

Issue 1423653005: Further plumb visual rect into cc:DisplayItemList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename layer_bounds to bounds_in_layer. Stop caching bounds in PaintCache. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/compositor/paint_recorder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 770
771 // If the View wasn't invalidated, don't waste time painting it, the output 771 // If the View wasn't invalidated, don't waste time painting it, the output
772 // would be culled. 772 // would be culled.
773 is_invalidated = context.IsRectInvalid(GetLocalBounds()); 773 is_invalidated = context.IsRectInvalid(GetLocalBounds());
774 } 774 }
775 775
776 TRACE_EVENT1("views", "View::Paint", "class", GetClassName()); 776 TRACE_EVENT1("views", "View::Paint", "class", GetClassName());
777 777
778 // If the view is backed by a layer, it should paint with itself as the origin 778 // If the view is backed by a layer, it should paint with itself as the origin
779 // rather than relative to its parent. 779 // rather than relative to its parent.
780 ui::ClipTransformRecorder clip_transform_recorder(context); 780 ui::ClipTransformRecorder clip_transform_recorder(context, size());
781 if (!layer()) { 781 if (!layer()) {
782 // Set the clip rect to the bounds of this View. Note that the X (or left) 782 // Set the clip rect to the bounds of this View. Note that the X (or left)
783 // position we pass to ClipRect takes into consideration whether or not the 783 // position we pass to ClipRect takes into consideration whether or not the
784 // View uses a right-to-left layout so that we paint the View in its 784 // View uses a right-to-left layout so that we paint the View in its
785 // mirrored position if need be. 785 // mirrored position if need be.
786 gfx::Rect clip_rect_in_parent = bounds(); 786 gfx::Rect clip_rect_in_parent = bounds();
787 clip_rect_in_parent.Inset(clip_insets_); 787 clip_rect_in_parent.Inset(clip_insets_);
788 if (parent_) 788 if (parent_)
789 clip_rect_in_parent.set_x( 789 clip_rect_in_parent.set_x(
790 parent_->GetMirroredXForRect(clip_rect_in_parent)); 790 parent_->GetMirroredXForRect(clip_rect_in_parent));
791 clip_transform_recorder.ClipRect(clip_rect_in_parent); 791 clip_transform_recorder.ClipRect(clip_rect_in_parent);
792 792
793 // Translate the graphics such that 0,0 corresponds to where 793 // Translate the graphics such that 0,0 corresponds to where
794 // this View is located relative to its parent. 794 // this View is located relative to its parent.
795 gfx::Transform transform_from_parent; 795 gfx::Transform transform_from_parent;
796 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin(); 796 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin();
797 transform_from_parent.Translate(offset_from_parent.x(), 797 transform_from_parent.Translate(offset_from_parent.x(),
798 offset_from_parent.y()); 798 offset_from_parent.y());
799 transform_from_parent.PreconcatTransform(GetTransform()); 799 transform_from_parent.PreconcatTransform(GetTransform());
800 clip_transform_recorder.Transform(transform_from_parent); 800 clip_transform_recorder.Transform(transform_from_parent);
801 } 801 }
802 802
803 if (is_invalidated || !paint_cache_.UseCache(context)) { 803 if (is_invalidated || !paint_cache_.UseCache(context, size())) {
danakj 2015/11/18 22:23:14 can you leave a comment here saying that the cache
wkorman 2015/11/18 23:01:31 Done.
804 ui::PaintRecorder recorder(context, size(), &paint_cache_); 804 ui::PaintRecorder recorder(context, size(), &paint_cache_);
805 gfx::Canvas* canvas = recorder.canvas(); 805 gfx::Canvas* canvas = recorder.canvas();
806 806
807 // If the View we are about to paint requested the canvas to be flipped, we 807 // If the View we are about to paint requested the canvas to be flipped, we
808 // should change the transform appropriately. 808 // should change the transform appropriately.
809 // The canvas mirroring is undone once the View is done painting so that we 809 // The canvas mirroring is undone once the View is done painting so that we
810 // don't pass the canvas with the mirrored transform to Views that didn't 810 // don't pass the canvas with the mirrored transform to Views that didn't
811 // request the canvas to be flipped. 811 // request the canvas to be flipped.
812 if (FlipCanvasOnPaintForRTLUI()) { 812 if (FlipCanvasOnPaintForRTLUI()) {
813 canvas->Translate(gfx::Vector2d(width(), 0)); 813 canvas->Translate(gfx::Vector2d(width(), 0));
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 // Message the RootView to do the drag and drop. That way if we're removed 2354 // Message the RootView to do the drag and drop. That way if we're removed
2355 // the RootView can detect it and avoid calling us back. 2355 // the RootView can detect it and avoid calling us back.
2356 gfx::Point widget_location(event.location()); 2356 gfx::Point widget_location(event.location());
2357 ConvertPointToWidget(this, &widget_location); 2357 ConvertPointToWidget(this, &widget_location);
2358 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2358 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2359 // WARNING: we may have been deleted. 2359 // WARNING: we may have been deleted.
2360 return true; 2360 return true;
2361 } 2361 }
2362 2362
2363 } // namespace views 2363 } // namespace views
OLDNEW
« no previous file with comments | « ui/compositor/paint_recorder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698