| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "config.h" | 22 #include "config.h" |
| 23 #include "platform/transforms/TransformOperations.h" | 23 #include "platform/transforms/TransformOperations.h" |
| 24 | 24 |
| 25 #include "platform/animation/AnimationUtilities.h" | 25 #include "platform/animation/AnimationUtilities.h" |
| 26 #include "platform/geometry/FloatBox.h" | 26 #include "platform/geometry/FloatBox.h" |
| 27 #include "platform/transforms/IdentityTransformOperation.h" | 27 #include "platform/transforms/IdentityTransformOperation.h" |
| 28 #include "platform/transforms/InterpolatedTransformOperation.h" | 28 #include "platform/transforms/InterpolatedTransformOperation.h" |
| 29 #include "platform/transforms/RotateTransformOperation.h" | 29 #include "platform/transforms/RotateTransformOperation.h" |
| 30 #include <algorithm> | 30 #include <algorithm> |
| 31 | 31 |
| 32 using namespace std; | |
| 33 | |
| 34 namespace blink { | 32 namespace blink { |
| 35 | 33 |
| 36 TransformOperations::TransformOperations(bool makeIdentity) | 34 TransformOperations::TransformOperations(bool makeIdentity) |
| 37 { | 35 { |
| 38 if (makeIdentity) | 36 if (makeIdentity) |
| 39 m_operations.append(IdentityTransformOperation::create()); | 37 m_operations.append(IdentityTransformOperation::create()); |
| 40 } | 38 } |
| 41 | 39 |
| 42 bool TransformOperations::operator==(const TransformOperations& o) const | 40 bool TransformOperations::operator==(const TransformOperations& o) const |
| 43 { | 41 { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 67 } | 65 } |
| 68 return true; | 66 return true; |
| 69 } | 67 } |
| 70 | 68 |
| 71 TransformOperations TransformOperations::blendByMatchingOperations(const Transfo
rmOperations& from, const double& progress) const | 69 TransformOperations TransformOperations::blendByMatchingOperations(const Transfo
rmOperations& from, const double& progress) const |
| 72 { | 70 { |
| 73 TransformOperations result; | 71 TransformOperations result; |
| 74 | 72 |
| 75 unsigned fromSize = from.operations().size(); | 73 unsigned fromSize = from.operations().size(); |
| 76 unsigned toSize = operations().size(); | 74 unsigned toSize = operations().size(); |
| 77 unsigned size = max(fromSize, toSize); | 75 unsigned size = std::max(fromSize, toSize); |
| 78 for (unsigned i = 0; i < size; i++) { | 76 for (unsigned i = 0; i < size; i++) { |
| 79 RefPtr<TransformOperation> fromOperation = (i < fromSize) ? from.operati
ons()[i].get() : 0; | 77 RefPtr<TransformOperation> fromOperation = (i < fromSize) ? from.operati
ons()[i].get() : 0; |
| 80 RefPtr<TransformOperation> toOperation = (i < toSize) ? operations()[i].
get() : 0; | 78 RefPtr<TransformOperation> toOperation = (i < toSize) ? operations()[i].
get() : 0; |
| 81 RefPtr<TransformOperation> blendedOperation = toOperation ? toOperation-
>blend(fromOperation.get(), progress) : (fromOperation ? fromOperation->blend(0,
progress, true) : nullptr); | 79 RefPtr<TransformOperation> blendedOperation = toOperation ? toOperation-
>blend(fromOperation.get(), progress) : (fromOperation ? fromOperation->blend(0,
progress, true) : nullptr); |
| 82 if (blendedOperation) | 80 if (blendedOperation) |
| 83 result.operations().append(blendedOperation); | 81 result.operations().append(blendedOperation); |
| 84 else { | 82 else { |
| 85 RefPtr<TransformOperation> identityOperation = IdentityTransformOper
ation::create(); | 83 RefPtr<TransformOperation> identityOperation = IdentityTransformOper
ation::create(); |
| 86 if (progress > 0.5) | 84 if (progress > 0.5) |
| 87 result.operations().append(toOperation ? toOperation : identityO
peration); | 85 result.operations().append(toOperation ? toOperation : identityO
peration); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 rotation.rotate3d(axis.x(), axis.y(), axis.z(), rad2deg(radians)); | 234 rotation.rotate3d(axis.x(), axis.y(), axis.z(), rad2deg(radians)); |
| 237 box.expandTo(rotation.mapPoint(point)); | 235 box.expandTo(rotation.mapPoint(point)); |
| 238 } | 236 } |
| 239 } | 237 } |
| 240 | 238 |
| 241 bool TransformOperations::blendedBoundsForBox(const FloatBox& box, const Transfo
rmOperations& from, const double& minProgress, const double& maxProgress, FloatB
ox* bounds) const | 239 bool TransformOperations::blendedBoundsForBox(const FloatBox& box, const Transfo
rmOperations& from, const double& minProgress, const double& maxProgress, FloatB
ox* bounds) const |
| 242 { | 240 { |
| 243 | 241 |
| 244 int fromSize = from.operations().size(); | 242 int fromSize = from.operations().size(); |
| 245 int toSize = operations().size(); | 243 int toSize = operations().size(); |
| 246 int size = max(fromSize, toSize); | 244 int size = std::max(fromSize, toSize); |
| 247 | 245 |
| 248 *bounds = box; | 246 *bounds = box; |
| 249 for (int i = size - 1; i >= 0; i--) { | 247 for (int i = size - 1; i >= 0; i--) { |
| 250 RefPtr<TransformOperation> fromOperation = (i < fromSize) ? from.operati
ons()[i] : nullptr; | 248 RefPtr<TransformOperation> fromOperation = (i < fromSize) ? from.operati
ons()[i] : nullptr; |
| 251 RefPtr<TransformOperation> toOperation = (i < toSize) ? operations()[i]
: nullptr; | 249 RefPtr<TransformOperation> toOperation = (i < toSize) ? operations()[i]
: nullptr; |
| 252 if (fromOperation && fromOperation->type() == TransformOperation::None) | 250 if (fromOperation && fromOperation->type() == TransformOperation::None) |
| 253 fromOperation = nullptr; | 251 fromOperation = nullptr; |
| 254 | 252 |
| 255 if (toOperation && toOperation->type() == TransformOperation::None) | 253 if (toOperation && toOperation->type() == TransformOperation::None) |
| 256 toOperation = nullptr; | 254 toOperation = nullptr; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 373 |
| 376 TransformOperations TransformOperations::add(const TransformOperations& addend)
const | 374 TransformOperations TransformOperations::add(const TransformOperations& addend)
const |
| 377 { | 375 { |
| 378 TransformOperations result; | 376 TransformOperations result; |
| 379 result.m_operations = operations(); | 377 result.m_operations = operations(); |
| 380 result.m_operations.appendVector(addend.operations()); | 378 result.m_operations.appendVector(addend.operations()); |
| 381 return result; | 379 return result; |
| 382 } | 380 } |
| 383 | 381 |
| 384 } // namespace blink | 382 } // namespace blink |
| OLD | NEW |