Changeset 128755 in webkit
- Timestamp:
- Sep 17, 2012 7:57:36 AM (12 years ago)
- Location:
- trunk/Source/WebKit/blackberry
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/blackberry/Api/WebOverlay.cpp
r125381 r128755 164 164 } 165 165 166 void WebOverlay::setContentsToImage(const unsigned char* data, const Platform::IntSize& imageSize )167 { 168 d->setContentsToImage(data, imageSize );166 void WebOverlay::setContentsToImage(const unsigned char* data, const Platform::IntSize& imageSize, ImageDataAdoptionType adoptionType) 167 { 168 d->setContentsToImage(data, imageSize, adoptionType); 169 169 } 170 170 … … 330 330 } 331 331 332 void WebOverlayPrivateWebKitThread::setContentsToImage(const unsigned char* data, const WebCore::IntSize& imageSize )332 void WebOverlayPrivateWebKitThread::setContentsToImage(const unsigned char* data, const WebCore::IntSize& imageSize, WebOverlay::ImageDataAdoptionType adoptionType) 333 333 { 334 334 notImplemented(); … … 391 391 { 392 392 m_texture.clear(); 393 clearUploadedContents(); 393 394 } 394 395 … … 398 399 m_color = Color(); 399 400 m_texture.clear(); 401 clearUploadedContents(); 402 } 403 404 void WebOverlayLayerCompositingThreadClient::clearUploadedContents() 405 { 406 m_uploadedContents = SkBitmap(); 400 407 } 401 408 … … 405 412 m_color = color; 406 413 m_texture.clear(); 414 clearUploadedContents(); 407 415 } 408 416 … … 447 455 m_texture->protect(IntSize(m_contents.width(), m_contents.height())); 448 456 IntRect bitmapRect(0, 0, m_contents.width(), m_contents.height()); 449 m_texture->updateContents(m_contents, bitmapRect, bitmapRect, false); 457 m_uploadedContents = m_contents; 458 m_texture->updateContents(m_uploadedContents, bitmapRect, bitmapRect, false); 450 459 } 451 460 … … 465 474 { 466 475 m_texture.clear(); 476 clearUploadedContents(); 467 477 } 468 478 … … 595 605 } 596 606 597 void WebOverlayPrivateCompositingThread::setContentsToImage(const unsigned char* data, const IntSize& imageSize )607 void WebOverlayPrivateCompositingThread::setContentsToImage(const unsigned char* data, const IntSize& imageSize, WebOverlay::ImageDataAdoptionType adoptionType) 598 608 { 599 609 if (!m_layerCompositingThreadClient) … … 609 619 SkBitmap contents; 610 620 contents.setConfig(SkBitmap::kARGB_8888_Config, imageSize.width(), imageSize.height()); 611 contents.setPixels(const_cast<unsigned char*>(data)); 621 622 switch (adoptionType) { 623 case WebOverlay::ReferenceImageData: 624 contents.setPixels(const_cast<unsigned char*>(data)); 625 break; 626 case WebOverlay::CopyImageData: 627 if (contents.allocPixels()) { 628 contents.lockPixels(); 629 size_t bytes = SkBitmap::ComputeSize(SkBitmap::kARGB_8888_Config, imageSize.width(), imageSize.height()); 630 memcpy(contents.getPixels(), data, bytes); 631 contents.unlockPixels(); 632 } 633 break; 634 default: 635 ASSERT_NOT_REACHED(); 636 } 612 637 613 638 m_layerCompositingThreadClient->setContents(contents); … … 734 759 } 735 760 736 void WebOverlay::setContentsToImage(const unsigned char*, const Platform::IntSize& )761 void WebOverlay::setContentsToImage(const unsigned char*, const Platform::IntSize&, ImageDataAdoptionType) 737 762 { 738 763 } -
trunk/Source/WebKit/blackberry/Api/WebOverlay.h
r118750 r128755 56 56 class BLACKBERRY_EXPORT WebOverlay { 57 57 public: 58 enum ImageDataAdoptionType { 59 ReferenceImageData, 60 CopyImageData 61 }; 62 58 63 WebOverlay(); 59 64 WebOverlay(WebCore::GraphicsLayerClient*); … … 95 100 void removeFromParent(); 96 101 97 void setContentsToImage(const unsigned char* data, const Platform::IntSize& imageSize );102 void setContentsToImage(const unsigned char* data, const Platform::IntSize& imageSize, ImageDataAdoptionType = ReferenceImageData); 98 103 void setContentsToColor(int r, int g, int b, int a); 99 104 void setDrawsContent(bool); -
trunk/Source/WebKit/blackberry/Api/WebOverlay_p.h
r125381 r128755 25 25 #include "LayerCompositingThread.h" 26 26 #include "Texture.h" 27 #include "WebOverlay.h" 27 28 #include "WebOverlayOverride.h" 28 29 … … 46 47 namespace WebKit { 47 48 48 class WebOverlay;49 49 class WebOverlayClient; 50 50 class WebPagePrivate; … … 96 96 virtual void removeFromParent() = 0; 97 97 98 virtual void setContentsToImage(const unsigned char* data, const WebCore::IntSize& imageSize ) = 0;98 virtual void setContentsToImage(const unsigned char* data, const WebCore::IntSize& imageSize, WebOverlay::ImageDataAdoptionType) = 0; 99 99 virtual void setContentsToColor(const WebCore::Color&) = 0; 100 100 virtual void setDrawsContent(bool) = 0; … … 153 153 virtual void removeFromParent(); 154 154 155 virtual void setContentsToImage(const unsigned char* data, const WebCore::IntSize& imageSize );155 virtual void setContentsToImage(const unsigned char* data, const WebCore::IntSize& imageSize, WebOverlay::ImageDataAdoptionType); 156 156 virtual void setContentsToColor(const WebCore::Color&); 157 157 virtual void setDrawsContent(bool); … … 203 203 204 204 private: 205 void clearUploadedContents(); 206 207 private: 205 208 RefPtr<WebCore::Texture> m_texture; 206 209 bool m_drawsContent; 207 210 SkBitmap m_contents; 211 SkBitmap m_uploadedContents; 208 212 WebCore::Color m_color; 209 213 WebCore::LayerCompositingThread* m_layerCompositingThread; … … 244 248 virtual void removeFromParent(); 245 249 246 virtual void setContentsToImage(const unsigned char* data, const WebCore::IntSize& imageSize );250 virtual void setContentsToImage(const unsigned char* data, const WebCore::IntSize& imageSize, WebOverlay::ImageDataAdoptionType); 247 251 virtual void setContentsToColor(const WebCore::Color&); 248 252 virtual void setDrawsContent(bool); -
trunk/Source/WebKit/blackberry/ChangeLog
r128650 r128755 1 2012-09-17 Jakob Petsovits <jpetsovits@rim.com> 2 3 [BlackBerry] Support copying image data in WebOverlay. 4 https://bugs.webkit.org/show_bug.cgi?id=96684 5 RIM PR 195444 6 7 Reviewed by Rob Buis. 8 Internally reviewed by Arvid Nilsson. 9 10 The publicly exposed WebOverlay class provides a method 11 setContentsToImage() to assign a pointer to pixel data, 12 which is later used to provide texture data for the 13 underlying compositing layer. This works well for static 14 images that stay in memory and never change, but not 15 so well for images with changing contents or where the 16 image data is being reassigned from different image 17 sources that are not constantly kept around in memory. 18 19 Due to the delayed upload and delayed fetching of 20 EGLImage data by the GPU, we shouldn't assume the caller 21 to know how long the image should be retained. Instead, 22 we should offer another method of setting image data 23 that takes ownership of the pixel data. 24 25 This patch adds an option to setContentsToImage() that 26 copies the passed pixel data and doesn't destroy it 27 until both the texture is destroyed and the image 28 contents are changed. Using this method, the caller can 29 withdraw the passed pixel array right after the 30 setContentsToImage() call without consequences. 31 32 * Api/WebOverlay.cpp: 33 (BlackBerry::WebKit::WebOverlay::setContentsToImage): 34 (BlackBerry::WebKit::WebOverlayPrivateWebKitThread::setContentsToImage): 35 (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::WebOverlayLayerCompositingThreadClient): 36 (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::invalidate): 37 (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setContents): 38 (WebKit): 39 (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::clearUploadedContents): 40 (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setContentsToColor): 41 (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::uploadTexturesIfNeeded): 42 (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::deleteTextures): 43 (BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setContentsToImage): 44 * Api/WebOverlay.h: 45 * Api/WebOverlay_p.h: 46 (WebOverlayPrivate): 47 (WebOverlayPrivateWebKitThread): 48 (WebOverlayLayerCompositingThreadClient): 49 (WebOverlayPrivateCompositingThread): 50 1 51 2012-09-14 Dana Jansens <danakj@chromium.org> 2 52
Note: See TracChangeset
for help on using the changeset viewer.