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

Side by Side Diff: ui/views/corewm/window_animations.cc

Issue 184983005: Remove Views dependency from window_animations.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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 | « ui/views/corewm/DEPS ('k') | ui/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) 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 #include "ui/views/corewm/window_animations.h" 5 #include "ui/views/corewm/window_animations.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 17 matching lines...) Expand all
28 #include "ui/compositor/layer_animator.h" 28 #include "ui/compositor/layer_animator.h"
29 #include "ui/compositor/scoped_layer_animation_settings.h" 29 #include "ui/compositor/scoped_layer_animation_settings.h"
30 #include "ui/gfx/animation/animation.h" 30 #include "ui/gfx/animation/animation.h"
31 #include "ui/gfx/interpolated_transform.h" 31 #include "ui/gfx/interpolated_transform.h"
32 #include "ui/gfx/rect_conversions.h" 32 #include "ui/gfx/rect_conversions.h"
33 #include "ui/gfx/screen.h" 33 #include "ui/gfx/screen.h"
34 #include "ui/gfx/vector2d.h" 34 #include "ui/gfx/vector2d.h"
35 #include "ui/gfx/vector3d_f.h" 35 #include "ui/gfx/vector3d_f.h"
36 #include "ui/views/corewm/corewm_switches.h" 36 #include "ui/views/corewm/corewm_switches.h"
37 #include "ui/views/corewm/window_util.h" 37 #include "ui/views/corewm/window_util.h"
38 #include "ui/views/view.h"
39 #include "ui/views/widget/widget.h"
40 38
41 DECLARE_WINDOW_PROPERTY_TYPE(int) 39 DECLARE_WINDOW_PROPERTY_TYPE(int)
42 DECLARE_WINDOW_PROPERTY_TYPE(views::corewm::WindowVisibilityAnimationType) 40 DECLARE_WINDOW_PROPERTY_TYPE(views::corewm::WindowVisibilityAnimationType)
43 DECLARE_WINDOW_PROPERTY_TYPE(views::corewm::WindowVisibilityAnimationTransition) 41 DECLARE_WINDOW_PROPERTY_TYPE(views::corewm::WindowVisibilityAnimationTransition)
44 DECLARE_WINDOW_PROPERTY_TYPE(float) 42 DECLARE_WINDOW_PROPERTY_TYPE(float)
45 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, bool) 43 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, bool)
46 44
47 using aura::Window; 45 using aura::Window;
48 using base::TimeDelta; 46 using base::TimeDelta;
49 using ui::Layer; 47 using ui::Layer;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 animation_host->OnWindowHidingAnimationCompleted(); 141 animation_host->OnWindowHidingAnimationCompleted();
144 window_->RemoveObserver(this); 142 window_->RemoveObserver(this);
145 } 143 }
146 delete this; 144 delete this;
147 } 145 }
148 146
149 // Overridden from aura::WindowObserver: 147 // Overridden from aura::WindowObserver:
150 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { 148 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
151 DCHECK_EQ(window, window_); 149 DCHECK_EQ(window, window_);
152 DCHECK(layers_.empty()); 150 DCHECK(layers_.empty());
153 AcquireAllLayers(window_); 151 AcquireAllLayers(window_->layer());
154
155 // If the Widget has views with layers, then it is necessary to take
156 // ownership of those layers too.
157 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window_);
158 const views::Widget* const_widget = widget;
159 if (widget && const_widget->GetRootView() && widget->GetContentsView())
160 AcquireAllViewLayers(widget->GetContentsView());
161 window_->RemoveObserver(this); 152 window_->RemoveObserver(this);
162 window_ = NULL; 153 window_ = NULL;
163 } 154 }
164 155
165 void AcquireAllLayers(aura::Window* window) { 156 void AcquireAllLayers(ui::Layer* layer) {
166 ui::Layer* layer = window->AcquireLayer(); 157 if (layer->owner()) {
167 DCHECK(layer); 158 ui::Layer* released = layer->owner()->AcquireLayer();
168 layers_.push_back(layer); 159 DCHECK_EQ(layer, released);
169 for (aura::Window::Windows::const_iterator it = window->children().begin(); 160 layers_.push_back(released);
170 it != window->children().end(); 161 }
171 ++it) 162 std::vector<Layer*>::const_iterator it = layer->children().begin();
163 for (; it != layer->children().end(); ++it)
172 AcquireAllLayers(*it); 164 AcquireAllLayers(*it);
173 } 165 }
174 166
175 void AcquireAllViewLayers(views::View* view) {
176 for (int i = 0; i < view->child_count(); ++i)
177 AcquireAllViewLayers(view->child_at(i));
178 if (view->layer()) {
179 ui::Layer* layer = view->RecreateLayer();
180 if (layer) {
181 layer->SuppressPaint();
182 layers_.push_back(layer);
183 }
184 }
185 }
186
187 aura::Window* window_; 167 aura::Window* window_;
188 std::vector<ui::Layer*> layers_; 168 std::vector<ui::Layer*> layers_;
189 169
190 DISALLOW_COPY_AND_ASSIGN(HidingWindowAnimationObserver); 170 DISALLOW_COPY_AND_ASSIGN(HidingWindowAnimationObserver);
191 }; 171 };
192 172
193 void GetTransformRelativeToRoot(ui::Layer* layer, gfx::Transform* transform) { 173 void GetTransformRelativeToRoot(ui::Layer* layer, gfx::Transform* transform) {
194 const Layer* root = layer; 174 const Layer* root = layer;
195 while (root->parent()) 175 while (root->parent())
196 root = root->parent(); 176 root = root->parent();
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 549
570 bool WindowAnimationsDisabled(aura::Window* window) { 550 bool WindowAnimationsDisabled(aura::Window* window) {
571 return (!gfx::Animation::ShouldRenderRichAnimation() || (window && 551 return (!gfx::Animation::ShouldRenderRichAnimation() || (window &&
572 window->GetProperty(aura::client::kAnimationsDisabledKey)) || 552 window->GetProperty(aura::client::kAnimationsDisabledKey)) ||
573 CommandLine::ForCurrentProcess()->HasSwitch( 553 CommandLine::ForCurrentProcess()->HasSwitch(
574 switches::kWindowAnimationsDisabled)); 554 switches::kWindowAnimationsDisabled));
575 } 555 }
576 556
577 } // namespace corewm 557 } // namespace corewm
578 } // namespace views 558 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/DEPS ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698