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

Side by Side Diff: views/view.h

Issue 7845033: Rework View Layer Draw() to use the Layer::DrawTree() method and the LayerDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « views/layer_helper.cc ('k') | views/view.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef VIEWS_VIEW_H_ 5 #ifndef VIEWS_VIEW_H_
6 #define VIEWS_VIEW_H_ 6 #define VIEWS_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "ui/base/dragdrop/os_exchange_data.h" 19 #include "ui/base/dragdrop/os_exchange_data.h"
20 #include "ui/gfx/compositor/layer_delegate.h"
20 #include "ui/gfx/native_widget_types.h" 21 #include "ui/gfx/native_widget_types.h"
21 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
22 #include "views/accelerator.h" 23 #include "views/accelerator.h"
23 #include "views/background.h" 24 #include "views/background.h"
24 #include "views/border.h" 25 #include "views/border.h"
25 #include "views/layer_helper.h" 26 #include "views/layer_helper.h"
26 27
27 using ui::OSExchangeData; 28 using ui::OSExchangeData;
28 29
29 namespace gfx { 30 namespace gfx {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // SprocketLayout system. Alternative Layout Managers implementing the 85 // SprocketLayout system. Alternative Layout Managers implementing the
85 // LayoutManager interface can be used to lay out children if required. 86 // LayoutManager interface can be used to lay out children if required.
86 // 87 //
87 // It is up to the subclass to implement Painting and storage of subclass - 88 // It is up to the subclass to implement Painting and storage of subclass -
88 // specific properties and functionality. 89 // specific properties and functionality.
89 // 90 //
90 // Unless otherwise documented, views is not thread safe and should only be 91 // Unless otherwise documented, views is not thread safe and should only be
91 // accessed from the main thread. 92 // accessed from the main thread.
92 // 93 //
93 ///////////////////////////////////////////////////////////////////////////// 94 /////////////////////////////////////////////////////////////////////////////
94 class VIEWS_EXPORT View : public AcceleratorTarget { 95 class VIEWS_EXPORT View : public ui::LayerDelegate,
96 public AcceleratorTarget {
95 public: 97 public:
96 typedef std::vector<View*> Views; 98 typedef std::vector<View*> Views;
97 99
98 // TO BE MOVED --------------------------------------------------------------- 100 // TO BE MOVED ---------------------------------------------------------------
99 // TODO(beng): These methods are to be moved to other files/classes. 101 // TODO(beng): These methods are to be moved to other files/classes.
100 102
101 // TODO(beng): delete 103 // TODO(beng): delete
102 // Set whether this view is hottracked. A disabled view cannot be hottracked. 104 // Set whether this view is hottracked. A disabled view cannot be hottracked.
103 // If flag differs from the current value, SchedulePaint is invoked. 105 // If flag differs from the current value, SchedulePaint is invoked.
104 virtual void SetHotTracked(bool flag); 106 virtual void SetHotTracked(bool flag);
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 956
955 // Override to paint a border not specified by SetBorder(). 957 // Override to paint a border not specified by SetBorder().
956 virtual void OnPaintBorder(gfx::Canvas* canvas); 958 virtual void OnPaintBorder(gfx::Canvas* canvas);
957 959
958 // Override to paint a focus border (usually a dotted rectangle) around 960 // Override to paint a focus border (usually a dotted rectangle) around
959 // relevant contents. 961 // relevant contents.
960 virtual void OnPaintFocusBorder(gfx::Canvas* canvas); 962 virtual void OnPaintFocusBorder(gfx::Canvas* canvas);
961 963
962 // Accelerated painting ------------------------------------------------------ 964 // Accelerated painting ------------------------------------------------------
963 965
964 // Invoked from SchedulePaintInRect. Invokes SchedulePaintInternal on the
965 // parent. This does not mark the layer as dirty. It's assumed the caller has
966 // done this. You should not need to invoke this, use SchedulePaint or
967 // SchedulePaintInRect instead.
968 virtual void SchedulePaintInternal(const gfx::Rect& r);
969
970 // If our layer is out of date invokes Paint() with a canvas that is then
971 // copied to the layer. If the layer is not out of date recursively descends
972 // in case any children needed their layers updated.
973 //
974 // This is invoked internally by Widget and painting code.
975 virtual void PaintToLayer(const gfx::Rect& dirty_rect);
976
977 // Instructs the compositor to show our layer and all children layers.
978 // Invokes OnWillCompositeLayer() for any views that have layers.
979 //
980 // This is invoked internally by Widget and painting code.
981 virtual void PaintComposite();
982
983 // Invoked from |PaintComposite| if this view has a layer and before the
984 // layer is rendered by the compositor.
985 virtual void OnWillCompositeLayer();
986
987 // This creates a layer for the view, if one does not exist. It then 966 // This creates a layer for the view, if one does not exist. It then
988 // passes the texture to a layer associated with the view. While an external 967 // passes the texture to a layer associated with the view. While an external
989 // texture is set, the view will not update the layer contents. 968 // texture is set, the view will not update the layer contents.
990 // 969 //
991 // Passing NULL resets to default behavior. 970 // Passing NULL resets to default behavior.
992 // 971 //
993 // Returns false if it cannot create a layer to which to assign the texture. 972 // Returns false if it cannot create a layer to which to assign the texture.
994 bool SetExternalTexture(ui::Texture* texture); 973 bool SetExternalTexture(ui::Texture* texture);
995 974
996 // Returns the Compositor. 975 // Returns the Compositor.
997 virtual const ui::Compositor* GetCompositor() const; 976 virtual const ui::Compositor* GetCompositor() const;
998 virtual ui::Compositor* GetCompositor(); 977 virtual ui::Compositor* GetCompositor();
999 978
1000 // Marks the layer this view draws into as dirty. 979 // Returns the offset from this view to the nearest ancestor with a layer.
1001 virtual void MarkLayerDirty(); 980 // If |ancestor| is non-NULL it is set to the nearest ancestor with a layer.
1002 981 virtual void CalculateOffsetToAncestorWithLayer(
1003 // Returns the offset from this view to the neareset ancestor with a layer. 982 gfx::Point* offset,
1004 // If |ancestor| is non-NULL it is set to the nearset ancestor with a layer. 983 ui::Layer** layer_parent);
1005 virtual void CalculateOffsetToAncestorWithLayer(gfx::Point* offset,
1006 View** ancestor);
1007 984
1008 // Creates a layer for this and recurses through all descendants. 985 // Creates a layer for this and recurses through all descendants.
1009 virtual void CreateLayerIfNecessary(); 986 virtual void CreateLayerIfNecessary();
1010 987
1011 // If this view has a layer, the layer is reparented to |parent_layer| and its 988 // If this view has a layer, the layer is reparented to |parent_layer| and its
1012 // bounds is set based on |point|. If this view does not have a layer, then 989 // bounds is set based on |point|. If this view does not have a layer, then
1013 // recurses through all children. This is used when adding a layer to an 990 // recurses through all children. This is used when adding a layer to an
1014 // existing view to make sure all descendants that have layers are parented to 991 // existing view to make sure all descendants that have layers are parented to
1015 // the right layer. 992 // the right layer.
1016 virtual void MoveLayerToParent(ui::Layer* parent_layer, 993 virtual void MoveLayerToParent(ui::Layer* parent_layer,
1017 const gfx::Point& point); 994 const gfx::Point& point);
1018 995
1019 // Destroys the layer on this view and all descendants. Intended for when a 996 // Destroys the layer on this view and all descendants. Intended for when a
1020 // view is being removed or made invisible. 997 // view is being removed or made invisible.
1021 virtual void DestroyLayerRecurse(); 998 virtual void DestroyLayerRecurse();
1022 999
1023 // Resets the bounds of the layer associated with this view and all 1000 // Resets the bounds of the layer associated with this view and all
1024 // descendants. 1001 // descendants.
1025 virtual void UpdateLayerBounds(const gfx::Point& offset); 1002 virtual void UpdateLayerBounds(const gfx::Point& offset);
1026 1003
1004 // Overridden from ui::LayerDelegate:
1005 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
1006
1027 // Input --------------------------------------------------------------------- 1007 // Input ---------------------------------------------------------------------
1028 1008
1029 // Called by HitTest to see if this View has a custom hit test mask. If the 1009 // Called by HitTest to see if this View has a custom hit test mask. If the
1030 // return value is true, GetHitTestMask will be called to obtain the mask. 1010 // return value is true, GetHitTestMask will be called to obtain the mask.
1031 // Default value is false, in which case the View will hit-test against its 1011 // Default value is false, in which case the View will hit-test against its
1032 // bounds. 1012 // bounds.
1033 virtual bool HasHitTestMask() const; 1013 virtual bool HasHitTestMask() const;
1034 1014
1035 // Called by HitTest to retrieve a mask for hit-testing against. Subclasses 1015 // Called by HitTest to retrieve a mask for hit-testing against. Subclasses
1036 // override to provide custom shaped hit test regions. 1016 // override to provide custom shaped hit test regions.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 SCHEDULE_PAINT_SIZE_SAME, 1112 SCHEDULE_PAINT_SIZE_SAME,
1133 1113
1134 // Indicates the size changed (and possibly the origin). 1114 // Indicates the size changed (and possibly the origin).
1135 SCHEDULE_PAINT_SIZE_CHANGED 1115 SCHEDULE_PAINT_SIZE_CHANGED
1136 }; 1116 };
1137 1117
1138 // Invoked before and after the bounds change to schedule painting the old and 1118 // Invoked before and after the bounds change to schedule painting the old and
1139 // new bounds. 1119 // new bounds.
1140 void SchedulePaintBoundsChanged(SchedulePaintType type); 1120 void SchedulePaintBoundsChanged(SchedulePaintType type);
1141 1121
1122 // Common Paint() code shared by accelerated and non-accelerated code paths to
1123 // invoke OnPaint() on the View.
1124 void PaintCommon(gfx::Canvas* canvas);
1125
1142 // Tree operations ----------------------------------------------------------- 1126 // Tree operations -----------------------------------------------------------
1143 1127
1144 // Removes |view| from the hierarchy tree. If |update_focus_cycle| is true, 1128 // Removes |view| from the hierarchy tree. If |update_focus_cycle| is true,
1145 // the next and previous focusable views of views pointing to this view are 1129 // the next and previous focusable views of views pointing to this view are
1146 // updated. If |update_tool_tip| is true, the tooltip is updated. If 1130 // updated. If |update_tool_tip| is true, the tooltip is updated. If
1147 // |delete_removed_view| is true, the view is also deleted (if it is parent 1131 // |delete_removed_view| is true, the view is also deleted (if it is parent
1148 // owned). 1132 // owned).
1149 void DoRemoveChildView(View* view, 1133 void DoRemoveChildView(View* view,
1150 bool update_focus_cycle, 1134 bool update_focus_cycle,
1151 bool update_tool_tip, 1135 bool update_tool_tip,
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 #if defined(OS_WIN) 1433 #if defined(OS_WIN)
1450 scoped_refptr<NativeViewAccessibilityWin> native_view_accessibility_win_; 1434 scoped_refptr<NativeViewAccessibilityWin> native_view_accessibility_win_;
1451 #endif 1435 #endif
1452 1436
1453 DISALLOW_COPY_AND_ASSIGN(View); 1437 DISALLOW_COPY_AND_ASSIGN(View);
1454 }; 1438 };
1455 1439
1456 } // namespace views 1440 } // namespace views
1457 1441
1458 #endif // VIEWS_VIEW_H_ 1442 #endif // VIEWS_VIEW_H_
OLDNEW
« no previous file with comments | « views/layer_helper.cc ('k') | views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698