| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <ctime> | 8 #include <ctime> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 duration_ms); | 220 duration_ms); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void RealCompositor::Actor::SetTilt(double tilt, int duration_ms) { | 223 void RealCompositor::Actor::SetTilt(double tilt, int duration_ms) { |
| 224 AnimateField(&float_animations_, &tilt_, | 224 AnimateField(&float_animations_, &tilt_, |
| 225 static_cast<float>(tilt), | 225 static_cast<float>(tilt), |
| 226 duration_ms); | 226 duration_ms); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void RealCompositor::Actor::Raise(Compositor::Actor* other) { | 229 void RealCompositor::Actor::Raise(Compositor::Actor* other) { |
| 230 CHECK(parent_) << "Tried to raise an actor that has no parent."; | 230 CHECK(parent_) << "Raising actor " << this << ", which has no parent"; |
| 231 if (other == this) { |
| 232 LOG(DFATAL) << "Got request to raise actor " << this << " above itself"; |
| 233 return; |
| 234 } |
| 231 RealCompositor::Actor* other_nc = | 235 RealCompositor::Actor* other_nc = |
| 232 dynamic_cast<RealCompositor::Actor*>(other); | 236 dynamic_cast<RealCompositor::Actor*>(other); |
| 233 CHECK(other_nc) << "Failed to cast to an Actor in Raise"; | 237 CHECK(other_nc) << "Failed to cast " << other << " to an Actor in Raise()"; |
| 234 parent_->RaiseChild(this, other_nc); | 238 parent_->RaiseChild(this, other_nc); |
| 235 SetDirty(); | 239 SetDirty(); |
| 236 } | 240 } |
| 237 | 241 |
| 238 void RealCompositor::Actor::Lower(Compositor::Actor* other) { | 242 void RealCompositor::Actor::Lower(Compositor::Actor* other) { |
| 239 CHECK(parent_) << "Tried to lower an actor that has no parent."; | 243 CHECK(parent_) << "Lowering actor " << this << ", which has no parent"; |
| 244 if (other == this) { |
| 245 LOG(DFATAL) << "Got request to lower actor " << this << " below itself"; |
| 246 return; |
| 247 } |
| 240 RealCompositor::Actor* other_nc = | 248 RealCompositor::Actor* other_nc = |
| 241 dynamic_cast<RealCompositor::Actor*>(other); | 249 dynamic_cast<RealCompositor::Actor*>(other); |
| 242 CHECK(other_nc) << "Failed to cast to an Actor in Lower"; | 250 CHECK(other_nc) << "Failed to cast " << other << " to an Actor in Lower()"; |
| 243 parent_->LowerChild(this, other_nc); | 251 parent_->LowerChild(this, other_nc); |
| 244 SetDirty(); | 252 SetDirty(); |
| 245 } | 253 } |
| 246 | 254 |
| 247 void RealCompositor::Actor::RaiseToTop() { | 255 void RealCompositor::Actor::RaiseToTop() { |
| 248 CHECK(parent_) << "Tried to raise an actor to top that has no parent."; | 256 CHECK(parent_) << "Raising actor " << this << ", which has no parent, to top"; |
| 249 parent_->RaiseChild(this, NULL); | 257 parent_->RaiseChild(this, NULL); |
| 250 SetDirty(); | 258 SetDirty(); |
| 251 } | 259 } |
| 252 | 260 |
| 253 void RealCompositor::Actor::LowerToBottom() { | 261 void RealCompositor::Actor::LowerToBottom() { |
| 254 CHECK(parent_) << "Tried to lower an actor to bottom that has no parent."; | 262 CHECK(parent_) << "Lowering actor " << this << ", which has no parent, " |
| 263 << "to bottom"; |
| 255 parent_->LowerChild(this, NULL); | 264 parent_->LowerChild(this, NULL); |
| 256 SetDirty(); | 265 SetDirty(); |
| 257 } | 266 } |
| 258 | 267 |
| 259 string RealCompositor::Actor::GetDebugStringInternal(const string& type_name, | 268 string RealCompositor::Actor::GetDebugStringInternal(const string& type_name, |
| 260 int indent_level) { | 269 int indent_level) { |
| 261 string out; | 270 string out; |
| 262 for (int i = 0; i < indent_level; ++i) | 271 out.assign(indent_level * 2, ' '); |
| 263 out += " "; | |
| 264 | |
| 265 out += StringPrintf("\"%s\" %p (%s%s) (%d, %d) %dx%d " | 272 out += StringPrintf("\"%s\" %p (%s%s) (%d, %d) %dx%d " |
| 266 "scale=(%.2f, %.2f) %.2f%% tilt=%0.2f\n", | 273 "scale=(%.2f, %.2f) %.2f%% tilt=%0.2f\n", |
| 267 !name_.empty() ? name_.c_str() : "", | 274 !name_.empty() ? name_.c_str() : "", |
| 268 this, | 275 this, |
| 269 visible_ ? "" : "inv ", | 276 visible_ ? "" : "inv ", |
| 270 type_name.c_str(), | 277 type_name.c_str(), |
| 271 x_, y_, | 278 x_, y_, |
| 272 width_, height_, | 279 width_, height_, |
| 273 scale_x_, scale_y_, | 280 scale_x_, scale_y_, |
| 274 opacity_, | 281 opacity_, |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 } | 778 } |
| 772 | 779 |
| 773 void RealCompositor::DisableDrawTimeout() { | 780 void RealCompositor::DisableDrawTimeout() { |
| 774 if (draw_timeout_enabled_) { | 781 if (draw_timeout_enabled_) { |
| 775 event_loop_->SuspendTimeout(draw_timeout_id_); | 782 event_loop_->SuspendTimeout(draw_timeout_id_); |
| 776 draw_timeout_enabled_ = false; | 783 draw_timeout_enabled_ = false; |
| 777 } | 784 } |
| 778 } | 785 } |
| 779 | 786 |
| 780 } // namespace window_manager | 787 } // namespace window_manager |
| OLD | NEW |