WebAnimation.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "config.h"
  19. #include "WebAnimation.h"
  20. #if USE(ACCELERATED_COMPOSITING)
  21. #include "GraphicsLayer.h"
  22. #include "LayerCompositingThread.h"
  23. #include "LayerWebKitThread.h"
  24. #include "ScaleTransformOperation.h"
  25. #include "WebAnimation_p.h"
  26. #include <BlackBerryPlatformMessageClient.h>
  27. #include <BlackBerryPlatformString.h>
  28. namespace BlackBerry {
  29. namespace WebKit {
  30. using namespace WebCore;
  31. WebAnimation WebAnimation::fadeAnimation(const BlackBerry::Platform::String& name, float from, float to, double duration)
  32. {
  33. WebAnimation tmp;
  34. tmp.d->name = name;
  35. tmp.d->animation = Animation::create();
  36. tmp.d->animation->setDuration(duration);
  37. tmp.d->keyframes = KeyframeValueList(AnimatedPropertyOpacity);
  38. tmp.d->keyframes.insert(new FloatAnimationValue(0, from));
  39. tmp.d->keyframes.insert(new FloatAnimationValue(1.0, to));
  40. return tmp;
  41. }
  42. WebAnimation WebAnimation::shrinkAnimation(const BlackBerry::Platform::String& name, float from, float to, double duration)
  43. {
  44. WebAnimation tmp;
  45. tmp.d->name = name;
  46. tmp.d->animation = Animation::create();
  47. tmp.d->animation->setDuration(duration);
  48. tmp.d->keyframes = KeyframeValueList(AnimatedPropertyWebkitTransform);
  49. TransformOperations startOperation;
  50. startOperation.operations().append(ScaleTransformOperation::create(from, from, TransformOperation::SCALE));
  51. tmp.d->keyframes.insert(new TransformAnimationValue(0, &startOperation));
  52. TransformOperations endOperation;
  53. endOperation.operations().append(ScaleTransformOperation::create(to, to, TransformOperation::SCALE));
  54. tmp.d->keyframes.insert(new TransformAnimationValue(1.0, &endOperation));
  55. return tmp;
  56. }
  57. BlackBerry::Platform::String WebAnimation::name() const
  58. {
  59. return d->name;
  60. }
  61. WebAnimation::WebAnimation()
  62. : d(new WebAnimationPrivate)
  63. {
  64. }
  65. WebAnimation::WebAnimation(const WebAnimation& o)
  66. : d(new WebAnimationPrivate)
  67. {
  68. *d = *o.d;
  69. }
  70. WebAnimation::~WebAnimation()
  71. {
  72. delete d;
  73. }
  74. WebAnimation& WebAnimation::operator=(const WebAnimation& o)
  75. {
  76. if (&o != this)
  77. *d = *o.d;
  78. return *this;
  79. }
  80. } // namespace WebKit
  81. } // namespace BlackBerry
  82. #endif // USE(ACCELERATED_COMPOSITING)