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

Side by Side Diff: ui/gfx/compositor/compositor.cc

Issue 8222028: Use WebKit compositor in ui::Layer (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebase Created 9 years, 2 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/gfx/compositor/compositor.h ('k') | ui/gfx/compositor/compositor.gyp » ('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 "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 Compositor::Compositor(CompositorDelegate* delegate, const gfx::Size& size) 19 Compositor::Compositor(CompositorDelegate* delegate, const gfx::Size& size)
20 : delegate_(delegate), 20 : delegate_(delegate),
21 size_(size), 21 size_(size),
22 root_layer_(NULL) { 22 root_layer_(NULL) {
23 } 23 }
24 24
25 Compositor::~Compositor() { 25 Compositor::~Compositor() {
26 } 26 }
27 27
28 void Compositor::ScheduleDraw() {
29 delegate_->ScheduleDraw();
30 }
31
28 void Compositor::SetRootLayer(Layer* root_layer) { 32 void Compositor::SetRootLayer(Layer* root_layer) {
29 root_layer_ = root_layer; 33 root_layer_ = root_layer;
30 if (!root_layer_->GetCompositor()) 34 if (!root_layer_->GetCompositor())
31 root_layer_->SetCompositor(this); 35 root_layer_->SetCompositor(this);
36 OnRootLayerChanged();
32 } 37 }
33 38
34 void Compositor::Draw(bool force_clear) { 39 void Compositor::Draw(bool force_clear) {
35 if (!root_layer_) 40 if (!root_layer_)
36 return; 41 return;
37 42
38 NotifyStart(force_clear); 43 NotifyStart(force_clear);
39 root_layer_->DrawTree(); 44 DrawTree();
40 NotifyEnd(); 45 NotifyEnd();
41 } 46 }
42 47
43 void Compositor::AddObserver(CompositorObserver* observer) { 48 void Compositor::AddObserver(CompositorObserver* observer) {
44 observer_list_.AddObserver(observer); 49 observer_list_.AddObserver(observer);
45 } 50 }
46 51
47 void Compositor::RemoveObserver(CompositorObserver* observer) { 52 void Compositor::RemoveObserver(CompositorObserver* observer) {
48 observer_list_.RemoveObserver(observer); 53 observer_list_.RemoveObserver(observer);
49 } 54 }
50 55
51 bool Compositor::HasObserver(CompositorObserver* observer) { 56 bool Compositor::HasObserver(CompositorObserver* observer) {
52 return observer_list_.HasObserver(observer); 57 return observer_list_.HasObserver(observer);
53 } 58 }
54 59
60 void Compositor::OnRootLayerChanged() {
61 ScheduleDraw();
62 }
63
64 void Compositor::DrawTree() {
65 root_layer_->DrawTree();
66 }
67
55 void Compositor::NotifyStart(bool clear) { 68 void Compositor::NotifyStart(bool clear) {
56 OnNotifyStart(clear); 69 OnNotifyStart(clear);
57 } 70 }
58 71
59 void Compositor::NotifyEnd() { 72 void Compositor::NotifyEnd() {
60 OnNotifyEnd(); 73 OnNotifyEnd();
61 FOR_EACH_OBSERVER(CompositorObserver, 74 FOR_EACH_OBSERVER(CompositorObserver,
62 observer_list_, 75 observer_list_,
63 OnCompositingEnded(this)); 76 OnCompositingEnded(this));
64 } 77 }
65 78
66 } // namespace ui 79 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/compositor/compositor.h ('k') | ui/gfx/compositor/compositor.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698