WebOverlayOverride.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (C) 2012 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 "WebOverlayOverride.h"
  20. #if USE(ACCELERATED_COMPOSITING)
  21. #include "WebAnimation.h"
  22. #include "WebAnimation_p.h"
  23. #include "WebOverlay_p.h"
  24. #include <BlackBerryPlatformMessageClient.h>
  25. #include <BlackBerryPlatformString.h>
  26. #include <wtf/CurrentTime.h>
  27. namespace BlackBerry {
  28. namespace WebKit {
  29. using namespace WebCore;
  30. WebOverlayOverride::WebOverlayOverride(WebOverlayPrivate* d)
  31. : d(d)
  32. {
  33. }
  34. WebOverlayOverride::~WebOverlayOverride()
  35. {
  36. }
  37. void WebOverlayOverride::setPosition(const Platform::FloatPoint& position)
  38. {
  39. d->layerCompositingThread()->override()->setPosition(position);
  40. d->scheduleCompositingRun();
  41. }
  42. void WebOverlayOverride::setAnchorPoint(const Platform::FloatPoint& anchor)
  43. {
  44. d->layerCompositingThread()->override()->setAnchorPoint(anchor);
  45. d->scheduleCompositingRun();
  46. }
  47. void WebOverlayOverride::setSize(const Platform::FloatSize& size)
  48. {
  49. d->layerCompositingThread()->override()->setBounds(IntSize(size.width(), size.height()));
  50. d->scheduleCompositingRun();
  51. }
  52. void WebOverlayOverride::setTransform(const Platform::TransformationMatrix& transform)
  53. {
  54. d->layerCompositingThread()->override()->setTransform(reinterpret_cast<const TransformationMatrix&>(transform));
  55. d->scheduleCompositingRun();
  56. }
  57. void WebOverlayOverride::setOpacity(float opacity)
  58. {
  59. d->layerCompositingThread()->override()->setOpacity(opacity);
  60. d->scheduleCompositingRun();
  61. }
  62. void WebOverlayOverride::addAnimation(const WebAnimation& animation)
  63. {
  64. LayerCompositingThread* layerCompositingThread = d->layerCompositingThread();
  65. LayerOverride* override = layerCompositingThread->override();
  66. IntSize boxSize = override->isBoundsSet() ? override->bounds() : layerCompositingThread->bounds();
  67. RefPtr<LayerAnimation> layerAnimation = LayerAnimation::create(animation.d->keyframes, boxSize, animation.d->animation.get(), animation.d->name, 0.0);
  68. layerAnimation->setStartTime(currentTime());
  69. override->addAnimation(layerAnimation);
  70. d->scheduleCompositingRun();
  71. }
  72. void WebOverlayOverride::removeAnimation(const BlackBerry::Platform::String& name)
  73. {
  74. d->layerCompositingThread()->override()->removeAnimation(name);
  75. d->scheduleCompositingRun();
  76. }
  77. }
  78. }
  79. #else // USE(ACCELERATED_COMPOSITING)
  80. namespace BlackBerry {
  81. namespace WebKit {
  82. WebOverlayOverride::WebOverlayOverride(WebOverlayPrivate*, bool)
  83. {
  84. }
  85. WebOverlayOverride::~WebOverlayOverride()
  86. {
  87. }
  88. void WebOverlayOverride::setPosition(const Platform::FloatPoint&)
  89. {
  90. }
  91. void WebOverlayOverride::setAnchorPoint(const Platform::FloatPoint&)
  92. {
  93. }
  94. void WebOverlayOverride::setSize(const Platform::FloatSize&)
  95. {
  96. }
  97. void WebOverlayOverride::setTransform(const Platform::TransformationMatrix&)
  98. {
  99. }
  100. void WebOverlayOverride::setOpacity(float)
  101. {
  102. }
  103. void WebOverlayOverride::addAnimation(const WebAnimation&)
  104. {
  105. }
  106. void WebOverlayOverride::removeAnimation(const BlackBerry::Platform::String&)
  107. {
  108. }
  109. }
  110. }
  111. #endif // USE(ACCELERATED_COMPOSITING)