Changeset 137481 in webkit
- Timestamp:
- Dec 12, 2012 10:32:01 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r137480 r137481 1 2012-12-12 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 3 [Qt] Animation fails on large layers 4 https://bugs.webkit.org/show_bug.cgi?id=104538 5 6 Reviewed by Noam Rosenthal. 7 8 The backing tiles had no upper limit defined for the non-GL backend, which could cause them 9 to allocate pixmaps widier or higher than what the underlying graphics systems can handle. 10 11 On top of that GraphicsLayerTextureMapper::prepareBackingStore() would allocate an intermediate 12 pixmap the size of the dirty rect, which would at least on the first paint be the size of the 13 entire layer, again causing allocation of pixmaps with dimensions outside of platform bounds. 14 15 This patch introduces a limit to the size of image buffer tiles, and adds an alternative path 16 for painting where the GraphicsLayer paints directly to the tile instead of over an intermediate 17 pixmap. This alternative path can also be useful later to minimize the amount of pixel copying 18 happening in full repaints. 19 20 * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp: 21 (WebCore::GraphicsLayerTextureMapper::prepareBackingStore): 22 * platform/graphics/texmap/GraphicsLayerTextureMapper.h: 23 (GraphicsLayerTextureMapper): 24 * platform/graphics/texmap/TextureMapper.cpp: 25 (WebCore::BitmapTexture::updateContents): 26 * platform/graphics/texmap/TextureMapper.h: 27 (BitmapTexture): 28 (TextureMapper): 29 * platform/graphics/texmap/TextureMapperBackingStore.cpp: 30 (WebCore::TextureMapperTile::updateContents): 31 (WebCore::TextureMapperTiledBackingStore::updateContents): 32 * platform/graphics/texmap/TextureMapperBackingStore.h: 33 (TextureMapperTile): 34 (TextureMapperTiledBackingStore): 35 * platform/graphics/texmap/TextureMapperImageBuffer.cpp: 36 (WebCore::BitmapTextureImageBuffer::updateContents): 37 (WebCore::TextureMapperImageBuffer::maxTextureSize): 38 * platform/graphics/texmap/TextureMapperImageBuffer.h: 39 (BitmapTextureImageBuffer): 40 1 41 2012-12-12 Aaron Colwell <acolwell@chromium.org> 2 42 -
trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
r137362 r137481 467 467 m_backingStore = TextureMapperTiledBackingStore::create(); 468 468 469 // Paint the entire dirty rect into an image buffer. This ensures we only paint once. 470 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(dirtyRect.size()); 471 GraphicsContext* context = imageBuffer->context(); 472 context->setImageInterpolationQuality(textureMapper->imageInterpolationQuality()); 473 context->setTextDrawingMode(textureMapper->textDrawingMode()); 474 context->translate(-dirtyRect.x(), -dirtyRect.y()); 475 paintGraphicsLayerContents(*context, dirtyRect); 476 477 if (isShowingRepaintCounter()) { 469 ASSERT(dynamic_cast<TextureMapperTiledBackingStore*>(m_backingStore.get())); 470 TextureMapperTiledBackingStore* backingStore = static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get()); 471 472 if (isShowingRepaintCounter()) 478 473 incrementRepaintCount(); 479 drawRepaintCounter(context); 480 } 481 482 RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore); 483 #if PLATFORM(QT) 484 ASSERT(dynamic_cast<TextureMapperTiledBackingStore*>(m_backingStore.get())); 485 #endif 486 TextureMapperTiledBackingStore* backingStore = static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get()); 487 backingStore->updateContents(textureMapper, image.get(), m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData); 474 475 // Paint into an intermediate buffer to avoid painting content more than once. 476 bool paintOnce = true; 477 const IntSize maxTextureSize = textureMapper->maxTextureSize(); 478 // We need to paint directly if the dirty rect exceeds one of the maximum dimensions. 479 if (dirtyRect.width() > maxTextureSize.width() || dirtyRect.height() > maxTextureSize.height()) 480 paintOnce = false; 481 482 if (paintOnce) { 483 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(dirtyRect.size()); 484 GraphicsContext* context = imageBuffer->context(); 485 context->setImageInterpolationQuality(textureMapper->imageInterpolationQuality()); 486 context->setTextDrawingMode(textureMapper->textDrawingMode()); 487 context->translate(-dirtyRect.x(), -dirtyRect.y()); 488 paintGraphicsLayerContents(*context, dirtyRect); 489 490 if (isShowingRepaintCounter()) 491 drawRepaintCounter(context); 492 493 RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore); 494 backingStore->updateContents(textureMapper, image.get(), m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData); 495 } else 496 backingStore->updateContents(textureMapper, this, m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData); 488 497 489 498 backingStore->setShowDebugBorders(isShowingDebugBorder()); -
trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
r136781 r137481 98 98 bool fixedToViewport() const { return m_fixedToViewport; } 99 99 100 void drawRepaintCounter(GraphicsContext*); 100 101 private: 101 102 virtual void willBeDestroyed(); … … 105 106 void prepareBackingStore(); 106 107 bool shouldHaveBackingStore() const; 107 void drawRepaintCounter(GraphicsContext*);108 108 void animationStartedTimerFired(Timer<GraphicsLayerTextureMapper>*); 109 109 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
r137442 r137481 21 21 #include "TextureMapper.h" 22 22 23 #include "GraphicsLayer.h" 23 24 #include "TextureMapperImageBuffer.h" 24 25 #include "Timer.h" … … 146 147 { } 147 148 149 void BitmapTexture::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag) 150 { 151 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(targetRect.size()); 152 GraphicsContext* context = imageBuffer->context(); 153 context->setImageInterpolationQuality(textureMapper->imageInterpolationQuality()); 154 context->setTextDrawingMode(textureMapper->textDrawingMode()); 155 156 IntRect sourceRect(targetRect); 157 sourceRect.setLocation(offset); 158 context->translate(-offset.x(), -offset.y()); 159 sourceLayer->paintGraphicsLayerContents(*context, sourceRect); 160 161 RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore); 162 163 updateContents(image.get(), targetRect, IntPoint(), updateContentsFlag); 148 164 } 165 166 } // namespace 167 149 168 #endif -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h
r135056 r137481 50 50 class BitmapTexturePool; 51 51 class CustomFilterProgram; 52 class GraphicsLayer; 52 53 class TextureMapper; 53 54 54 55 // A 2D texture that can be the target of software or GL rendering. 55 class BitmapTexture 56 class BitmapTexture : public RefCounted<BitmapTexture> { 56 57 public: 57 58 enum Flag { … … 76 77 virtual IntSize size() const = 0; 77 78 virtual void updateContents(Image*, const IntRect&, const IntPoint& offset, UpdateContentsFlag) = 0; 79 virtual void updateContents(TextureMapper*, GraphicsLayer*, const IntRect& target, const IntPoint& offset, UpdateContentsFlag); 78 80 virtual void updateContents(const void*, const IntRect& target, const IntPoint& offset, int bytesPerLine, UpdateContentsFlag) = 0; 79 81 virtual bool isValid() const = 0; … … 152 154 virtual void endPainting() { } 153 155 154 virtual IntSize maxTextureSize() const { return IntSize(INT_MAX, INT_MAX); }156 virtual IntSize maxTextureSize() const = 0; 155 157 156 158 virtual PassRefPtr<BitmapTexture> acquireTextureFromPool(const IntSize&); -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp
r135517 r137481 79 79 80 80 m_texture->updateContents(image, targetRect, sourceOffset, updateContentsFlag); 81 } 82 83 void TextureMapperTile::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag) 84 { 85 IntRect targetRect = enclosingIntRect(m_rect); 86 targetRect.intersect(dirtyRect); 87 if (targetRect.isEmpty()) 88 return; 89 IntPoint sourceOffset = targetRect.location(); 90 91 // Normalize targetRect to the texture's coordinates. 92 targetRect.move(-m_rect.x(), -m_rect.y()); 93 94 if (!m_texture) { 95 m_texture = textureMapper->createTexture(); 96 m_texture->reset(targetRect.size(), BitmapTexture::SupportsAlpha); 97 } 98 99 m_texture->updateContents(textureMapper, sourceLayer, targetRect, sourceOffset, updateContentsFlag); 81 100 } 82 101 … … 198 217 } 199 218 219 void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag) 220 { 221 createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), true); 222 for (size_t i = 0; i < m_tiles.size(); ++i) 223 m_tiles[i].updateContents(textureMapper, sourceLayer, dirtyRect, updateContentsFlag); 224 } 225 200 226 PassRefPtr<BitmapTexture> TextureMapperTiledBackingStore::texture() const 201 227 { -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h
r135517 r137481 74 74 75 75 void updateContents(TextureMapper*, Image*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData); 76 void updateContents(TextureMapper*, GraphicsLayer*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData); 76 77 virtual void paint(TextureMapper*, const TransformationMatrix&, float, BitmapTexture*, const unsigned exposedEdges); 77 78 virtual ~TextureMapperTile() { } … … 95 96 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) OVERRIDE; 96 97 void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag); 98 void updateContents(TextureMapper*, GraphicsLayer*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag); 97 99 98 100 void setContentsToImage(Image* image) { m_image = image; } -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
r137463 r137481 22 22 23 23 #include "FilterEffectRenderer.h" 24 #include "GraphicsLayer.h" 24 25 #if PLATFORM(QT) 25 26 #include "NativeImageQt.h" … … 29 30 #if USE(TEXTURE_MAPPER) 30 31 namespace WebCore { 32 33 static const int s_maximumAllowedImageBufferDimension = 4096; 31 34 32 35 void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag) … … 55 58 } 56 59 60 void BitmapTextureImageBuffer::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& sourceOffset, UpdateContentsFlag) 61 { 62 GraphicsContext* context = m_image->context(); 63 64 context->clearRect(targetRect); 65 66 IntRect sourceRect(targetRect); 67 sourceRect.setLocation(sourceOffset); 68 context->save(); 69 context->translate(targetRect.x() - sourceOffset.x(), targetRect.y() - sourceOffset.y()); 70 sourceLayer->paintGraphicsLayerContents(*context, sourceRect); 71 context->restore(); 72 } 73 57 74 void BitmapTextureImageBuffer::didReset() 58 75 { … … 63 80 { 64 81 m_image->context()->drawImage(image, ColorSpaceDeviceRGB, targetRect, IntRect(offset, targetRect.size()), CompositeCopy); 82 } 83 84 IntSize TextureMapperImageBuffer::maxTextureSize() const 85 { 86 return IntSize(s_maximumAllowedImageBufferDimension, s_maximumAllowedImageBufferDimension); 65 87 } 66 88 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
r134671 r137481 36 36 inline GraphicsContext* graphicsContext() { return m_image ? m_image->context() : 0; } 37 37 virtual void updateContents(Image*, const IntRect&, const IntPoint&, UpdateContentsFlag); 38 virtual void updateContents(TextureMapper*, GraphicsLayer*, const IntRect& target, const IntPoint& offset, UpdateContentsFlag); 38 39 virtual void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag); 39 40 #if ENABLE(CSS_FILTERS) … … 66 67 virtual void bindSurface(BitmapTexture* surface) OVERRIDE { m_currentSurface = surface;} 67 68 virtual void endClip() OVERRIDE { graphicsContext()->restore(); } 69 virtual IntSize maxTextureSize() const; 68 70 virtual PassRefPtr<BitmapTexture> createTexture() OVERRIDE { return BitmapTextureImageBuffer::create(); } 69 71
Note: See TracChangeset
for help on using the changeset viewer.