WebOverlay.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  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 "WebOverlay.h"
  20. #if USE(ACCELERATED_COMPOSITING)
  21. #include "LayerWebKitThread.h"
  22. #include "NotImplemented.h"
  23. #include "TextureCacheCompositingThread.h"
  24. #include "WebAnimation.h"
  25. #include "WebAnimation_p.h"
  26. #include "WebOverlayClient.h"
  27. #include "WebOverlayOverride.h"
  28. #include "WebOverlay_p.h"
  29. #include "WebPageCompositorClient.h"
  30. #include "WebPageCompositor_p.h"
  31. #include "WebPage_p.h"
  32. #include <BlackBerryPlatformGraphicsContext.h>
  33. #include <BlackBerryPlatformMessageClient.h>
  34. #include <BlackBerryPlatformString.h>
  35. #include <GLES2/gl2.h>
  36. using namespace WebCore;
  37. using BlackBerry::Platform::Graphics::GLES2Program;
  38. namespace BlackBerry {
  39. namespace WebKit {
  40. WebOverlay::WebOverlay()
  41. : d(0)
  42. {
  43. if (Platform::webKitThreadMessageClient()->isCurrentThread()) {
  44. d = new WebOverlayPrivateWebKitThread;
  45. d->q = this;
  46. } else if (Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
  47. d = new WebOverlayPrivateCompositingThread;
  48. d->q = this;
  49. }
  50. }
  51. WebOverlay::WebOverlay(GraphicsLayerClient* client)
  52. : d(0)
  53. {
  54. d = new WebOverlayPrivateWebKitThread(client);
  55. d->q = this;
  56. }
  57. WebOverlay::~WebOverlay()
  58. {
  59. delete d;
  60. }
  61. Platform::FloatPoint WebOverlay::position() const
  62. {
  63. return d->position();
  64. }
  65. void WebOverlay::setPosition(const Platform::FloatPoint& position)
  66. {
  67. d->setPosition(position);
  68. }
  69. Platform::FloatPoint WebOverlay::anchorPoint() const
  70. {
  71. return d->anchorPoint();
  72. }
  73. void WebOverlay::setAnchorPoint(const Platform::FloatPoint& anchor)
  74. {
  75. d->setAnchorPoint(anchor);
  76. }
  77. Platform::FloatSize WebOverlay::size() const
  78. {
  79. return d->size();
  80. }
  81. void WebOverlay::setSize(const Platform::FloatSize& size)
  82. {
  83. d->setSize(size);
  84. }
  85. bool WebOverlay::sizeIsScaleInvariant() const
  86. {
  87. return d->sizeIsScaleInvariant();
  88. }
  89. void WebOverlay::setSizeIsScaleInvariant(bool invariant)
  90. {
  91. d->setSizeIsScaleInvariant(invariant);
  92. }
  93. Platform::TransformationMatrix WebOverlay::transform() const
  94. {
  95. // FIXME: There is no WebCore::TranformationMatrix interoperability
  96. // with Platform::TransformationMatrix
  97. TransformationMatrix transform = d->transform();
  98. return reinterpret_cast<const Platform::TransformationMatrix&>(transform);
  99. }
  100. void WebOverlay::setTransform(const Platform::TransformationMatrix& transform)
  101. {
  102. d->setTransform(reinterpret_cast<const TransformationMatrix&>(transform));
  103. }
  104. float WebOverlay::opacity() const
  105. {
  106. return d->opacity();
  107. }
  108. void WebOverlay::setOpacity(float opacity)
  109. {
  110. d->setOpacity(opacity);
  111. }
  112. void WebOverlay::addAnimation(const WebAnimation& animation)
  113. {
  114. d->addAnimation(animation.d->name, animation.d->animation.get(), animation.d->keyframes);
  115. }
  116. void WebOverlay::removeAnimation(const BlackBerry::Platform::String& name)
  117. {
  118. d->removeAnimation(name);
  119. }
  120. Platform::IntRect WebOverlay::pixelViewportRect() const
  121. {
  122. return d->pixelViewportRect();
  123. }
  124. WebOverlay* WebOverlay::parent() const
  125. {
  126. return d->parent;
  127. }
  128. bool WebOverlay::addChild(WebOverlay* overlay)
  129. {
  130. if (overlay->d->nativeThread != d->nativeThread)
  131. return false;
  132. overlay->d->parent = this;
  133. d->addChild(overlay->d);
  134. return true;
  135. }
  136. void WebOverlay::removeFromParent()
  137. {
  138. d->removeFromParent();
  139. d->parent = 0;
  140. }
  141. void WebOverlay::setContentsToImage(const unsigned char* data, const Platform::IntSize& imageSize, ImageDataAdoptionType adoptionType)
  142. {
  143. d->setContentsToImage(data, imageSize, adoptionType);
  144. }
  145. void WebOverlay::setContentsToColor(int r, int g, int b, int a)
  146. {
  147. d->setContentsToColor(Color(r, g, b, a));
  148. }
  149. void WebOverlay::setDrawsContent(bool drawsContent)
  150. {
  151. d->setDrawsContent(drawsContent);
  152. }
  153. void WebOverlay::invalidate()
  154. {
  155. d->invalidate();
  156. }
  157. void WebOverlay::setClient(WebOverlayClient* client)
  158. {
  159. d->setClient(client);
  160. }
  161. WebOverlayOverride* WebOverlay::override()
  162. {
  163. // Must be called on UI thread
  164. if (!Platform::userInterfaceThreadMessageClient()->isCurrentThread())
  165. return 0;
  166. return d->override();
  167. }
  168. void WebOverlay::resetOverrides()
  169. {
  170. d->resetOverrides();
  171. }
  172. WebPagePrivate* WebOverlayPrivate::page() const
  173. {
  174. if (m_page)
  175. return m_page;
  176. if (parent)
  177. return parent->d->page();
  178. return 0;
  179. }
  180. WebOverlayOverride* WebOverlayPrivate::override()
  181. {
  182. if (!m_override)
  183. m_override = adoptPtr(new WebOverlayOverride(this));
  184. // Page might have changed if we were removed from the page and added to
  185. // some other page.
  186. m_override->d->setPage(page());
  187. return m_override.get();
  188. }
  189. void WebOverlayPrivate::drawContents(Platform::Graphics::Drawable* drawable)
  190. {
  191. if (!client)
  192. return;
  193. client->drawOverlayContents(q, drawable);
  194. }
  195. void WebOverlayPrivate::scheduleCompositingRun()
  196. {
  197. if (!page())
  198. return;
  199. page()->scheduleCompositingRun();
  200. }
  201. WebOverlayPrivateWebKitThread::WebOverlayPrivateWebKitThread(GraphicsLayerClient* client)
  202. : m_layer(GraphicsLayer::create(client ? client : this))
  203. {
  204. m_layerCompositingThread = m_layer->platformLayer()->layerCompositingThread();
  205. }
  206. FloatPoint WebOverlayPrivateWebKitThread::position() const
  207. {
  208. return m_layer->position();
  209. }
  210. void WebOverlayPrivateWebKitThread::setPosition(const FloatPoint& position)
  211. {
  212. m_layer->setPosition(position);
  213. }
  214. FloatPoint WebOverlayPrivateWebKitThread::anchorPoint() const
  215. {
  216. FloatPoint3D anchor = m_layer->anchorPoint();
  217. return FloatPoint(anchor.x(), anchor.y());
  218. }
  219. void WebOverlayPrivateWebKitThread::setAnchorPoint(const FloatPoint& anchor)
  220. {
  221. m_layer->setAnchorPoint(FloatPoint3D(anchor.x(), anchor.y(), 0));
  222. }
  223. FloatSize WebOverlayPrivateWebKitThread::size() const
  224. {
  225. return m_layer->size();
  226. }
  227. void WebOverlayPrivateWebKitThread::setSize(const FloatSize& size)
  228. {
  229. m_layer->setSize(size);
  230. }
  231. bool WebOverlayPrivateWebKitThread::sizeIsScaleInvariant() const
  232. {
  233. return m_layer->platformLayer()->sizeIsScaleInvariant();
  234. }
  235. void WebOverlayPrivateWebKitThread::setSizeIsScaleInvariant(bool invariant)
  236. {
  237. m_layer->platformLayer()->setSizeIsScaleInvariant(invariant);
  238. }
  239. TransformationMatrix WebOverlayPrivateWebKitThread::transform() const
  240. {
  241. return m_layer->transform();
  242. }
  243. void WebOverlayPrivateWebKitThread::setTransform(const TransformationMatrix& transform)
  244. {
  245. m_layer->setTransform(transform);
  246. }
  247. float WebOverlayPrivateWebKitThread::opacity() const
  248. {
  249. return m_layer->opacity();
  250. }
  251. void WebOverlayPrivateWebKitThread::setOpacity(float opacity)
  252. {
  253. m_layer->setOpacity(opacity);
  254. }
  255. void WebOverlayPrivateWebKitThread::addAnimation(const String& name, Animation* animation, const KeyframeValueList& keyframes)
  256. {
  257. IntSize size(m_layer->size().width(), m_layer->size().height());
  258. m_layer->addAnimation(keyframes, size, animation, name, 0);
  259. }
  260. void WebOverlayPrivateWebKitThread::removeAnimation(const String& name)
  261. {
  262. m_layer->removeAnimation(name);
  263. }
  264. Platform::IntRect WebOverlayPrivateWebKitThread::pixelViewportRect() const
  265. {
  266. notImplemented();
  267. return Platform::IntRect();
  268. }
  269. void WebOverlayPrivateWebKitThread::addChild(WebOverlayPrivate* overlay)
  270. {
  271. m_layer->addChild(static_cast<WebOverlayPrivateWebKitThread*>(overlay)->m_layer.get());
  272. }
  273. void WebOverlayPrivateWebKitThread::removeFromParent()
  274. {
  275. m_layer->removeFromParent();
  276. }
  277. void WebOverlayPrivateWebKitThread::setContentsToImage(const unsigned char*, const WebCore::IntSize&, WebOverlay::ImageDataAdoptionType)
  278. {
  279. notImplemented();
  280. }
  281. void WebOverlayPrivateWebKitThread::setContentsToColor(const Color&)
  282. {
  283. notImplemented();
  284. }
  285. void WebOverlayPrivateWebKitThread::setDrawsContent(bool drawsContent)
  286. {
  287. m_layer->setDrawsContent(drawsContent);
  288. }
  289. void WebOverlayPrivateWebKitThread::clear()
  290. {
  291. setSize(FloatSize(0, 0));
  292. }
  293. void WebOverlayPrivateWebKitThread::invalidate()
  294. {
  295. m_layer->setNeedsDisplay();
  296. }
  297. void WebOverlayPrivateWebKitThread::resetOverrides()
  298. {
  299. if (Platform::webKitThreadMessageClient()->isCurrentThread())
  300. m_layer->platformLayer()->clearOverride();
  301. else if (Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
  302. m_layerCompositingThread->clearOverride();
  303. scheduleCompositingRun();
  304. }
  305. }
  306. void WebOverlayPrivateWebKitThread::notifyFlushRequired(const WebCore::GraphicsLayer*)
  307. {
  308. if (WebPagePrivate* page = this->page())
  309. page->scheduleRootLayerCommit();
  310. }
  311. void WebOverlayPrivateWebKitThread::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext& c, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&)
  312. {
  313. drawContents(c.platformContext());
  314. }
  315. WebOverlayLayerCompositingThreadClient::WebOverlayLayerCompositingThreadClient(WebOverlayPrivate* overlay)
  316. : m_drawsContent(false)
  317. , m_overlay(overlay)
  318. {
  319. }
  320. void WebOverlayLayerCompositingThreadClient::setDrawsContent(bool drawsContent)
  321. {
  322. m_drawsContent = drawsContent;
  323. }
  324. void WebOverlayLayerCompositingThreadClient::invalidate()
  325. {
  326. m_texture.clear();
  327. clearUploadedContents();
  328. }
  329. void WebOverlayLayerCompositingThreadClient::setContentsToImage(const BlackBerry::Platform::Graphics::TiledImage& image)
  330. {
  331. m_image = image;
  332. m_color = Color();
  333. m_texture.clear();
  334. clearUploadedContents();
  335. }
  336. void WebOverlayLayerCompositingThreadClient::clearUploadedContents()
  337. {
  338. m_uploadedImage = BlackBerry::Platform::Graphics::TiledImage();
  339. }
  340. void WebOverlayLayerCompositingThreadClient::setContentsToColor(const Color& color)
  341. {
  342. m_image = BlackBerry::Platform::Graphics::TiledImage();
  343. m_color = color;
  344. m_texture.clear();
  345. clearUploadedContents();
  346. }
  347. void WebOverlayLayerCompositingThreadClient::layerCompositingThreadDestroyed(WebCore::LayerCompositingThread*)
  348. {
  349. delete this;
  350. }
  351. void WebOverlayLayerCompositingThreadClient::layerVisibilityChanged(LayerCompositingThread*, bool)
  352. {
  353. }
  354. void WebOverlayLayerCompositingThreadClient::uploadTexturesIfNeeded(LayerCompositingThread* layer)
  355. {
  356. if (m_image.isNull() && !m_color.isValid() && !m_drawsContent)
  357. return;
  358. if (m_texture && m_texture->buffer())
  359. return;
  360. if (m_color.isValid()) {
  361. m_texture = textureCacheCompositingThread()->textureForColor(m_color);
  362. return;
  363. }
  364. BlackBerry::Platform::Graphics::Buffer* textureContents = 0;
  365. IntSize textureSize;
  366. if (m_drawsContent) {
  367. if (!m_overlay || !m_overlay->client)
  368. return;
  369. textureSize = layer->bounds();
  370. textureContents = BlackBerry::Platform::Graphics::createBuffer(IntSize(0, 0), BlackBerry::Platform::Graphics::NeverBacked);
  371. if (!textureContents)
  372. return;
  373. clearBuffer(textureContents, 0, 0, 0, 0);
  374. PlatformGraphicsContext* platformContext = lockBufferDrawable(textureContents);
  375. if (!platformContext) {
  376. destroyBuffer(textureContents);
  377. return;
  378. }
  379. double transform[] = {
  380. 1, 0,
  381. 0, 1,
  382. -layer->bounds().width() / 2.0, -layer->bounds().height() / 2.0
  383. };
  384. platformContext->setTransform(transform);
  385. m_overlay->client->drawOverlayContents(m_overlay->q, platformContext);
  386. releaseBufferDrawable(textureContents);
  387. } else if (!m_image.isNull()) {
  388. textureSize = IntSize(m_image.width(), m_image.height());
  389. textureContents = BlackBerry::Platform::Graphics::createBuffer(IntSize(0, 0), BlackBerry::Platform::Graphics::NeverBacked);
  390. if (!textureContents)
  391. return;
  392. PlatformGraphicsContext* platformContext = BlackBerry::Platform::Graphics::lockBufferDrawable(textureContents);
  393. if (!platformContext) {
  394. destroyBuffer(textureContents);
  395. return;
  396. }
  397. AffineTransform transform;
  398. platformContext->getTransform(reinterpret_cast<double*>(&transform));
  399. transform.translate(-m_image.width() / 2.0, -m_image.height() / 2.0);
  400. platformContext->setTransform(reinterpret_cast<double*>(&transform));
  401. FloatRect rect(0, 0, m_image.width(), m_image.height());
  402. platformContext->addImage(rect, rect, &m_image);
  403. releaseBufferDrawable(textureContents);
  404. m_uploadedImage = m_image;
  405. }
  406. m_texture = LayerTexture::create();
  407. m_texture->protect(IntSize(), BlackBerry::Platform::Graphics::BackedWhenNecessary);
  408. m_texture->updateContents(textureContents);
  409. }
  410. void WebOverlayLayerCompositingThreadClient::drawTextures(LayerCompositingThread* layer, const GLES2Program&, double scale, const FloatRect& /*clipRect*/)
  411. {
  412. if (!m_texture || !m_texture->buffer())
  413. return;
  414. TransformationMatrix matrix = layer->drawTransform();
  415. if (!m_image.isNull()) {
  416. if (m_image.size().isEmpty())
  417. return;
  418. matrix.scaleNonUniform(static_cast<double>(layer->bounds().width()) / m_image.width(), static_cast<double>(layer->bounds().height()) / m_image.height());
  419. }
  420. matrix.scale(layer->sizeIsScaleInvariant() ? 1.0 / scale : 1.0);
  421. blitToBuffer(0, m_texture->buffer(), reinterpret_cast<BlackBerry::Platform::TransformationMatrix&>(matrix),
  422. BlackBerry::Platform::Graphics::SourceOver, static_cast<unsigned char>(layer->drawOpacity() * 255));
  423. }
  424. void WebOverlayLayerCompositingThreadClient::deleteTextures(LayerCompositingThread*)
  425. {
  426. m_texture.clear();
  427. clearUploadedContents();
  428. }
  429. WebOverlayPrivateCompositingThread::WebOverlayPrivateCompositingThread(PassRefPtr<LayerCompositingThread> layerCompositingThread)
  430. : m_layerCompositingThreadClient(0)
  431. , m_data(0)
  432. {
  433. m_layerCompositingThread = layerCompositingThread;
  434. }
  435. WebOverlayPrivateCompositingThread::WebOverlayPrivateCompositingThread()
  436. : m_layerCompositingThreadClient(new WebOverlayLayerCompositingThreadClient(this))
  437. {
  438. m_layerCompositingThread = LayerCompositingThread::create(LayerData::CustomLayer, m_layerCompositingThreadClient);
  439. }
  440. WebOverlayPrivateCompositingThread::~WebOverlayPrivateCompositingThread()
  441. {
  442. if (m_layerCompositingThreadClient)
  443. m_layerCompositingThreadClient->overlayDestroyed();
  444. }
  445. FloatPoint WebOverlayPrivateCompositingThread::position() const
  446. {
  447. return m_layerCompositingThread->position();
  448. }
  449. void WebOverlayPrivateCompositingThread::setPosition(const FloatPoint& position)
  450. {
  451. m_layerCompositingThread->setPosition(position);
  452. scheduleCompositingRun();
  453. }
  454. FloatPoint WebOverlayPrivateCompositingThread::anchorPoint() const
  455. {
  456. return m_layerCompositingThread->anchorPoint();
  457. }
  458. void WebOverlayPrivateCompositingThread::setAnchorPoint(const FloatPoint& anchor)
  459. {
  460. m_layerCompositingThread->setAnchorPoint(anchor);
  461. scheduleCompositingRun();
  462. }
  463. FloatSize WebOverlayPrivateCompositingThread::size() const
  464. {
  465. IntSize bounds = m_layerCompositingThread->bounds();
  466. return FloatSize(bounds.width(), bounds.height());
  467. }
  468. void WebOverlayPrivateCompositingThread::setSize(const FloatSize& size)
  469. {
  470. m_layerCompositingThread->setBounds(IntSize(size.width(), size.height()));
  471. scheduleCompositingRun();
  472. }
  473. bool WebOverlayPrivateCompositingThread::sizeIsScaleInvariant() const
  474. {
  475. return m_layerCompositingThread->sizeIsScaleInvariant();
  476. }
  477. void WebOverlayPrivateCompositingThread::setSizeIsScaleInvariant(bool invariant)
  478. {
  479. m_layerCompositingThread->setSizeIsScaleInvariant(invariant);
  480. scheduleCompositingRun();
  481. }
  482. TransformationMatrix WebOverlayPrivateCompositingThread::transform() const
  483. {
  484. return m_layerCompositingThread->transform();
  485. }
  486. void WebOverlayPrivateCompositingThread::setTransform(const TransformationMatrix& transform)
  487. {
  488. m_layerCompositingThread->setTransform(transform);
  489. scheduleCompositingRun();
  490. }
  491. float WebOverlayPrivateCompositingThread::opacity() const
  492. {
  493. return m_layerCompositingThread->opacity();
  494. }
  495. void WebOverlayPrivateCompositingThread::setOpacity(float opacity)
  496. {
  497. m_layerCompositingThread->setOpacity(opacity);
  498. scheduleCompositingRun();
  499. }
  500. void WebOverlayPrivateCompositingThread::addAnimation(const String& name, Animation* animation, const KeyframeValueList& keyframes)
  501. {
  502. IntSize boxSize = m_layerCompositingThread->bounds();
  503. RefPtr<LayerAnimation> layerAnimation = LayerAnimation::create(keyframes, boxSize, animation, name, 0.0);
  504. // FIXME: Unfortunately WebPageCompositorClient::requestAnimationFrame uses a different time coordinate system
  505. // than accelerated animations, so we can't use the time returned by WebPageCompositorClient::requestAnimationFrame()
  506. // for starttime.
  507. layerAnimation->setStartTime(currentTime());
  508. m_layerCompositingThread->addAnimation(layerAnimation.get());
  509. scheduleCompositingRun();
  510. }
  511. void WebOverlayPrivateCompositingThread::removeAnimation(const String& name)
  512. {
  513. m_layerCompositingThread->removeAnimation(name);
  514. scheduleCompositingRun();
  515. }
  516. Platform::IntRect WebOverlayPrivateCompositingThread::pixelViewportRect() const
  517. {
  518. if (LayerRenderer* renderer = m_layerCompositingThread->layerRenderer())
  519. return renderer->toPixelViewportCoordinates(m_layerCompositingThread->boundingBox());
  520. return Platform::IntRect();
  521. }
  522. void WebOverlayPrivateCompositingThread::addChild(WebOverlayPrivate* overlay)
  523. {
  524. m_layerCompositingThread->addSublayer(overlay->layerCompositingThread());
  525. scheduleCompositingRun();
  526. }
  527. void WebOverlayPrivateCompositingThread::removeFromParent()
  528. {
  529. if (page() && m_layerCompositingThread->superlayer() == page()->compositor()->compositingThreadOverlayLayer())
  530. page()->m_webPage->removeCompositingThreadOverlay(q);
  531. else
  532. m_layerCompositingThread->removeFromSuperlayer();
  533. scheduleCompositingRun();
  534. }
  535. void WebOverlayPrivateCompositingThread::setContentsToImage(const unsigned char* data, const IntSize& imageSize, WebOverlay::ImageDataAdoptionType)
  536. {
  537. if (!m_layerCompositingThreadClient)
  538. return;
  539. if (data == m_data)
  540. return;
  541. m_data = data;
  542. BlackBerry::Platform::Graphics::TiledImage image = BlackBerry::Platform::Graphics::TiledImage(imageSize, reinterpret_cast_ptr<const unsigned*>(data), true, BlackBerry::Platform::Graphics::TiledImage::Hardware);
  543. m_layerCompositingThreadClient->setContentsToImage(image);
  544. m_layerCompositingThread->setNeedsTexture(true);
  545. }
  546. void WebOverlayPrivateCompositingThread::setContentsToColor(const Color& color)
  547. {
  548. if (!m_layerCompositingThreadClient)
  549. return;
  550. m_layerCompositingThreadClient->setContentsToColor(color);
  551. m_layerCompositingThread->setNeedsTexture(true);
  552. }
  553. void WebOverlayPrivateCompositingThread::setDrawsContent(bool drawsContent)
  554. {
  555. if (!m_layerCompositingThreadClient)
  556. return;
  557. m_layerCompositingThreadClient->setDrawsContent(drawsContent);
  558. m_layerCompositingThread->setNeedsTexture(true);
  559. }
  560. void WebOverlayPrivateCompositingThread::clear()
  561. {
  562. m_layerCompositingThread->deleteTextures();
  563. }
  564. void WebOverlayPrivateCompositingThread::invalidate()
  565. {
  566. if (!m_layerCompositingThreadClient || !m_layerCompositingThreadClient->drawsContent())
  567. return;
  568. m_layerCompositingThreadClient->invalidate();
  569. scheduleCompositingRun();
  570. }
  571. void WebOverlayPrivateCompositingThread::resetOverrides()
  572. {
  573. m_layerCompositingThread->clearOverride();
  574. scheduleCompositingRun();
  575. }
  576. }
  577. }
  578. #else // USE(ACCELERATED_COMPOSITING)
  579. namespace BlackBerry {
  580. namespace WebKit {
  581. WebOverlay::WebOverlay()
  582. {
  583. }
  584. WebOverlay::~WebOverlay()
  585. {
  586. }
  587. Platform::FloatPoint WebOverlay::position() const
  588. {
  589. return Platform::FloatPoint();
  590. }
  591. void WebOverlay::setPosition(const Platform::FloatPoint&)
  592. {
  593. }
  594. Platform::FloatPoint WebOverlay::anchorPoint() const
  595. {
  596. return Platform::FloatPoint();
  597. }
  598. void WebOverlay::setAnchorPoint(const Platform::FloatPoint&)
  599. {
  600. }
  601. Platform::FloatSize WebOverlay::size() const
  602. {
  603. return Platform::FloatSize();
  604. }
  605. void WebOverlay::setSize(const Platform::FloatSize&)
  606. {
  607. }
  608. Platform::TransformationMatrix WebOverlay::transform() const
  609. {
  610. return Platform::TransformationMatrix();
  611. }
  612. void WebOverlay::setTransform(const Platform::TransformationMatrix&)
  613. {
  614. }
  615. float WebOverlay::opacity() const
  616. {
  617. return 1.0f;
  618. }
  619. void WebOverlay::setOpacity(float)
  620. {
  621. }
  622. Platform::IntRect WebOverlay::pixelViewportRect() const
  623. {
  624. return Platform::IntRect();
  625. }
  626. WebOverlay* WebOverlay::parent() const
  627. {
  628. return 0;
  629. }
  630. bool WebOverlay::addChild(WebOverlay*)
  631. {
  632. return false;
  633. }
  634. void WebOverlay::removeFromParent()
  635. {
  636. }
  637. void WebOverlay::addAnimation(const WebAnimation&)
  638. {
  639. }
  640. void WebOverlay::removeAnimation(const BlackBerry::Platform::String&)
  641. {
  642. }
  643. void WebOverlay::setContentsToImage(const unsigned char*, const Platform::IntSize&, ImageDataAdoptionType)
  644. {
  645. }
  646. void WebOverlay::setContentsToColor(int, int, int, int)
  647. {
  648. }
  649. void WebOverlay::setDrawsContent(bool)
  650. {
  651. }
  652. void WebOverlay::invalidate()
  653. {
  654. }
  655. void WebOverlay::setClient(WebOverlayClient*)
  656. {
  657. }
  658. WebOverlayOverride* WebOverlay::override()
  659. {
  660. }
  661. void WebOverlay::resetOverrides()
  662. {
  663. }
  664. }
  665. }
  666. #endif // USE(ACCELERATED_COMPOSITING)