OLD | NEW |
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 "ui/gfx/compositor/compositor.h" | 5 #include "ui/gfx/compositor/compositor.h" |
6 | 6 |
7 #include "ui/gfx/compositor/compositor_observer.h" | 7 #include "ui/gfx/compositor/compositor_observer.h" |
8 #include "ui/gfx/compositor/layer.h" | 8 #include "ui/gfx/compositor/layer.h" |
9 | 9 |
10 namespace ui { | 10 namespace ui { |
11 | 11 |
12 TextureDrawParams::TextureDrawParams() | 12 TextureDrawParams::TextureDrawParams() |
13 : blend(false), | 13 : blend(false), |
14 has_valid_alpha_channel(false), | 14 has_valid_alpha_channel(false), |
15 opacity(1.0f), | 15 opacity(1.0f), |
16 vertically_flipped(false) { | 16 vertically_flipped(false) { |
17 } | 17 } |
18 | 18 |
19 // static | 19 // static |
20 Compositor*(*Compositor::compositor_factory_)(CompositorDelegate*) = NULL; | 20 Compositor*(*Compositor::compositor_factory_)(CompositorDelegate*) = NULL; |
21 | 21 |
22 Compositor::Compositor(CompositorDelegate* delegate, const gfx::Size& size) | 22 Compositor::Compositor(CompositorDelegate* delegate, const gfx::Size& size) |
23 : delegate_(delegate), | 23 : delegate_(delegate), |
24 size_(size), | 24 size_(size), |
25 root_layer_(NULL) { | 25 root_layer_(NULL) { |
26 } | 26 } |
27 | 27 |
28 Compositor::~Compositor() { | 28 Compositor::~Compositor() { |
| 29 if (root_layer_) |
| 30 root_layer_->SetCompositor(NULL); |
29 } | 31 } |
30 | 32 |
31 void Compositor::ScheduleDraw() { | 33 void Compositor::ScheduleDraw() { |
32 delegate_->ScheduleDraw(); | 34 delegate_->ScheduleDraw(); |
33 } | 35 } |
34 | 36 |
35 void Compositor::SetRootLayer(Layer* root_layer) { | 37 void Compositor::SetRootLayer(Layer* root_layer) { |
| 38 if (root_layer_) |
| 39 root_layer_->SetCompositor(NULL); |
36 root_layer_ = root_layer; | 40 root_layer_ = root_layer; |
37 if (!root_layer_->GetCompositor()) | 41 if (root_layer_ && !root_layer_->GetCompositor()) |
38 root_layer_->SetCompositor(this); | 42 root_layer_->SetCompositor(this); |
39 OnRootLayerChanged(); | 43 OnRootLayerChanged(); |
40 } | 44 } |
41 | 45 |
42 void Compositor::Draw(bool force_clear) { | 46 void Compositor::Draw(bool force_clear) { |
43 if (!root_layer_) | 47 if (!root_layer_) |
44 return; | 48 return; |
45 | 49 |
46 NotifyStart(force_clear); | 50 NotifyStart(force_clear); |
47 DrawTree(); | 51 DrawTree(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 100 } |
97 | 101 |
98 void Compositor::NotifyEnd() { | 102 void Compositor::NotifyEnd() { |
99 OnNotifyEnd(); | 103 OnNotifyEnd(); |
100 FOR_EACH_OBSERVER(CompositorObserver, | 104 FOR_EACH_OBSERVER(CompositorObserver, |
101 observer_list_, | 105 observer_list_, |
102 OnCompositingEnded(this)); | 106 OnCompositingEnded(this)); |
103 } | 107 } |
104 | 108 |
105 } // namespace ui | 109 } // namespace ui |
OLD | NEW |