| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 "window_manager/compositor.h" | 5 #include "window_manager/compositor.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "window_manager/util.h" | 8 #include "window_manager/util.h" |
| 9 #include "window_manager/x_connection.h" | 9 #include "window_manager/x_connection.h" |
| 10 | 10 |
| 11 using std::list; | 11 using std::list; |
| 12 using std::string; |
| 12 | 13 |
| 13 namespace window_manager { | 14 namespace window_manager { |
| 14 | 15 |
| 15 MockCompositor::Actor::~Actor() { | 16 MockCompositor::Actor::~Actor() { |
| 16 if (parent_) { | 17 if (parent_) { |
| 17 parent_->stacked_children()->Remove(this); | 18 parent_->stacked_children()->Remove(this); |
| 18 parent_ = NULL; | 19 parent_ = NULL; |
| 19 } | 20 } |
| 20 } | 21 } |
| 21 | 22 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 50 parent_->stacked_children()->AddOnTop(this); | 51 parent_->stacked_children()->AddOnTop(this); |
| 51 } | 52 } |
| 52 | 53 |
| 53 void MockCompositor::Actor::LowerToBottom() { | 54 void MockCompositor::Actor::LowerToBottom() { |
| 54 CHECK(parent_); | 55 CHECK(parent_); |
| 55 CHECK(parent_->stacked_children()->Contains(this)); | 56 CHECK(parent_->stacked_children()->Contains(this)); |
| 56 parent_->stacked_children()->Remove(this); | 57 parent_->stacked_children()->Remove(this); |
| 57 parent_->stacked_children()->AddOnBottom(this); | 58 parent_->stacked_children()->AddOnBottom(this); |
| 58 } | 59 } |
| 59 | 60 |
| 61 string MockCompositor::Actor::GetDebugString(int indent_level) { |
| 62 string out; |
| 63 out.assign(indent_level * 2, ' '); |
| 64 out += (!name_.empty() ? name_ : "unnamed actor") + "\n"; |
| 65 return out; |
| 66 } |
| 67 |
| 60 | 68 |
| 61 MockCompositor::ContainerActor::ContainerActor() | 69 MockCompositor::ContainerActor::ContainerActor() |
| 62 : stacked_children_(new Stacker<Actor*>) { | 70 : stacked_children_(new Stacker<Actor*>) { |
| 63 } | 71 } |
| 64 | 72 |
| 65 MockCompositor::ContainerActor::~ContainerActor() { | 73 MockCompositor::ContainerActor::~ContainerActor() { |
| 66 typedef list<Actor*>::const_iterator iterator; | 74 typedef list<Actor*>::const_iterator iterator; |
| 67 | 75 |
| 68 for (iterator it = stacked_children_->items().begin(); | 76 for (iterator it = stacked_children_->items().begin(); |
| 69 it != stacked_children_->items().end(); ++it) { | 77 it != stacked_children_->items().end(); ++it) { |
| 70 (*it)->set_parent(NULL); | 78 (*it)->set_parent(NULL); |
| 71 } | 79 } |
| 72 } | 80 } |
| 73 | 81 |
| 82 string MockCompositor::ContainerActor::GetDebugString(int indent_level) { |
| 83 string out = Actor::GetDebugString(indent_level); |
| 84 for (list<Actor*>::const_iterator it = stacked_children_->items().begin(); |
| 85 it != stacked_children_->items().end(); ++it) { |
| 86 out += (*it)->GetDebugString(indent_level + 1); |
| 87 } |
| 88 return out; |
| 89 } |
| 90 |
| 74 void MockCompositor::ContainerActor::AddActor(Compositor::Actor* actor) { | 91 void MockCompositor::ContainerActor::AddActor(Compositor::Actor* actor) { |
| 75 MockCompositor::Actor* cast_actor = | 92 MockCompositor::Actor* cast_actor = |
| 76 dynamic_cast<MockCompositor::Actor*>(actor); | 93 dynamic_cast<MockCompositor::Actor*>(actor); |
| 77 CHECK(cast_actor); | 94 CHECK(cast_actor); |
| 78 CHECK(cast_actor->parent() == static_cast<ContainerActor*>(NULL)); | 95 CHECK(cast_actor->parent() == static_cast<ContainerActor*>(NULL)); |
| 79 cast_actor->set_parent(this); | 96 cast_actor->set_parent(this); |
| 80 CHECK(!stacked_children_->Contains(cast_actor)); | 97 CHECK(!stacked_children_->Contains(cast_actor)); |
| 81 stacked_children_->AddOnTop(cast_actor); | 98 stacked_children_->AddOnTop(cast_actor); |
| 82 } | 99 } |
| 83 | 100 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 98 memcpy(alpha_mask_bytes_, bytes, size); | 115 memcpy(alpha_mask_bytes_, bytes, size); |
| 99 return true; | 116 return true; |
| 100 } | 117 } |
| 101 | 118 |
| 102 void MockCompositor::TexturePixmapActor::ClearAlphaMask() { | 119 void MockCompositor::TexturePixmapActor::ClearAlphaMask() { |
| 103 delete[] alpha_mask_bytes_; | 120 delete[] alpha_mask_bytes_; |
| 104 alpha_mask_bytes_ = NULL; | 121 alpha_mask_bytes_ = NULL; |
| 105 } | 122 } |
| 106 | 123 |
| 107 } // namespace window_manager | 124 } // namespace window_manager |
| OLD | NEW |