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

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

Issue 1470123002: Split ClipTransformRecorder into {Clip,Transform}Recorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize transformed to false. Created 5 years 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/views/mus/native_widget_mus.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>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
18 #include "third_party/skia/include/core/SkRect.h" 18 #include "third_party/skia/include/core/SkRect.h"
19 #include "ui/accessibility/ax_enums.h" 19 #include "ui/accessibility/ax_enums.h"
20 #include "ui/base/cursor/cursor.h" 20 #include "ui/base/cursor/cursor.h"
21 #include "ui/base/dragdrop/drag_drop_types.h" 21 #include "ui/base/dragdrop/drag_drop_types.h"
22 #include "ui/base/ime/input_method.h" 22 #include "ui/base/ime/input_method.h"
23 #include "ui/compositor/clip_transform_recorder.h" 23 #include "ui/compositor/clip_recorder.h"
24 #include "ui/compositor/compositor.h" 24 #include "ui/compositor/compositor.h"
25 #include "ui/compositor/dip_util.h" 25 #include "ui/compositor/dip_util.h"
26 #include "ui/compositor/layer.h" 26 #include "ui/compositor/layer.h"
27 #include "ui/compositor/layer_animator.h" 27 #include "ui/compositor/layer_animator.h"
28 #include "ui/compositor/paint_context.h" 28 #include "ui/compositor/paint_context.h"
29 #include "ui/compositor/paint_recorder.h" 29 #include "ui/compositor/paint_recorder.h"
30 #include "ui/compositor/transform_recorder.h"
30 #include "ui/events/event_target_iterator.h" 31 #include "ui/events/event_target_iterator.h"
31 #include "ui/gfx/canvas.h" 32 #include "ui/gfx/canvas.h"
32 #include "ui/gfx/geometry/point3_f.h" 33 #include "ui/gfx/geometry/point3_f.h"
33 #include "ui/gfx/geometry/point_conversions.h" 34 #include "ui/gfx/geometry/point_conversions.h"
34 #include "ui/gfx/interpolated_transform.h" 35 #include "ui/gfx/interpolated_transform.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 #include "ui/gfx/skia_util.h" 39 #include "ui/gfx/skia_util.h"
39 #include "ui/gfx/transform.h" 40 #include "ui/gfx/transform.h"
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 772
772 // If the View wasn't invalidated, don't waste time painting it, the output 773 // If the View wasn't invalidated, don't waste time painting it, the output
773 // would be culled. 774 // would be culled.
774 is_invalidated = context.IsRectInvalid(GetLocalBounds()); 775 is_invalidated = context.IsRectInvalid(GetLocalBounds());
775 } 776 }
776 777
777 TRACE_EVENT1("views", "View::Paint", "class", GetClassName()); 778 TRACE_EVENT1("views", "View::Paint", "class", GetClassName());
778 779
779 // If the view is backed by a layer, it should paint with itself as the origin 780 // If the view is backed by a layer, it should paint with itself as the origin
780 // rather than relative to its parent. 781 // rather than relative to its parent.
781 ui::ClipTransformRecorder clip_transform_recorder(context); 782 bool paint_relative_to_parent = !layer();
782 if (!layer()) { 783
784 ui::ClipRecorder clip_recorder(context);
785 if (paint_relative_to_parent) {
783 // Set the clip rect to the bounds of this View. Note that the X (or left) 786 // 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 787 // 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 788 // View uses a right-to-left layout so that we paint the View in its
786 // mirrored position if need be. 789 // mirrored position if need be.
787 gfx::Rect clip_rect_in_parent = bounds(); 790 gfx::Rect clip_rect_in_parent = bounds();
788 clip_rect_in_parent.Inset(clip_insets_); 791 clip_rect_in_parent.Inset(clip_insets_);
789 if (parent_) 792 if (parent_)
790 clip_rect_in_parent.set_x( 793 clip_rect_in_parent.set_x(
791 parent_->GetMirroredXForRect(clip_rect_in_parent)); 794 parent_->GetMirroredXForRect(clip_rect_in_parent));
792 clip_transform_recorder.ClipRect(clip_rect_in_parent); 795 clip_recorder.ClipRect(clip_rect_in_parent);
796 }
793 797
798 ui::TransformRecorder transform_recorder(context);
799 if (paint_relative_to_parent) {
794 // Translate the graphics such that 0,0 corresponds to where 800 // Translate the graphics such that 0,0 corresponds to where
795 // this View is located relative to its parent. 801 // this View is located relative to its parent.
796 gfx::Transform transform_from_parent; 802 gfx::Transform transform_from_parent;
797 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin(); 803 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin();
798 transform_from_parent.Translate(offset_from_parent.x(), 804 transform_from_parent.Translate(offset_from_parent.x(),
799 offset_from_parent.y()); 805 offset_from_parent.y());
800 transform_from_parent.PreconcatTransform(GetTransform()); 806 transform_from_parent.PreconcatTransform(GetTransform());
801 clip_transform_recorder.Transform(transform_from_parent); 807 transform_recorder.Transform(transform_from_parent);
802 } 808 }
803 809
804 if (is_invalidated || !paint_cache_.UseCache(context)) { 810 if (is_invalidated || !paint_cache_.UseCache(context)) {
805 ui::PaintRecorder recorder(context, size(), &paint_cache_); 811 ui::PaintRecorder recorder(context, size(), &paint_cache_);
806 gfx::Canvas* canvas = recorder.canvas(); 812 gfx::Canvas* canvas = recorder.canvas();
807 813
808 // If the View we are about to paint requested the canvas to be flipped, we 814 // If the View we are about to paint requested the canvas to be flipped, we
809 // should change the transform appropriately. 815 // should change the transform appropriately.
810 // The canvas mirroring is undone once the View is done painting so that we 816 // The canvas mirroring is undone once the View is done painting so that we
811 // don't pass the canvas with the mirrored transform to Views that didn't 817 // don't pass the canvas with the mirrored transform to Views that didn't
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 // Message the RootView to do the drag and drop. That way if we're removed 2371 // Message the RootView to do the drag and drop. That way if we're removed
2366 // the RootView can detect it and avoid calling us back. 2372 // the RootView can detect it and avoid calling us back.
2367 gfx::Point widget_location(event.location()); 2373 gfx::Point widget_location(event.location());
2368 ConvertPointToWidget(this, &widget_location); 2374 ConvertPointToWidget(this, &widget_location);
2369 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2375 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2370 // WARNING: we may have been deleted. 2376 // WARNING: we may have been deleted.
2371 return true; 2377 return true;
2372 } 2378 }
2373 2379
2374 } // namespace views 2380 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698