Changeset 148748 in webkit
- Timestamp:
- Apr 19, 2013 9:01:25 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r148743 r148748 1 2013-04-19 Noam Rosenthal <noam@webkit.org> 2 3 [Texmap] Implementation for pattern compositing 4 https://bugs.webkit.org/show_bug.cgi?id=109588 5 6 Reviewed by Allan Sandfeld Jensen. 7 8 Enable pattern compositing (background images) for CoordinatedGraphics/TextureMapperGL. 9 Use the existing patternTransform shader uniform, multiplying it by a matrix calculated 10 using the contentsRect, tileSize and tilePhase. 11 12 Covered by existing tests in compositing/patterns. 13 14 * platform/graphics/GraphicsLayer.h: 15 (GraphicsLayer): 16 Conditionally enable pattern compositing for coordinated graphics. 17 18 * platform/graphics/texmap/TextureMapper.cpp: 19 (WebCore::TextureMapper::TextureMapper): 20 * platform/graphics/texmap/TextureMapper.h: 21 (WebCore::TextureMapper::setPatternTransform): 22 (WebCore::TextureMapper::setWrapMode): 23 (WebCore::TextureMapper::wrapMode): 24 (WebCore::TextureMapper::patternTransform): 25 Add wrapMode and patternTransform properties to the TextureMapper state. 26 27 * platform/graphics/texmap/TextureMapperGL.cpp: 28 (WebCore::TextureMapperGL::drawTexturedQuadWithProgram): 29 Paint with GL_REPEAT and a pattern transform when needed. 30 31 * platform/graphics/texmap/TextureMapperLayer.cpp: 32 (WebCore::TextureMapperLayer::computePatternTransformIfNeeded): 33 (WebCore): 34 (WebCore::TextureMapperLayer::paintSelf): 35 (WebCore::TextureMapperLayer::setContentsRect): 36 (WebCore::TextureMapperLayer::setContentsTileSize): 37 (WebCore::TextureMapperLayer::setContentsTilePhase): 38 Apply the patternTransform from the tile size/phase. 39 40 * platform/graphics/texmap/TextureMapperLayer.h: 41 (WebCore::TextureMapperLayer::TextureMapperLayer): 42 (TextureMapperLayer): 43 (WebCore::TextureMapperLayer::setShouldMapBackingStoreToContentsRect): 44 (State): 45 (WebCore::TextureMapperLayer::State::State): 46 Allow the client to configure whether a layer uses its bounds or its 47 contents rect to paint the backing store. 48 This is needed now since layers with background images, unlike layers 49 with regular images, may have bounds that are greater than the contents 50 rect. 51 52 * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp: 53 (WebCore::CoordinatedGraphicsLayer::setContentsTileSize): 54 (WebCore): 55 (WebCore::CoordinatedGraphicsLayer::setContentsTilePhase): 56 (WebCore::CoordinatedGraphicsLayer::setShouldSupportContentsTiling): 57 (WebCore::GraphicsLayer::supportsContentsTiling): 58 * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h: 59 (CoordinatedGraphicsLayer): 60 * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp: 61 (WebCore::CoordinatedGraphicsScene::setLayerState): 62 (WebCore::CoordinatedGraphicsScene::assignImageBackingToLayer): 63 * platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h: 64 (CoordinatedGraphicsLayerState): 65 Logic to pass the tileSize/tilePhase from CoordinatedGraphicsLayer 66 to TextureMapperLayer. 67 68 * rendering/RenderLayerBacking.cpp: 69 (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage): 70 Don't reset the layer's image contents when this is a directly composited image. 71 1 72 2013-04-19 ChangSeok Oh <changseok.oh@collabora.com> 2 73 -
trunk/Source/WebCore/platform/graphics/GraphicsLayer.h
r148172 r148748 444 444 } 445 445 446 #if USE(COORDINATED_GRAPHICS) 447 static bool supportsContentsTiling(); 448 #else 446 449 static bool supportsContentsTiling() 447 450 { … … 449 452 return false; 450 453 } 454 #endif 451 455 452 456 void updateDebugIndicators(); -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
r146640 r148748 144 144 , m_accelerationMode(accelerationMode) 145 145 , m_isMaskMode(false) 146 , m_wrapMode(StretchWrap) 146 147 { } 147 148 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h
r146640 r148748 116 116 PaintingMirrored = 1 << 0, 117 117 }; 118 119 enum WrapMode { 120 StretchWrap, 121 RepeatWrap 122 }; 123 118 124 typedef unsigned PaintFlags; 119 125 … … 164 170 #endif 165 171 172 void setPatternTransform(const TransformationMatrix& p) { m_patternTransform = p; } 173 void setWrapMode(WrapMode m) { m_wrapMode = m; } 174 166 175 protected: 167 176 explicit TextureMapper(AccelerationMode); … … 170 179 171 180 bool isInMaskMode() const { return m_isMaskMode; } 181 WrapMode wrapMode() const { return m_wrapMode; } 182 const TransformationMatrix& patternTransform() const { return m_patternTransform; } 172 183 173 184 private: … … 185 196 AccelerationMode m_accelerationMode; 186 197 bool m_isMaskMode; 198 TransformationMatrix m_patternTransform; 199 WrapMode m_wrapMode; 187 200 }; 188 201 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
r148115 r148748 549 549 m_context3D->bindTexture(target, texture); 550 550 m_context3D->uniform1i(program->samplerLocation(), 0); 551 552 TransformationMatrix patternTransform; 551 if (wrapMode() == RepeatWrap) { 552 m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::REPEAT); 553 m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::REPEAT); 554 } 555 556 TransformationMatrix patternTransform = this->patternTransform(); 553 557 if (flags & ShouldFlipTexture) 554 558 patternTransform.flipY(); … … 565 569 566 570 draw(rect, modelViewMatrix, program, GraphicsContext3D::TRIANGLE_FAN, flags); 571 m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); 572 m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); 567 573 } 568 574 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
r148090 r148748 100 100 } 101 101 102 void TextureMapperLayer::computePatternTransformIfNeeded() 103 { 104 if (!m_patternTransformDirty) 105 return; 106 107 m_patternTransformDirty = false; 108 m_patternTransform = 109 TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_state.contentsTileSize), m_state.contentsRect) 110 .multiply(TransformationMatrix().translate(m_state.contentsTilePhase.x() / m_state.contentsRect.width(), m_state.contentsTilePhase.y() / m_state.contentsRect.height())); 111 } 112 102 113 void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options) 103 114 { … … 111 122 transform.multiply(m_currentTransform.combined()); 112 123 113 if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() ) {124 if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() && m_state.solidColor.alpha()) { 114 125 options.textureMapper->drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, options.opacity)); 115 126 if (m_state.showDebugBorders) … … 118 129 } 119 130 131 options.textureMapper->setWrapMode(TextureMapper::StretchWrap); 132 options.textureMapper->setPatternTransform(TransformationMatrix()); 133 134 if (!m_state.contentsTileSize.isEmpty()) { 135 computePatternTransformIfNeeded(); 136 options.textureMapper->setWrapMode(TextureMapper::RepeatWrap); 137 options.textureMapper->setPatternTransform(m_patternTransform); 138 } 139 120 140 if (m_backingStore) { 121 141 ASSERT(m_state.drawsContent && m_state.contentsVisible && !m_state.size.isEmpty()); 122 ASSERT(!layerRect().isEmpty()); 123 m_backingStore->paintToTextureMapper(options.textureMapper, layerRect(), transform, options.opacity); 142 FloatRect targetRect = m_state.shouldMapBackingStoreToContentsRect ? m_state.contentsRect : layerRect(); 143 ASSERT(!targetRect.isEmpty()); 144 m_backingStore->paintToTextureMapper(options.textureMapper, targetRect, transform, options.opacity); 124 145 if (m_state.showDebugBorders) 125 m_backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);146 m_backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, targetRect, transform); 126 147 // Only draw repaint count for the main backing store. 127 148 if (m_state.showRepaintCounter) 128 m_backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, layerRect(), transform); 129 } 130 131 if (m_contentsLayer) { 132 ASSERT(!layerRect().isEmpty()); 133 m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity); 134 if (m_state.showDebugBorders) 135 m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform); 136 } 149 m_backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, targetRect, transform); 150 } 151 152 if (!m_contentsLayer) 153 return; 154 155 ASSERT(!layerRect().isEmpty()); 156 m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity); 157 if (m_state.showDebugBorders) 158 m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform); 137 159 } 138 160 … … 552 574 void TextureMapperLayer::setContentsRect(const IntRect& contentsRect) 553 575 { 576 if (contentsRect == m_state.contentsRect) 577 return; 554 578 m_state.contentsRect = contentsRect; 579 m_patternTransformDirty = true; 580 } 581 582 void TextureMapperLayer::setContentsTileSize(const IntSize& size) 583 { 584 if (size == m_state.contentsTileSize) 585 return; 586 m_state.contentsTileSize = size; 587 m_patternTransformDirty = true; 588 } 589 590 void TextureMapperLayer::setContentsTilePhase(const IntPoint& phase) 591 { 592 if (phase == m_state.contentsTilePhase) 593 return; 594 m_state.contentsTilePhase = phase; 595 m_patternTransformDirty = true; 555 596 } 556 597 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
r148437 r148748 57 57 , m_scrollClient(0) 58 58 , m_isScrollable(false) 59 , m_patternTransformDirty(false) 59 60 { } 60 61 … … 99 100 void setOpacity(float); 100 101 void setSolidColor(const Color&); 102 void setContentsTileSize(const IntSize&); 103 void setContentsTilePhase(const IntPoint&); 101 104 #if ENABLE(CSS_FILTERS) 102 105 void setFilters(const FilterOperations&); … … 120 123 bool fixedToViewport() const { return m_fixedToViewport; } 121 124 void setBackingStore(PassRefPtr<TextureMapperBackingStore>); 125 void setShouldMapBackingStoreToContentsRect(bool m) { m_state.shouldMapBackingStoreToContentsRect = m; } 122 126 123 127 void syncAnimations(); … … 159 163 void paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions&); 160 164 void applyMask(const TextureMapperPaintOptions&); 165 void computePatternTransformIfNeeded(); 161 166 162 167 // GraphicsLayerAnimation::Client … … 207 212 float opacity; 208 213 FloatRect contentsRect; 214 IntSize contentsTileSize; 215 IntPoint contentsTilePhase; 209 216 TextureMapperLayer* maskLayer; 210 217 TextureMapperLayer* replicaLayer; … … 226 233 bool showDebugBorders : 1; 227 234 bool showRepaintCounter : 1; 235 bool shouldMapBackingStoreToContentsRect : 1; 228 236 229 237 State() … … 242 250 , showDebugBorders(false) 243 251 , showRepaintCounter(false) 252 , shouldMapBackingStoreToContentsRect(false) 244 253 { 245 254 } … … 256 265 FloatSize m_userScrollOffset; 257 266 FloatSize m_accumulatedScrollOffsetFractionalPart; 267 TransformationMatrix m_patternTransform; 268 bool m_patternTransformDirty; 258 269 }; 259 270 -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
r147745 r148748 341 341 } 342 342 343 void CoordinatedGraphicsLayer::setContentsTileSize(const IntSize& s) 344 { 345 if (contentsTileSize() == s) 346 return; 347 348 GraphicsLayer::setContentsTileSize(s); 349 m_layerState.contentsTileSize = s; 350 m_layerState.contentsTilingChanged = true; 351 didChangeLayerState(); 352 } 353 354 void CoordinatedGraphicsLayer::setContentsTilePhase(const IntPoint& p) 355 { 356 if (contentsTilePhase() == p) 357 return; 358 359 GraphicsLayer::setContentsTilePhase(p); 360 m_layerState.contentsTilePhase = p; 361 m_layerState.contentsTilingChanged = true; 362 didChangeLayerState(); 363 } 364 365 static bool s_shouldSupportContentsTiling = false; 366 367 void CoordinatedGraphicsLayer::setShouldSupportContentsTiling(bool s) 368 { 369 s_shouldSupportContentsTiling = s; 370 } 371 372 bool GraphicsLayer::supportsContentsTiling() 373 { 374 return s_shouldSupportContentsTiling; 375 } 376 343 377 void CoordinatedGraphicsLayer::setContentsNeedsDisplay() 344 378 { -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
r145670 r148748 87 87 virtual void setOpacity(float) OVERRIDE; 88 88 virtual void setContentsRect(const IntRect&) OVERRIDE; 89 virtual void setContentsTilePhase(const IntPoint&) OVERRIDE; 90 virtual void setContentsTileSize(const IntSize&) OVERRIDE; 89 91 virtual void setContentsToImage(Image*) OVERRIDE; 90 92 virtual void setContentsToSolidColor(const Color&) OVERRIDE; … … 146 148 bool hasPendingVisibleChanges(); 147 149 150 static void setShouldSupportContentsTiling(bool); 151 148 152 private: 149 153 #if USE(GRAPHICS_SURFACE) -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
r148433 r148748 324 324 layer->setContentsRect(layerState.contentsRect); 325 325 326 if (layerState.contentsTilingChanged) { 327 layer->setContentsTilePhase(layerState.contentsTilePhase); 328 layer->setContentsTileSize(layerState.contentsTileSize); 329 } 330 326 331 if (layerState.opacityChanged) 327 332 layer->setOpacity(layerState.opacity); … … 580 585 if (imageID == InvalidCoordinatedImageBackingID) { 581 586 layer->setBackingStore(0); 582 return; 583 } 587 layer->setShouldMapBackingStoreToContentsRect(false); 588 return; 589 } 590 584 591 ImageBackingMap::iterator it = m_imageBackings.find(imageID); 585 592 ASSERT(it != m_imageBackings.end()); 586 593 layer->setBackingStore(it->value.get()); 594 layer->setShouldMapBackingStoreToContentsRect(true); 587 595 } 588 596 -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h
r148430 r148748 94 94 bool isScrollableChanged: 1; 95 95 bool committedScrollOffsetChanged: 1; 96 bool contentsTilingChanged: 1; 96 97 }; 97 98 unsigned changeMask; … … 142 143 TransformationMatrix childrenTransform; 143 144 IntRect contentsRect; 145 IntPoint contentsTilePhase; 146 IntSize contentsTileSize; 144 147 float opacity; 145 148 Color solidColor; -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r148487 r148748 1447 1447 return; 1448 1448 1449 if (isDirectlyCompositedImage()) 1450 return; 1451 1449 1452 const RenderStyle* style = renderer()->style(); 1450 1453 -
trunk/Source/WebKit2/ChangeLog
r148719 r148748 1 2013-04-19 Noam Rosenthal <noam@webkit.org> 2 3 [Texmap] Implementation for pattern compositing 4 https://bugs.webkit.org/show_bug.cgi?id=109588 5 6 Reviewed by Allan Sandfeld Jensen. 7 8 Serialize the two new properties from CoordinatedGraphicsLayer to CoordinatedGraphicsScene. 9 10 * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp: 11 (CoreIPC::::encode): 12 (CoreIPC::::decode): 13 Encode/decode the new tiling properties. 14 15 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp: 16 (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost): 17 Enable pattern compositing for coordinated graphics. 18 This is needed since we don't want to enable pattern compositing for 19 WebKit1 yet. 20 1 21 2013-04-18 Tim Horton <timothy_horton@apple.com> 2 22 -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
r148430 r148748 850 850 encoder << state.contentsRect; 851 851 852 if (state.contentsTilingChanged) { 853 encoder << state.contentsTileSize; 854 encoder << state.contentsTilePhase; 855 } 856 852 857 if (state.opacityChanged) 853 858 encoder << state.opacity; … … 929 934 return false; 930 935 936 if (state.contentsTilingChanged) { 937 if (!decoder.decode(state.contentsTileSize)) 938 return false; 939 if (!decoder.decode(state.contentsTilePhase)) 940 return false; 941 } 942 931 943 if (state.opacityChanged && !decoder.decode(state.opacity)) 932 944 return false; -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
r148536 r148748 122 122 CoordinatedSurface::setFactory(createCoordinatedSurface); 123 123 124 // This is a temporary way to enable this only in the GL case, until TextureMapperImageBuffer is removed. 125 // See https://bugs.webkit.org/show_bug.cgi?id=114869 126 CoordinatedGraphicsLayer::setShouldSupportContentsTiling(true); 127 124 128 if (m_webPage->hasPageOverlay()) 125 129 createPageOverlayLayer();
Note: See TracChangeset
for help on using the changeset viewer.