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

Side by Side Diff: aura/window.cc

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 | « aura/window.h ('k') | chrome/browser/ui/views/wrench_menu.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 #include "aura/window.h" 5 #include "aura/window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "aura/desktop.h" 9 #include "aura/desktop.h"
10 #include "aura/event.h" 10 #include "aura/event.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 void Window::Init() { 47 void Window::Init() {
48 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor())); 48 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor()));
49 layer_->set_delegate(this); 49 layer_->set_delegate(this);
50 } 50 }
51 51
52 void Window::SetVisibility(Visibility visibility) { 52 void Window::SetVisibility(Visibility visibility) {
53 if (visibility_ == visibility) 53 if (visibility_ == visibility)
54 return; 54 return;
55 55
56 visibility_ = visibility; 56 visibility_ = visibility;
57 if (visibility_ != VISIBILITY_HIDDEN) 57 layer_->set_visible(visibility_ != VISIBILITY_HIDDEN);
58 if (layer_->visible())
58 SchedulePaint(); 59 SchedulePaint();
59 } 60 }
60 61
61 void Window::SetBounds(const gfx::Rect& bounds, int anim_ms) { 62 void Window::SetBounds(const gfx::Rect& bounds, int anim_ms) {
62 // TODO: support anim_ms 63 // TODO: support anim_ms
63 // TODO: funnel this through the Desktop. 64 // TODO: funnel this through the Desktop.
64 bool was_move = bounds_.size() == bounds.size(); 65 bool was_move = bounds_.size() == bounds.size();
65 bounds_ = bounds; 66 bounds_ = bounds;
66 layer_->SetBounds(bounds); 67 layer_->SetBounds(bounds);
67 if (was_move) 68 if (was_move)
(...skipping 30 matching lines...) Expand all
98 const Windows::iterator i(std::find(children_.begin(), children_.end(), 99 const Windows::iterator i(std::find(children_.begin(), children_.end(),
99 child)); 100 child));
100 DCHECK(i != children_.end()); 101 DCHECK(i != children_.end());
101 children_.erase(i); 102 children_.erase(i);
102 103
103 // TODO(beng): this obviously has to handle different window types. 104 // TODO(beng): this obviously has to handle different window types.
104 children_.insert(children_.begin() + children_.size(), child); 105 children_.insert(children_.begin() + children_.size(), child);
105 SchedulePaintInRect(gfx::Rect()); 106 SchedulePaintInRect(gfx::Rect());
106 } 107 }
107 108
108 void Window::DrawTree() {
109 Draw();
110 for (Windows::iterator i = children_.begin(); i != children_.end(); ++i)
111 (*i)->DrawTree();
112 }
113
114 void Window::AddChild(Window* child) { 109 void Window::AddChild(Window* child) {
115 DCHECK(std::find(children_.begin(), children_.end(), child) == 110 DCHECK(std::find(children_.begin(), children_.end(), child) ==
116 children_.end()); 111 children_.end());
117 child->parent_ = this; 112 child->parent_ = this;
118 layer_->Add(child->layer_.get()); 113 layer_->Add(child->layer_.get());
119 children_.push_back(child); 114 children_.push_back(child);
120 } 115 }
121 116
122 void Window::RemoveChild(Window* child) { 117 void Window::RemoveChild(Window* child) {
123 Windows::iterator i = std::find(children_.begin(), children_.end(), child); 118 Windows::iterator i = std::find(children_.begin(), children_.end(), child);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 if (child->HitTest(point_in_child_coords)) 156 if (child->HitTest(point_in_child_coords))
162 return child->GetEventHandlerForPoint(point_in_child_coords); 157 return child->GetEventHandlerForPoint(point_in_child_coords);
163 } 158 }
164 return this; 159 return this;
165 } 160 }
166 161
167 internal::FocusManager* Window::GetFocusManager() { 162 internal::FocusManager* Window::GetFocusManager() {
168 return parent_ ? parent_->GetFocusManager() : NULL; 163 return parent_ ? parent_->GetFocusManager() : NULL;
169 } 164 }
170 165
171 void Window::Draw() {
172 if (visibility_ != VISIBILITY_HIDDEN)
173 layer_->Draw();
174 }
175
176 void Window::SchedulePaint() { 166 void Window::SchedulePaint() {
177 SchedulePaintInRect(gfx::Rect(0, 0, bounds_.width(), bounds_.height())); 167 SchedulePaintInRect(gfx::Rect(0, 0, bounds_.width(), bounds_.height()));
178 } 168 }
179 169
180 void Window::OnPaint(gfx::Canvas* canvas) { 170 void Window::OnPaintLayer(gfx::Canvas* canvas) {
181 delegate_->OnPaint(canvas); 171 if (delegate_)
172 delegate_->OnPaint(canvas);
182 } 173 }
183 174
184 } // namespace aura 175 } // namespace aura
OLDNEW
« no previous file with comments | « aura/window.h ('k') | chrome/browser/ui/views/wrench_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698