Changeset 113678 in webkit
- Timestamp:
- Apr 9, 2012 9:57:32 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r113677 r113678 1 2012-04-09 No'am Rosenthal <noam.rosenthal@nokia.com> 2 3 [WK2] Enable using a single ShareableBitmap for multiple updates 4 https://bugs.webkit.org/show_bug.cgi?id=83424 5 6 Modify BitmapTexture::updateContents to include a source offset. 7 This allows us to update a texture from a sub-image. 8 9 Reviewed by Kenneth Rohde Christiansen. 10 11 Tested by existing API tests. 12 13 * platform/graphics/texmap/TextureMapper.h: 14 (BitmapTexture): 15 * platform/graphics/texmap/TextureMapperGL.cpp: 16 (WebCore::BitmapTextureGL::didReset): 17 (WebCore::driverSupportsBGRASwizzling): 18 (WebCore::BitmapTextureGL::updateContents): 19 * platform/graphics/texmap/TextureMapperGL.h: 20 (WebCore::BitmapTextureGL::textureTarget): 21 (BitmapTextureGL): 22 * platform/graphics/texmap/TextureMapperImageBuffer.cpp: 23 (WebCore::BitmapTextureImageBuffer::updateContents): 24 * platform/graphics/texmap/TextureMapperImageBuffer.h: 25 (BitmapTextureImageBuffer): 26 1 27 2012-04-09 Dana Jansens <danakj@chromium.org> 2 28 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h
r110979 r113678 53 53 class BitmapTexture : public RefCounted<BitmapTexture> { 54 54 public: 55 enum PixelFormat { BGRAFormat, RGBAFormat, BGRFormat, RGBFormat };56 55 enum Flag { 57 56 SupportsAlpha = 0x01 … … 68 67 69 68 virtual IntSize size() const = 0; 70 virtual void updateContents(Image*, const IntRect&, const Int Rect&, BitmapTexture::PixelFormat) = 0;71 virtual void updateContents(const void*, const IntRect& ) = 0;69 virtual void updateContents(Image*, const IntRect&, const IntPoint& offset) = 0; 70 virtual void updateContents(const void*, const IntRect& target, const IntPoint& offset, int bytesPerLine) = 0; 72 71 virtual bool isValid() const = 0; 73 72 inline Flags flags() const { return m_flags; } -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp
r108135 r113678 27 27 namespace WebCore { 28 28 29 void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect , BitmapTexture::PixelFormat format)29 void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect) 30 30 { 31 31 IntRect targetRect = enclosingIntRect(m_rect); … … 33 33 if (targetRect.isEmpty()) 34 34 return; 35 Int Rect sourceRect = targetRect;35 IntPoint sourceOffset = targetRect.location(); 36 36 37 37 // Normalize sourceRect to the buffer's coordinates. 38 source Rect.move(-dirtyRect.x(), -dirtyRect.y());38 sourceOffset.move(-dirtyRect.x(), -dirtyRect.y()); 39 39 40 40 // Normalize targetRect to the texture's coordinates. … … 45 45 } 46 46 47 m_texture->updateContents(image, targetRect, source Rect, format);47 m_texture->updateContents(image, targetRect, sourceOffset); 48 48 } 49 49 … … 58 58 return; 59 59 60 updateContents(textureMapper, m_image.get() , m_image->currentFrameHasAlpha() ? BitmapTexture::BGRAFormat : BitmapTexture::BGRFormat);60 updateContents(textureMapper, m_image.get()); 61 61 m_image.clear(); 62 62 } … … 135 135 } 136 136 137 void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect , BitmapTexture::PixelFormat format)137 void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect) 138 138 { 139 139 createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), image->currentFrameHasAlpha()); 140 140 for (size_t i = 0; i < m_tiles.size(); ++i) 141 m_tiles[i].updateContents(textureMapper, image, dirtyRect , format);141 m_tiles[i].updateContents(textureMapper, image, dirtyRect); 142 142 } 143 143 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h
r111258 r113678 46 46 inline void setRect(const FloatRect& rect) { m_rect = rect; } 47 47 48 void updateContents(TextureMapper*, Image*, const IntRect& , BitmapTexture::PixelFormat);48 void updateContents(TextureMapper*, Image*, const IntRect&); 49 49 virtual void paint(TextureMapper*, const TransformationMatrix&, float, BitmapTexture*); 50 50 virtual ~TextureMapperTile() { } … … 66 66 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*); 67 67 virtual PassRefPtr<BitmapTexture> texture() const; 68 void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect& , BitmapTexture::PixelFormat);69 void updateContents(TextureMapper* textureMapper, Image* image , BitmapTexture::PixelFormat format) { updateContents(textureMapper, image, image->size(), image->rect(), format); }68 void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&); 69 void updateContents(TextureMapper* textureMapper, Image* image) { updateContents(textureMapper, image, image->size(), image->rect()); } 70 70 inline FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); } 71 71 static PassRefPtr<TextureMapperTiledBackingStore> create() { return adoptRef(new TextureMapperTiledBackingStore); } -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
r113533 r113678 410 410 } 411 411 412 static void swizzleBGRAToRGBA(uint32_t* data, const IntSize& size )412 static void swizzleBGRAToRGBA(uint32_t* data, const IntSize& size, int stride = 0) 413 413 { 414 414 int width = size.width(); 415 415 int height = size.height(); 416 stride = stride | width; 416 417 for (int y = 0; y < height; ++y) { 417 uint32_t* p = data + y * width;418 uint32_t* p = data + y * stride; 418 419 for (int x = 0; x < width; ++x) 419 420 p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); … … 431 432 } 432 433 433 void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect) 434 static bool driverSupportsSubImage() 435 { 436 #if defined(TEXMAP_OPENGL_ES_2) 437 // FIXME: Implement reliable detection. 438 return false; 439 #else 440 return true; 441 #endif 442 } 443 444 void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine) 434 445 { 435 446 GLuint glFormat = GL_RGBA; 436 447 GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id)) 448 437 449 if (driverSupportsBGRASwizzling()) 438 450 glFormat = GL_BGRA; 439 else { 440 swizzleBGRAToRGBA(static_cast<uint32_t*>(const_cast<void*>(data)), targetRect.size()); 441 glFormat = GL_RGBA; 442 } 443 444 GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, GL_UNSIGNED_BYTE, data)) 445 } 446 447 void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntRect& sourceRect, BitmapTexture::PixelFormat format) 451 else 452 swizzleBGRAToRGBA(static_cast<uint32_t*>(const_cast<void*>(data)), targetRect.size(), bytesPerLine / 4); 453 454 if (bytesPerLine == targetRect.width() / 4 && sourceOffset == IntPoint::zero()) { 455 GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, GL_UNSIGNED_BYTE, (const char*)data)) 456 return; 457 } 458 459 // For ES drivers that don't support sub-images, transfer the pixels row-by-row. 460 if (!driverSupportsSubImage()) { 461 const char* bits = static_cast<const char*>(data); 462 for (int y = 0; y < targetRect.height(); ++y) { 463 const char *row = bits + ((sourceOffset.y() + y) * bytesPerLine + sourceOffset.x() * 4); 464 GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y() + y, targetRect.width(), 1, glFormat, GL_UNSIGNED_BYTE, row)) 465 } 466 return; 467 } 468 469 // Use the OpenGL sub-image extension, now that we know it's available. 470 glPixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / 4); 471 glPixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y()); 472 glPixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x()); 473 GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, GL_UNSIGNED_BYTE, (const char*)data)) 474 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 475 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); 476 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 477 } 478 479 void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset) 448 480 { 449 481 if (!image) 450 482 return; 451 GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id))452 GLuint glFormat = isOpaque() ? GL_RGB : GL_RGBA;453 483 NativeImagePtr frameImage = image->nativeImageForCurrentFrame(); 454 484 if (!frameImage) 455 485 return; 456 486 487 int bytesPerLine; 488 const char* imageData; 489 457 490 #if PLATFORM(QT) 458 491 QImage qtImage; 459 460 492 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 461 493 // With QPA, we can avoid a deep copy. … … 465 497 qtImage = frameImage->toImage(); 466 498 #endif 467 468 if (IntSize(qtImage.size()) != sourceRect.size()) 469 qtImage = qtImage.copy(sourceRect); 470 if (format == BGRAFormat || format == BGRFormat) { 471 if (driverSupportsBGRASwizzling()) 472 glFormat = isOpaque() ? GL_BGR : GL_BGRA; 473 else 474 swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(qtImage.bits()), qtImage.size()); 475 } 476 GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, GL_UNSIGNED_BYTE, qtImage.constBits())) 477 499 imageData = reinterpret_cast<const char*>(qtImage.constBits()); 500 bytesPerLine = qtImage.bytesPerLine(); 478 501 #elif USE(CAIRO) 479 480 #if !CPU(BIG_ENDIAN) 481 #if defined(TEXMAP_OPENGL_ES_2) 482 swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(cairo_image_surface_get_data(frameImage)), 483 cairo_image_surface_get_stride(frameImage) * cairo_image_surface_get_height(frameImage)); 484 #else 485 glFormat = isOpaque() ? GL_BGR : GL_BGRA; 486 #endif 487 #endif 488 489 glPixelStorei(GL_UNPACK_ROW_LENGTH, cairo_image_surface_get_stride(frameImage) / 4); 490 glPixelStorei(GL_UNPACK_SKIP_ROWS, sourceRect.y()); 491 glPixelStorei(GL_UNPACK_SKIP_PIXELS, sourceRect.x()); 492 GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, 493 targetRect.x(), targetRect.y(), 494 targetRect.width(), targetRect.height(), 495 glFormat, GL_UNSIGNED_BYTE, 496 cairo_image_surface_get_data(frameImage))); 497 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 498 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); 499 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 500 #endif 502 imageData = cairo_image_surface_get_data(frameImage); 503 bytesPerLine = cairo_image_surface_get_stride(frameImage); 504 #endif 505 506 updateContents(imageData, targetRect, offset, bytesPerLine); 507 501 508 } 502 509 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
r110979 r113678 63 63 GraphicsContext* graphicsContext() { return m_context; } 64 64 virtual bool isOpenGLBacked() const { return true; } 65 void platformUpdateContents(NativeImagePtr, const IntRect&, const IntRect& , BitmapTexture::PixelFormat);65 void platformUpdateContents(NativeImagePtr, const IntRect&, const IntRect&); 66 66 virtual AccelerationMode accelerationMode() const { return OpenGLMode; } 67 67 … … 84 84 ~BitmapTextureGL(); 85 85 virtual uint32_t id() const { return m_id; } 86 uint32_t textureTarget() const { return GL_TEXTURE_2D; } 86 87 IntSize textureSize() const { return m_textureSize; } 87 88 void setTextureMapper(TextureMapperGL* texmap) { m_textureMapper = texmap; } 88 void updateContents(Image*, const IntRect&, const Int Rect&, PixelFormat);89 v oid updateContents(const void*, const IntRect&);89 void updateContents(Image*, const IntRect&, const IntPoint&); 90 virtual void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine); 90 91 91 92 private: -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
r108135 r113678 26 26 namespace WebCore { 27 27 28 void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& targetRect )28 void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine) 29 29 { 30 30 #if PLATFORM(QT) 31 QImage image(reinterpret_cast<const uchar*>(data), targetRect.width(), targetRect.height(), targetRect.width() * 4, QImage::Format_ARGB32_Premultiplied); 31 QImage image(reinterpret_cast<const uchar*>(data), targetRect.width(), targetRect.height(), bytesPerLine, QImage::Format_ARGB32_Premultiplied); 32 32 33 QPainter* painter = m_image->context()->platformContext(); 33 34 painter->save(); 34 35 painter->setCompositionMode(QPainter::CompositionMode_Source); 35 painter->drawImage(targetRect, image );36 painter->drawImage(targetRect, image, IntRect(sourceOffset, targetRect.size())); 36 37 painter->restore(); 37 38 #endif … … 43 44 } 44 45 45 void BitmapTextureImageBuffer::updateContents(Image* image, const IntRect& targetRect, const Int Rect& sourceRect, PixelFormat)46 void BitmapTextureImageBuffer::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset) 46 47 { 47 m_image->context()->drawImage(image, ColorSpaceDeviceRGB, targetRect, sourceRect, CompositeCopy);48 m_image->context()->drawImage(image, ColorSpaceDeviceRGB, targetRect, IntRect(offset, targetRect.size()), CompositeCopy); 48 49 } 49 50 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
r110437 r113678 35 35 virtual bool isValid() const { return m_image; } 36 36 inline GraphicsContext* graphicsContext() { return m_image ? m_image->context() : 0; } 37 virtual void updateContents(Image*, const IntRect&, const Int Rect&, PixelFormat);38 v oid updateContents(const void* data, const IntRect& targetRect);37 virtual void updateContents(Image*, const IntRect&, const IntPoint&); 38 virtual void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine); 39 39 #if ENABLE(CSS_FILTERS) 40 40 void applyFilters(const BitmapTexture&, const FilterOperations&); -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
r111258 r113678 132 132 #endif 133 133 134 static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get())->updateContents(textureMapper, image.get(), m_size, dirtyRect , BitmapTexture::BGRAFormat);134 static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get())->updateContents(textureMapper, image.get(), m_size, dirtyRect); 135 135 } 136 136 -
trunk/Source/WebKit2/ChangeLog
r113640 r113678 1 2012-04-09 No'am Rosenthal <noam.rosenthal@nokia.com> 2 3 [WK2] Enable using a single ShareableBitmap for multiple updates 4 https://bugs.webkit.org/show_bug.cgi?id=83424 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Enabled creating a GraphicsContext that references a rect inside ShareableBitmap. 9 Added bitmapOffset to UpdateInfo, to allow updates to reference an offset inside the bitmap. 10 Added UpdateAtlas, a class that manages available rects in a larger ShareableBitmap. 11 12 In this iteration, UpdateAtlas has a simple behavior where a rect inside the bitmap is 13 either available or used. When the buffers are swapped, all used buffers become available 14 again. A future enhancement might allow triple-buffering, where available rects can be 15 updated while other rects from the same atlas are in use. 16 17 Added the necessary plumbing to allow Qt's UI-side compositing to take advantage of 18 UpdateAtlas. LayerTreeHostQt creates an atlas per type of bitmap (i.e. one opaque and one 19 alpha-enabled atlas). When a tile wants to update and there's no available scratch-buffer, 20 the update would be postponed to the next frame, creating a tiling-artifact in low memory 21 situations. 22 23 * Shared/UpdateInfo.cpp: 24 (WebKit::UpdateInfo::encode): 25 (WebKit::UpdateInfo::decode): 26 * Shared/UpdateInfo.h: 27 (UpdateInfo): 28 * Target.pri: 29 * UIProcess/LayerTreeHostProxy.cpp: 30 (WebKit::LayerTreeHostProxy::updateTileForLayer): 31 * UIProcess/WebLayerTreeRenderer.cpp: 32 (WebKit::WebLayerTreeRenderer::syncLayerParameters): 33 (WebKit::WebLayerTreeRenderer::updateTile): 34 (WebKit::WebLayerTreeRenderer::createImage): 35 * UIProcess/WebLayerTreeRenderer.h: 36 (TileUpdate): 37 (WebKit::WebLayerTreeRenderer::TileUpdate::TileUpdate): 38 (WebLayerTreeRenderer): 39 * UIProcess/qt/LayerBackingStore.cpp: 40 (WebKit::LayerBackingStoreTile::swapBuffers): 41 (WebKit::LayerBackingStoreTile::setBackBuffer): 42 (WebKit::LayerBackingStore::createTile): 43 * UIProcess/qt/LayerBackingStore.h: 44 (LayerBackingStoreTile): 45 (LayerBackingStore): 46 * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp: 47 (WebCore::WebGraphicsLayer::tiledBackingStoreBackgroundColor): 48 (WebCore::WebGraphicsLayer::beginContentUpdate): 49 (WebCore): 50 * WebProcess/WebCoreSupport/WebGraphicsLayer.h: 51 (WebGraphicsLayerClient): 52 (WebGraphicsLayer): 53 * WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp: 54 (WebKit::TiledBackingStoreRemoteTile::updateBackBuffer): 55 * WebProcess/WebPage/TiledBackingStoreRemoteTile.h: 56 (TiledBackingStoreRemoteTileClient): 57 * WebProcess/WebPage/UpdateAtlas.cpp: Added. 58 (WebKit): 59 (WebKit::UpdateAtlas::UpdateAtlas): 60 (WebKit::nextPowerOfTwo): 61 (WebKit::UpdateAtlas::buildLayoutIfNeeded): 62 (WebKit::UpdateAtlas::findAvailableIndex): 63 (WebKit::UpdateAtlas::didSwapBuffers): 64 (WebKit::UpdateAtlas::acquireScratchBuffer): 65 (WebKit::UpdateAtlas::offsetForIndex): 66 * WebProcess/WebPage/UpdateAtlas.h: Added. 67 (WebCore): 68 (WebKit): 69 (UpdateAtlas): 70 (WebKit::UpdateAtlas::bitmap): 71 (WebKit::UpdateAtlas::size): 72 (WebKit::UpdateAtlas::flags): 73 * WebProcess/WebPage/qt/LayerTreeHostQt.cpp: 74 (WebKit::LayerTreeHostQt::adoptImageBackingStore): 75 (WebKit::LayerTreeHostQt::renderNextFrame): 76 (WebKit::LayerTreeHostQt::purgeBackingStores): 77 (WebKit): 78 (WebKit::LayerTreeHostQt::getAtlas): 79 (WebKit::LayerTreeHostQt::beginContentUpdate): 80 * WebProcess/WebPage/qt/LayerTreeHostQt.h: 81 (LayerTreeHostQt): 82 1 83 2012-04-09 No'am Rosenthal <noam.rosenthal@nokia.com> 2 84 -
trunk/Source/WebKit2/Shared/UpdateInfo.cpp
r95901 r113678 41 41 encoder->encode(updateScaleFactor); 42 42 encoder->encode(bitmapHandle); 43 encoder->encode(bitmapOffset); 43 44 } 44 45 … … 61 62 if (!decoder->decode(result.bitmapHandle)) 62 63 return false; 64 if (!decoder->decode(result.bitmapOffset)) 65 return false; 63 66 64 67 return true; -
trunk/Source/WebKit2/Shared/UpdateInfo.h
r95901 r113678 66 66 // The handle of the shareable bitmap containing the updates. Will be null if there are no updates. 67 67 ShareableBitmap::Handle bitmapHandle; 68 69 // The offset in the bitmap where the rendered contents are. 70 WebCore::IntPoint bitmapOffset; 68 71 }; 69 72 -
trunk/Source/WebKit2/Target.pri
r113172 r113678 364 364 WebProcess/WebPage/TapHighlightController.h \ 365 365 WebProcess/WebPage/PageOverlay.h \ 366 WebProcess/WebPage/UpdateAtlas.h \ 366 367 WebProcess/WebPage/WebContextMenu.h \ 367 368 WebProcess/WebPage/WebFrame.h \ … … 371 372 WebProcess/WebPage/WebPageGroupProxy.h \ 372 373 WebProcess/WebPage/WebUndoStep.h \ 374 WebProcess/WebPage/qt/LayerTreeHostQt.h \ 373 375 WebProcess/WebConnectionToUIProcess.h \ 374 376 WebProcess/WebProcess.h \ … … 730 732 WebProcess/WebPage/PageOverlay.cpp \ 731 733 WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp \ 734 WebProcess/WebPage/UpdateAtlas.cpp \ 732 735 WebProcess/WebPage/WebBackForwardListProxy.cpp \ 733 736 WebProcess/WebPage/WebContextMenu.cpp \ -
trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp
r113640 r113678 79 79 IntRect targetRect = updateInfo.updateRectBounds; 80 80 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle); 81 dispatchUpdate(bind(&WebLayerTreeRenderer::updateTile, m_renderer.get(), layerID, tileID, sourceRect, targetRect, bitmap));81 dispatchUpdate(bind(&WebLayerTreeRenderer::updateTile, m_renderer.get(), layerID, tileID, WebLayerTreeRenderer::TileUpdate(sourceRect, targetRect, bitmap, updateInfo.bitmapOffset))); 82 82 } 83 83 -
trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp
r113640 r113678 268 268 } 269 269 270 void WebLayerTreeRenderer::updateTile(WebLayerID layerID, int tileID, const IntRect& sourceRect, const IntRect& targetRect, PassRefPtr<ShareableBitmap> weakBitmap) 271 { 272 RefPtr<ShareableBitmap> bitmap = weakBitmap; 270 void WebLayerTreeRenderer::updateTile(WebLayerID layerID, int tileID, const TileUpdate& update) 271 { 273 272 RefPtr<LayerBackingStore> backingStore = getBackingStore(layerID); 274 backingStore->updateTile(tileID, sourceRect, targetRect, bitmap.get());273 backingStore->updateTile(tileID, update.sourceRect, update.targetRect, update.bitmap, update.offset); 275 274 m_backingStoresWithPendingBuffers.add(backingStore); 276 275 } … … 280 279 RefPtr<ShareableBitmap> bitmap = weakBitmap; 281 280 RefPtr<TextureMapperTiledBackingStore> backingStore = TextureMapperTiledBackingStore::create(); 282 backingStore->updateContents(m_textureMapper.get(), bitmap->createImage().get(), BitmapTexture::BGRAFormat);283 281 m_directlyCompositedImages.set(imageID, backingStore); 282 backingStore->updateContents(m_textureMapper.get(), bitmap->createImage().get()); 284 283 } 285 284 -
trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h
r113640 r113678 46 46 class WebLayerTreeRenderer : public ThreadSafeRefCounted<WebLayerTreeRenderer>, public WebCore::GraphicsLayerClient { 47 47 public: 48 struct TileUpdate { 49 WebCore::IntRect sourceRect; 50 WebCore::IntRect targetRect; 51 RefPtr<ShareableBitmap> bitmap; 52 WebCore::IntPoint offset; 53 TileUpdate(const WebCore::IntRect& source, const WebCore::IntRect& target, PassRefPtr<ShareableBitmap> newBitmap, const WebCore::IntPoint& newOffset) 54 : sourceRect(source) 55 , targetRect(target) 56 , bitmap(newBitmap) 57 , offset(newOffset) 58 { 59 } 60 }; 48 61 WebLayerTreeRenderer(LayerTreeHostProxy*); 49 62 virtual ~WebLayerTreeRenderer(); … … 64 77 void createTile(WebLayerID, int, float scale); 65 78 void removeTile(WebLayerID, int); 66 void updateTile(WebLayerID, int, const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableBitmap>);79 void updateTile(WebLayerID, int, const TileUpdate&); 67 80 void flushLayerChanges(); 68 81 void createImage(int64_t, PassRefPtr<ShareableBitmap>); -
trunk/Source/WebKit2/UIProcess/qt/LayerBackingStore.cpp
r111566 r113678 24 24 #include "GraphicsLayer.h" 25 25 #include "TextureMapper.h" 26 27 #include "stdio.h" 26 #include "TextureMapperGL.h" 28 27 29 28 using namespace WebCore; … … 51 50 52 51 QImage qImage = m_backBuffer->createQImage(); 53 54 52 if (shouldReset) 55 53 texture->reset(m_sourceRect.size(), qImage.hasAlphaChannel() ? BitmapTexture::SupportsAlpha : 0); 56 57 texture->updateContents(qImage.constBits(), m_sourceRect); 54 texture->updateContents(qImage.constBits(), m_sourceRect, m_bitmapOffset, qImage.bytesPerLine()); 58 55 m_backBuffer.clear(); 59 56 } 60 57 61 void LayerBackingStoreTile::setBackBuffer(const WebCore::IntRect& targetRect, const WebCore::IntRect& sourceRect, ShareableBitmap* buffer)58 void LayerBackingStoreTile::setBackBuffer(const IntRect& targetRect, const IntRect& sourceRect, PassRefPtr<ShareableBitmap> buffer, const IntPoint& offset) 62 59 { 63 60 m_sourceRect = sourceRect; 64 61 m_targetRect = targetRect; 62 m_bitmapOffset = offset; 65 63 m_backBuffer = buffer; 66 64 } … … 77 75 } 78 76 79 void LayerBackingStore::updateTile(int id, const IntRect& sourceRect, const IntRect& targetRect, ShareableBitmap* backBuffer) 77 78 void LayerBackingStore::updateTile(int id, const IntRect& sourceRect, const IntRect& targetRect, PassRefPtr<ShareableBitmap> backBuffer, const IntPoint& offset) 80 79 { 81 80 HashMap<int, LayerBackingStoreTile>::iterator it = m_tiles.find(id); 82 81 ASSERT(it != m_tiles.end()); 83 it->second.setBackBuffer(targetRect, sourceRect, backBuffer );82 it->second.setBackBuffer(targetRect, sourceRect, backBuffer, offset); 84 83 } 85 84 -
trunk/Source/WebKit2/UIProcess/qt/LayerBackingStore.h
r113361 r113678 40 40 inline float scale() const { return m_scale; } 41 41 void swapBuffers(WebCore::TextureMapper*); 42 void setBackBuffer(const WebCore::IntRect&, const WebCore::IntRect&, ShareableBitmap* buffer);42 void setBackBuffer(const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableBitmap> buffer, const WebCore::IntPoint&); 43 43 44 44 private: … … 46 46 WebCore::IntRect m_sourceRect; 47 47 WebCore::IntRect m_targetRect; 48 WebCore::IntPoint m_bitmapOffset; 48 49 float m_scale; 49 50 }; … … 53 54 void createTile(int, float); 54 55 void removeTile(int); 55 void updateTile(int, const WebCore::IntRect&, const WebCore::IntRect&, ShareableBitmap*);56 void updateTile(int, const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableBitmap>, const WebCore::IntPoint&); 56 57 static PassRefPtr<LayerBackingStore> create() { return adoptRef(new LayerBackingStore); } 57 58 void commitTileOperations(WebCore::TextureMapper*); -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp
r113640 r113678 554 554 } 555 555 556 PassOwnPtr<WebCore::GraphicsContext> WebGraphicsLayer::beginContentUpdate(const WebCore::IntSize& size, ShareableBitmap::Handle& handle, WebCore::IntPoint& offset) 557 { 558 return m_webGraphicsLayerClient->beginContentUpdate(size, contentsOpaque() ? 0 : ShareableBitmap::SupportsAlpha, handle, offset); 559 } 560 556 561 void WebGraphicsLayer::createTile(int tileID, const UpdateInfo& updateInfo) 557 562 { -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h
r113640 r113678 60 60 virtual void attachLayer(WebCore::WebGraphicsLayer*) = 0; 61 61 virtual void detachLayer(WebCore::WebGraphicsLayer*) = 0; 62 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableBitmap::Handle&, WebCore::IntPoint&) = 0; 62 63 }; 63 64 } … … 129 130 virtual void updateTile(int tileID, const WebKit::UpdateInfo&); 130 131 virtual void removeTile(int tileID); 132 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, WebKit::ShareableBitmap::Handle&, WebCore::IntPoint&); 131 133 132 134 void setWebGraphicsLayerClient(WebKit::WebGraphicsLayerClient*); -
trunk/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp
r108055 r113678 73 73 return Vector<IntRect>(); 74 74 75 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(m_dirtyRect.size(), m_tiledBackingStore->supportsAlpha() ? ShareableBitmap::SupportsAlpha : 0); 76 OwnPtr<GraphicsContext> graphicsContext(bitmap->createGraphicsContext()); 75 UpdateInfo updateInfo; 76 OwnPtr<GraphicsContext> graphicsContext = m_client->beginContentUpdate(m_dirtyRect.size(), updateInfo.bitmapHandle, updateInfo.bitmapOffset); 77 if (!graphicsContext) 78 return Vector<IntRect>(); 77 79 graphicsContext->translate(-m_dirtyRect.x(), -m_dirtyRect.y()); 78 80 graphicsContext->scale(FloatSize(m_tiledBackingStore->contentsScale(), m_tiledBackingStore->contentsScale())); 79 81 m_tiledBackingStore->client()->tiledBackingStorePaint(graphicsContext.get(), m_tiledBackingStore->mapToContents(m_dirtyRect)); 80 82 81 UpdateInfo updateInfo;82 83 updateInfo.updateRectBounds = m_rect; 83 84 IntRect updateRect = m_dirtyRect; … … 85 86 updateInfo.updateRects.append(updateRect); 86 87 updateInfo.updateScaleFactor = m_tiledBackingStore->contentsScale(); 87 bitmap->createHandle(updateInfo.bitmapHandle);88 graphicsContext.release(); 88 89 89 90 static int id = 0; -
trunk/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.h
r97571 r113678 29 29 #if USE(TILED_BACKING_STORE) 30 30 31 #include "ShareableBitmap.h" 31 32 #include "Tile.h" 32 33 #include "TiledBackingStore.h" … … 79 80 virtual void updateTile(int tileID, const UpdateInfo&) = 0; 80 81 virtual void removeTile(int tileID) = 0; 82 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Handle&, WebCore::IntPoint&) = 0; 81 83 }; 82 84 -
trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
r113640 r113678 33 33 #include "LayerTreeHostProxyMessages.h" 34 34 #include "MessageID.h" 35 #include "WebCoreArgumentCoders.h" 35 36 #include "WebGraphicsLayer.h" 36 37 #include "WebPage.h" … … 330 331 } 331 332 332 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), image->currentFrameHasAlpha() ? ShareableBitmap::SupportsAlpha : 0);333 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), (image->currentFrameHasAlpha() ? ShareableBitmap::SupportsAlpha : 0)); 333 334 { 334 335 OwnPtr<WebCore::GraphicsContext> graphicsContext = bitmap->createGraphicsContext(); … … 452 453 m_waitingForUIProcess = false; 453 454 scheduleLayerFlush(); 455 for (int i = 0; i < m_updateAtlases.size(); ++i) 456 m_updateAtlases[i].didSwapBuffers(); 454 457 } 455 458 … … 466 469 467 470 ASSERT(!m_directlyCompositedImageRefCounts.size()); 471 m_updateAtlases.clear(); 472 } 473 474 UpdateAtlas& LayerTreeHostQt::getAtlas(ShareableBitmap::Flags flags) 475 { 476 for (int i = 0; i < m_updateAtlases.size(); ++i) { 477 if (m_updateAtlases[i].flags() == flags) 478 return m_updateAtlases[i]; 479 } 480 static const int ScratchBufferDimension = 2000; 481 m_updateAtlases.append(UpdateAtlas(ScratchBufferDimension, flags)); 482 return m_updateAtlases.last(); 483 } 484 485 PassOwnPtr<WebCore::GraphicsContext> LayerTreeHostQt::beginContentUpdate(const WebCore::IntSize& size, ShareableBitmap::Flags flags, ShareableBitmap::Handle& handle, WebCore::IntPoint& offset) 486 { 487 UpdateAtlas& atlas = getAtlas(flags); 488 if (!atlas.bitmap()->createHandle(handle)) 489 return PassOwnPtr<WebCore::GraphicsContext>(); 490 491 // This will return null if there is no available buffer. 492 OwnPtr<WebCore::GraphicsContext> graphicsContext = atlas.beginPaintingOnAvailableBuffer(size, offset); 493 if (!graphicsContext) 494 return PassOwnPtr<WebCore::GraphicsContext>(); 495 496 return graphicsContext.release(); 468 497 } 469 498 -
trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h
r113640 r113678 24 24 #include "LayerTreeHost.h" 25 25 #include "Timer.h" 26 #include "UpdateAtlas.h" 26 27 #include "WebGraphicsLayer.h" 27 28 #include <WebCore/GraphicsLayerClient.h> … … 77 78 virtual void detachLayer(WebCore::WebGraphicsLayer*); 78 79 80 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableBitmap::Handle&, WebCore::IntPoint&); 81 79 82 protected: 80 83 explicit LayerTreeHostQt(WebPage*); … … 96 99 void sendLayersToUI(); 97 100 101 UpdateAtlas& getAtlas(ShareableBitmap::Flags); 102 98 103 OwnPtr<WebCore::GraphicsLayer> m_rootLayer; 99 104 … … 106 111 HashSet<WebCore::WebGraphicsLayer*> m_registeredLayers; 107 112 HashMap<int64_t, int> m_directlyCompositedImageRefCounts; 113 Vector<UpdateAtlas> m_updateAtlases; 108 114 109 115 bool m_notifyAfterScheduledLayerFlush;
Note: See TracChangeset
for help on using the changeset viewer.