Changeset 83915 in webkit
- Timestamp:
- Apr 14, 2011 5:16:51 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r83914 r83915 1 2011-04-14 Adrienne Walker <enne@google.com> 2 3 Reviewed by James Robinson. 4 5 [chromium] Tile content and image layers 6 https://bugs.webkit.org/show_bug.cgi?id=57113 7 8 Rebaseline a number of image tests where slight filtering differences 9 from using tiles caused test failures with exact pixel matching. 10 None of these results are perceptually different. 11 12 * platform/chromium-gpu-linux/compositing/color-matching/image-color-matching-expected.checksum: 13 * platform/chromium-gpu-linux/compositing/color-matching/image-color-matching-expected.png: 14 * platform/chromium-gpu-linux/compositing/text-on-large-layer-expected.checksum: 15 * platform/chromium-gpu-linux/compositing/text-on-large-layer-expected.png: 16 * platform/chromium-gpu-linux/fast/canvas/canvas-text-alignment-expected.checksum: 17 * platform/chromium-gpu-linux/fast/canvas/canvas-text-alignment-expected.png: 18 * platform/chromium-gpu-linux/fast/canvas/canvas-text-baseline-expected.checksum: 19 * platform/chromium-gpu-linux/fast/canvas/canvas-text-baseline-expected.png: 20 * platform/chromium-gpu-mac/compositing/color-matching/image-color-matching-expected.checksum: 21 * platform/chromium-gpu-mac/compositing/color-matching/image-color-matching-expected.png: 22 * platform/chromium-gpu-mac/compositing/text-on-large-layer-expected.checksum: 23 * platform/chromium-gpu-mac/compositing/text-on-large-layer-expected.png: 24 * platform/chromium-gpu-win/compositing/color-matching/image-color-matching-expected.checksum: 25 * platform/chromium-gpu-win/compositing/color-matching/image-color-matching-expected.png: 26 * platform/chromium-gpu-win/compositing/text-on-large-layer-expected.checksum: 27 * platform/chromium-gpu-win/compositing/text-on-large-layer-expected.png: 28 * platform/chromium-gpu-win/fast/canvas/canvas-text-alignment-expected.checksum: 29 * platform/chromium-gpu-win/fast/canvas/canvas-text-alignment-expected.png: 30 * platform/chromium-gpu-win/fast/canvas/canvas-text-baseline-expected.checksum: 31 * platform/chromium-gpu-win/fast/canvas/canvas-text-baseline-expected.png: 32 * platform/chromium/test_expectations.txt: 33 1 34 2011-04-14 James Robinson <jamesr@chromium.org> 2 35 -
trunk/LayoutTests/platform/chromium-gpu-linux/compositing/color-matching/image-color-matching-expected.checksum
r83511 r83915 1 23fa4ef4d069718cee8dd5120b6271df 1 9af568c8084f3cf8d2a614f2324804cc -
trunk/LayoutTests/platform/chromium-gpu-linux/compositing/text-on-large-layer-expected.checksum
r83511 r83915 1 fe58e58bc0287ef9549722f0417b0ccb 1 c85d12f4ff9c8e9791b9a111cc3a137e -
trunk/LayoutTests/platform/chromium-gpu-linux/fast/canvas/canvas-text-alignment-expected.checksum
r79381 r83915 1 d7da5c3c67c61c23c2b24aef3572cd52 1 f10ff733898353c29ed21bd6928fe08b -
trunk/LayoutTests/platform/chromium-gpu-linux/fast/canvas/canvas-text-baseline-expected.checksum
r70582 r83915 1 f330ab78aeb1f176c8bec4bbd1ce86b3 1 8ead55d188ea374c96a4437b9786cce2 -
trunk/LayoutTests/platform/chromium-gpu-mac/compositing/color-matching/image-color-matching-expected.checksum
r83511 r83915 1 8acef2a5710b4f87f2594b4a2ac8af75 1 a563248737d41f703e528054e0155279 -
trunk/LayoutTests/platform/chromium-gpu-mac/compositing/text-on-large-layer-expected.checksum
r83511 r83915 1 24766181b479126107feb69ad08af8e8 1 0f39e5e414500af54dad1f8f99e168a3 -
trunk/LayoutTests/platform/chromium-gpu-win/compositing/color-matching/image-color-matching-expected.checksum
r83511 r83915 1 e8c3f969c3ebff9dfc70ee48dbb40d0f 1 143d90ea374a99cc25c0dff7899bf0f1 -
trunk/LayoutTests/platform/chromium-gpu-win/compositing/text-on-large-layer-expected.checksum
r83511 r83915 1 3f83e7406a50d10563080040019f7fe0 1 00ec487b9eec64bd3957def11c93f46d -
trunk/LayoutTests/platform/chromium-gpu-win/fast/canvas/canvas-text-alignment-expected.checksum
r79381 r83915 1 c5f11c49a9d8d97e566c520a06d1a5f5 1 fee76e0b4356bb41329d9964150322e8 -
trunk/LayoutTests/platform/chromium-gpu-win/fast/canvas/canvas-text-baseline-expected.checksum
r70582 r83915 1 d4f4655eef150d04c51f34a91ee034a5 1 3cac80d01fdebff0e8d6351d392f5476 -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r83914 r83915 3090 3090 3091 3091 // Seems to blend scrollbars very slightly differently in debug vs. release. 3092 BUGWK58587 DEBUG GPU LINUX : compositing/geometry/horizontal-scroll-composited.html = IMAGE 3092 // Commented out because BUGWK57113 supersedes it below. 3093 //BUGWK58587 DEBUG GPU LINUX : compositing/geometry/horizontal-scroll-composited.html = IMAGE 3093 3094 BUGWK58587 DEBUG GPU LINUX : fast/canvas/image-object-in-canvas.html = IMAGE 3094 3095 BUGWK58587 DEBUG GPU LINUX : media/video-zoom.html = IMAGE … … 3486 3487 3487 3488 BUGCROGERS WIN LINUX : fast/text/zero-font-size.html = IMAGE+TEXT 3489 3490 // Temporarily marked failing for rebaselining. 3491 BUGWK57113 GPU : compositing/geometry/fixed-position.html = FAIL 3492 BUGWK57113 GPU : compositing/geometry/horizontal-scroll-composited.html = FAIL 3493 BUGWK57113 GPU : compositing/geometry/vertical-scroll-composited.html = FAIL 3494 BUGWK57113 GPU : compositing/tiling/huge-layer-img.html = FAIL 3495 BUGWK57113 GPU : compositing/overflow/fixed-position-ancestor-clip.html = FAIL 3496 BUGWK57113 GPU : compositing/overflow/overflow-scroll.html = FAIL 3497 BUGWK57113 GPU : platform/chromium/compositing/huge-layer-rotated.html = FAIL -
trunk/Source/WebCore/ChangeLog
r83914 r83915 1 2011-04-14 Adrienne Walker <enne@google.com> 2 3 Reviewed by James Robinson. 4 5 [chromium] Tile content and image layers 6 https://bugs.webkit.org/show_bug.cgi?id=57113 7 8 Layers tile by default if any dimension is larger than 512. Smaller 9 layers are contained within a single texture but still use the tiler 10 infrastructure so that there's only one code path. 11 12 Remove large layer support from content layers. Content layers no 13 longer own a platform canvas--they own a tiler. Refactor tiler to 14 allow for better separation of update/upload/paint. Add rect 15 parameter to update and draw functions on layers for the layer-space 16 rect of interest. This is necessary to know which tiles need to be 17 drawn. 18 19 * platform/graphics/chromium/ContentLayerChromium.cpp: 20 (WebCore::ContentLayerChromium::ContentLayerChromium): 21 (WebCore::ContentLayerChromium::~ContentLayerChromium): 22 (WebCore::ContentLayerPainter::ContentLayerPainter): 23 (WebCore::ContentLayerPainter::paint): 24 (WebCore::ContentLayerChromium::paintContentsIfDirty): 25 (WebCore::ContentLayerChromium::setLayerRenderer): 26 (WebCore::ContentLayerChromium::tilingTransform): 27 (WebCore::ContentLayerChromium::visibleLayerRect): 28 (WebCore::ContentLayerChromium::layerBounds): 29 (WebCore::ContentLayerChromium::updateLayerSize): 30 (WebCore::ContentLayerChromium::draw): 31 (WebCore::ContentLayerChromium::createTilerIfNeeded): 32 (WebCore::ContentLayerChromium::updateCompositorResources): 33 (WebCore::ContentLayerChromium::setTilingOption): 34 (WebCore::ContentLayerChromium::bindContentsTexture): 35 (WebCore::ContentLayerChromium::unreserveContentsTexture): 36 (WebCore::ContentLayerChromium::setIsMask): 37 (WebCore::ContentLayerChromium::dumpLayerProperties): 38 * platform/graphics/chromium/ContentLayerChromium.h: 39 (WebCore::ContentLayerChromium::drawsContent): 40 * platform/graphics/chromium/GraphicsLayerChromium.cpp: 41 (WebCore::GraphicsLayerChromium::setMaskLayer): 42 * platform/graphics/chromium/ImageLayerChromium.cpp: 43 (WebCore::ImageLayerChromium::paintContentsIfDirty): 44 (WebCore::ImageLayerChromium::updateCompositorResources): 45 (WebCore::ImageLayerChromium::layerBounds): 46 (WebCore::ImageLayerChromium::tilingTransform): 47 * platform/graphics/chromium/ImageLayerChromium.h: 48 * platform/graphics/chromium/LayerChromium.h: 49 (WebCore::LayerChromium::invalidateRect): 50 (WebCore::LayerChromium::paintContentsIfDirty): 51 (WebCore::LayerChromium::setIsMask): 52 (WebCore::LayerChromium::draw): 53 * platform/graphics/chromium/LayerRendererChromium.cpp: 54 (WebCore::LayerRendererChromium::drawRootLayer): 55 (WebCore::LayerRendererChromium::drawLayers): 56 (WebCore::LayerRendererChromium::paintContentsRecursive): 57 (WebCore::LayerRendererChromium::copyOffscreenTextureToDisplay): 58 (WebCore::LayerRendererChromium::drawLayer): 59 (WebCore::LayerRendererChromium::initializeSharedObjects): 60 (WebCore::LayerRendererChromium::cleanupSharedObjects): 61 * platform/graphics/chromium/LayerRendererChromium.h: 62 * platform/graphics/chromium/LayerTilerChromium.cpp: 63 (WebCore::LayerTilerChromium::setTileSize): 64 (WebCore::LayerTilerChromium::getSingleTexture): 65 (WebCore::LayerTilerChromium::invalidateRect): 66 (WebCore::LayerTilerChromium::update): 67 (WebCore::LayerTilerChromium::uploadCanvas): 68 (WebCore::LayerTilerChromium::updateFromPixels): 69 (WebCore::LayerTilerChromium::draw): 70 (WebCore::LayerTilerChromium::unreserveTextures): 71 * platform/graphics/chromium/LayerTilerChromium.h: 72 (WebCore::LayerTilerChromium::setLayerRenderer): 73 (WebCore::LayerTilerChromium::skipsDraw): 74 * platform/graphics/chromium/PlatformCanvas.cpp: 75 (WebCore::PlatformCanvas::AutoLocker::AutoLocker): 76 (WebCore::PlatformCanvas::Painter::Painter): 77 * platform/graphics/chromium/PlatformCanvas.h: 78 * platform/graphics/chromium/RenderSurfaceChromium.cpp: 79 (WebCore::RenderSurfaceChromium::draw): 80 * platform/graphics/chromium/RenderSurfaceChromium.h: 81 * platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp: 82 (WebCore::CCCanvasLayerImpl::draw): 83 * platform/graphics/chromium/cc/CCCanvasLayerImpl.h: 84 * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: 85 (WebCore::CCHeadsUpDisplay::draw): 86 * platform/graphics/chromium/cc/CCLayerImpl.cpp: 87 (WebCore::CCLayerImpl::draw): 88 * platform/graphics/chromium/cc/CCLayerImpl.h: 89 * platform/graphics/chromium/cc/CCPluginLayerImpl.cpp: 90 (WebCore::CCPluginLayerImpl::draw): 91 * platform/graphics/chromium/cc/CCPluginLayerImpl.h: 92 * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp: 93 (WebCore::CCVideoLayerImpl::draw): 94 * platform/graphics/chromium/cc/CCVideoLayerImpl.h: 95 1 96 2011-04-14 James Robinson <jamesr@chromium.org> 2 97 -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
r83820 r83915 42 42 #include "TextStream.h" 43 43 44 // Maximum size the width or height of this layer can be before enabling tiling 45 // when m_tilingOption == AutoTile. 46 static int maxUntiledSize = 512; 47 // When tiling is enabled, use tiles of this dimension squared. 48 static int defaultTileSize = 256; 49 50 using namespace std; 51 44 52 namespace WebCore { 45 53 … … 51 59 ContentLayerChromium::ContentLayerChromium(GraphicsLayerChromium* owner) 52 60 : LayerChromium(owner) 53 , m_contentsTexture(0) 54 , m_skipsDraw(false) 61 , m_tilingOption(ContentLayerChromium::AutoTile) 55 62 { 56 63 } … … 58 65 ContentLayerChromium::~ContentLayerChromium() 59 66 { 60 cleanupResources(); 61 } 62 63 void ContentLayerChromium::cleanupResources() 64 { 67 m_tiler.clear(); 65 68 LayerChromium::cleanupResources(); 66 m_contentsTexture.clear(); 67 } 68 69 bool ContentLayerChromium::requiresClippedUpdateRect() 70 { 71 // To avoid allocating excessively large textures, switch into "large layer mode" if 72 // one of the layer's dimensions is larger than 2000 pixels or the size of 73 // surface it's rendering into. This is a temporary measure until layer tiling is implemented. 74 static const int maxLayerSize = 2000; 75 return (bounds().width() > max(maxLayerSize, ccLayerImpl()->targetRenderSurface()->contentRect().width()) 76 || bounds().height() > max(maxLayerSize, ccLayerImpl()->targetRenderSurface()->contentRect().height()) 77 || !layerRenderer()->checkTextureSize(bounds())); 78 } 79 80 void ContentLayerChromium::paintContentsIfDirty() 69 } 70 71 class ContentLayerPainter : public TilePaintInterface { 72 public: 73 explicit ContentLayerPainter(GraphicsLayerChromium* owner) 74 : m_owner(owner) 75 { 76 } 77 78 virtual void paint(GraphicsContext& context, const IntRect& contentRect) 79 { 80 context.save(); 81 context.clearRect(contentRect); 82 context.clip(contentRect); 83 m_owner->paintGraphicsLayerContents(context, contentRect); 84 context.restore(); 85 } 86 private: 87 GraphicsLayerChromium* m_owner; 88 }; 89 90 void ContentLayerChromium::paintContentsIfDirty(const IntRect& targetSurfaceRect) 81 91 { 82 92 ASSERT(drawsContent()); 83 84 93 ASSERT(layerRenderer()); 85 94 86 IntRect dirtyRect; 87 IntRect boundsRect(IntPoint(0, 0), bounds()); 88 IntPoint paintingOffset; 89 90 // FIXME: Remove this test when tiled layers are implemented. 91 if (requiresClippedUpdateRect()) { 92 // Calculate the region of this layer that is currently visible. 93 const IntRect clipRect = ccLayerImpl()->targetRenderSurface()->contentRect(); 94 95 TransformationMatrix layerOriginTransform = ccLayerImpl()->drawTransform(); 96 layerOriginTransform.translate3d(-0.5 * bounds().width(), -0.5 * bounds().height(), 0); 97 98 // We compute the visible portion of the layer by back-mapping the current RenderSurface 99 // content area to the layer. To do that, we invert the drawing matrix of the layer 100 // and project the content area rectangle to it. If the layer transform is not invertible 101 // then we skip rendering the layer. 102 if (!layerOriginTransform.isInvertible()) { 103 m_skipsDraw = true; 104 return; 105 } 106 TransformationMatrix targetToLayerMatrix = layerOriginTransform.inverse(); 107 FloatQuad mappedClipToLayer = targetToLayerMatrix.projectQuad(FloatRect(clipRect)); 108 IntRect visibleRectInLayerCoords = mappedClipToLayer.enclosingBoundingBox(); 109 visibleRectInLayerCoords.intersect(IntRect(0, 0, bounds().width(), bounds().height())); 110 111 // If this is still too large to render, then skip the layer completely. 112 if (!layerRenderer()->checkTextureSize(visibleRectInLayerCoords.size())) { 113 m_skipsDraw = true; 114 return; 115 } 116 117 // If we need to resize the upload buffer we have to repaint everything. 118 if (m_canvas.size() != visibleRectInLayerCoords.size()) { 119 resizeUploadBuffer(visibleRectInLayerCoords.size()); 120 m_dirtyRect = boundsRect; 121 } 122 // If the visible portion of the layer is different from the last upload. 123 if (visibleRectInLayerCoords != m_visibleRectInLayerCoords) 124 m_dirtyRect = boundsRect; 125 m_visibleRectInLayerCoords = visibleRectInLayerCoords; 126 127 // Calculate the portion of the dirty rectangle that is visible. m_dirtyRect is in layer space. 128 IntRect visibleDirtyRectInLayerSpace = enclosingIntRect(m_dirtyRect); 129 visibleDirtyRectInLayerSpace.intersect(visibleRectInLayerCoords); 130 131 // What the rectangles mean: 132 // dirtyRect: The region of this layer that will be updated. 133 // m_uploadUpdateRect: The region of the layer's texture that will be uploaded into. 134 dirtyRect = visibleDirtyRectInLayerSpace; 135 m_uploadUpdateRect = dirtyRect; 136 IntSize visibleRectOffsetInLayerCoords(visibleRectInLayerCoords.x(), visibleRectInLayerCoords.y()); 137 paintingOffset = IntPoint(visibleRectOffsetInLayerCoords); 138 m_uploadUpdateRect.move(-visibleRectOffsetInLayerCoords); 139 } else { 140 dirtyRect = IntRect(m_dirtyRect); 141 // If the texture needs to be reallocated then we must redraw the entire 142 // contents of the layer. 143 if (m_canvas.size() != bounds()) { 144 resizeUploadBuffer(bounds()); 145 dirtyRect = boundsRect; 146 } else { 147 // Clip the dirtyRect to the size of the layer to avoid drawing 148 // outside the bounds of the backing texture. 149 dirtyRect.intersect(boundsRect); 150 } 151 m_uploadUpdateRect = dirtyRect; 152 } 153 154 if (dirtyRect.isEmpty()) 95 createTilerIfNeeded(); 96 97 ContentLayerPainter painter(m_owner); 98 updateLayerSize(layerBounds().size()); 99 100 IntRect layerRect = visibleLayerRect(targetSurfaceRect); 101 if (layerRect.isEmpty()) 155 102 return; 156 157 PlatformCanvas::Painter painter(&m_canvas); 158 painter.context()->save(); 159 painter.context()->translate(-paintingOffset.x(), -paintingOffset.y()); 160 painter.context()->clearRect(dirtyRect); 161 painter.context()->clip(dirtyRect); 162 163 m_owner->paintGraphicsLayerContents(*painter.context(), dirtyRect); 164 painter.context()->restore(); 165 } 166 167 void ContentLayerChromium::resizeUploadBuffer(const IntSize& size) 168 { 169 m_canvas.resize(size); 170 } 171 172 void ContentLayerChromium::updateTextureIfNeeded() 173 { 174 PlatformCanvas::AutoLocker locker(&m_canvas); 175 updateTexture(locker.pixels(), m_canvas.size()); 176 } 177 178 void ContentLayerChromium::updateTexture(const uint8_t* pixels, const IntSize& size) 179 { 180 if (!pixels) 103 m_tiler->invalidateRect(enclosingIntRect(m_dirtyRect)); 104 m_tiler->update(painter, layerRect); 105 m_dirtyRect = FloatRect(); 106 } 107 108 void ContentLayerChromium::setLayerRenderer(LayerRendererChromium* layerRenderer) 109 { 110 LayerChromium::setLayerRenderer(layerRenderer); 111 createTilerIfNeeded(); 112 m_tiler->setLayerRenderer(layerRenderer); 113 } 114 115 TransformationMatrix ContentLayerChromium::tilingTransform() 116 { 117 TransformationMatrix transform = ccLayerImpl()->drawTransform(); 118 // Tiler draws from the upper left corner. The draw transform 119 // specifies the middle of the layer. 120 IntSize size = bounds(); 121 transform.translate(-size.width() / 2.0, -size.height() / 2.0); 122 123 return transform; 124 } 125 126 IntRect ContentLayerChromium::visibleLayerRect(const IntRect& targetSurfaceRect) 127 { 128 if (targetSurfaceRect.isEmpty()) 129 return targetSurfaceRect; 130 131 const IntRect layerBoundRect = layerBounds(); 132 const TransformationMatrix transform = tilingTransform(); 133 134 // Is this layer fully contained within the target surface? 135 IntRect layerInSurfaceSpace = transform.mapRect(layerBoundRect); 136 if (targetSurfaceRect.contains(layerInSurfaceSpace)) 137 return layerBoundRect; 138 139 // If the layer doesn't fill up the entire surface, then find the part of 140 // the surface rect where the layer could be visible. This avoids trying to 141 // project surface rect points that are behind the projection point. 142 IntRect minimalSurfaceRect = targetSurfaceRect; 143 minimalSurfaceRect.intersect(layerInSurfaceSpace); 144 145 // Project the corners of the target surface rect into the layer space. 146 // This bounding rectangle may be larger than it needs to be (being 147 // axis-aligned), but is a reasonable filter on the space to consider. 148 // Non-invertible transforms will create an empty rect here. 149 const TransformationMatrix surfaceToLayer = transform.inverse(); 150 IntRect layerRect = surfaceToLayer.projectQuad(FloatQuad(FloatRect(minimalSurfaceRect))).enclosingBoundingBox(); 151 layerRect.intersect(layerBoundRect); 152 return layerRect; 153 } 154 155 IntRect ContentLayerChromium::layerBounds() const 156 { 157 return IntRect(IntPoint(0, 0), bounds()); 158 } 159 160 void ContentLayerChromium::updateLayerSize(const IntSize& layerSize) 161 { 162 if (!m_tiler) 181 163 return; 182 164 183 GraphicsContext3D* context = layerRendererContext(); 184 if (!m_contentsTexture) 185 m_contentsTexture = LayerTexture::create(context, layerRenderer()->textureManager()); 186 187 // If we have to allocate a new texture we have to upload the full contents. 188 if (!m_contentsTexture->isValid(size, GraphicsContext3D::RGBA)) 189 m_uploadUpdateRect = IntRect(IntPoint(0, 0), size); 190 191 if (m_uploadUpdateRect.isEmpty()) 165 const IntSize tileSize(min(defaultTileSize, layerSize.width()), min(defaultTileSize, layerSize.height())); 166 const bool autoTiled = layerSize.width() > maxUntiledSize || layerSize.height() > maxUntiledSize; 167 168 bool isTiled; 169 if (m_tilingOption == AlwaysTile) 170 isTiled = true; 171 else if (m_tilingOption == NeverTile) 172 isTiled = false; 173 else 174 isTiled = autoTiled; 175 176 m_tiler->setTileSize(isTiled ? tileSize : layerSize); 177 } 178 179 void ContentLayerChromium::draw(const IntRect& targetSurfaceRect) 180 { 181 const TransformationMatrix transform = tilingTransform(); 182 IntRect layerRect = visibleLayerRect(targetSurfaceRect); 183 if (!layerRect.isEmpty()) 184 m_tiler->draw(layerRect, transform, ccLayerImpl()->drawOpacity()); 185 m_tiler->unreserveTextures(); 186 } 187 188 void ContentLayerChromium::createTilerIfNeeded() 189 { 190 if (m_tiler) 192 191 return; 193 194 if (!m_contentsTexture->reserve(size, GraphicsContext3D::RGBA)) { 195 m_skipsDraw = true; 196 return; 197 } 198 199 IntRect srcRect = IntRect(IntPoint(0, 0), size); 200 if (requiresClippedUpdateRect()) 201 srcRect = m_visibleRectInLayerCoords; 202 203 const size_t destStride = m_uploadUpdateRect.width() * 4; 204 const size_t srcStride = srcRect.width() * 4; 205 206 const uint8_t* uploadPixels = pixels + srcStride * m_uploadUpdateRect.y(); 207 Vector<uint8_t> uploadBuffer; 208 if (srcStride != destStride || m_uploadUpdateRect.x()) { 209 uploadBuffer.resize(m_uploadUpdateRect.height() * destStride); 210 for (int row = 0; row < m_uploadUpdateRect.height(); ++row) { 211 size_t srcOffset = (m_uploadUpdateRect.y() + row) * srcStride + m_uploadUpdateRect.x() * 4; 212 ASSERT(srcOffset + destStride <= static_cast<size_t>(size.width() * size.height() * 4)); 213 size_t destOffset = row * destStride; 214 ASSERT(destOffset + destStride <= uploadBuffer.size()); 215 memcpy(uploadBuffer.data() + destOffset, pixels + srcOffset, destStride); 216 } 217 uploadPixels = uploadBuffer.data(); 218 } 219 220 m_contentsTexture->bindTexture(); 221 GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, 222 m_uploadUpdateRect.x(), m_uploadUpdateRect.y(), m_uploadUpdateRect.width(), m_uploadUpdateRect.height(), 223 GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, 224 uploadPixels)); 225 226 m_uploadUpdateRect = IntRect(); 227 m_dirtyRect.setSize(FloatSize()); 228 // Large layers always stay dirty, because they need to update when the content rect changes. 229 m_contentsDirty = requiresClippedUpdateRect(); 230 } 231 232 void ContentLayerChromium::draw() 233 { 234 if (m_skipsDraw) 235 return; 236 237 ASSERT(layerRenderer()); 238 239 const ContentLayerChromium::Program* program = layerRenderer()->contentLayerProgram(); 240 ASSERT(program && program->initialized()); 241 GraphicsContext3D* context = layerRendererContext(); 242 GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); 243 bindContentsTexture(); 244 layerRenderer()->useShader(program->program()); 245 GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0)); 246 GLC(context, context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA)); 247 248 if (requiresClippedUpdateRect()) { 249 // Compute the offset between the layer's center point and the center of the visible portion 250 // of the layer. 251 FloatPoint visibleRectCenterOffset = FloatRect(m_visibleRectInLayerCoords).center(); 252 visibleRectCenterOffset.move(-0.5 * bounds().width(), -0.5 * bounds().height()); 253 254 TransformationMatrix transform = ccLayerImpl()->drawTransform(); 255 transform.translate(visibleRectCenterOffset.x(), visibleRectCenterOffset.y()); 256 257 drawTexturedQuad(context, layerRenderer()->projectionMatrix(), 258 transform, m_visibleRectInLayerCoords.width(), 259 m_visibleRectInLayerCoords.height(), ccLayerImpl()->drawOpacity(), 260 program->vertexShader().matrixLocation(), 261 program->fragmentShader().alphaLocation()); 262 } else { 263 drawTexturedQuad(context, layerRenderer()->projectionMatrix(), 264 ccLayerImpl()->drawTransform(), bounds().width(), bounds().height(), 265 ccLayerImpl()->drawOpacity(), program->vertexShader().matrixLocation(), 266 program->fragmentShader().alphaLocation()); 267 } 268 unreserveContentsTexture(); 192 m_tiler = LayerTilerChromium::create(layerRenderer(), IntSize(defaultTileSize, defaultTileSize), LayerTilerChromium::HasBorderTexels); 269 193 } 270 194 271 195 void ContentLayerChromium::updateCompositorResources() 272 196 { 273 updateTextureIfNeeded(); 197 m_tiler->uploadCanvas(); 198 } 199 200 void ContentLayerChromium::setTilingOption(TilingOption option) 201 { 202 m_tilingOption = option; 203 updateLayerSize(bounds()); 204 } 205 206 void ContentLayerChromium::bindContentsTexture() 207 { 208 // This function is only valid for single texture layers, e.g. masks. 209 ASSERT(m_tilingOption == NeverTile); 210 ASSERT(m_tiler); 211 212 LayerTexture* texture = m_tiler->getSingleTexture(); 213 ASSERT(texture); 214 215 texture->bindTexture(); 274 216 } 275 217 276 218 void ContentLayerChromium::unreserveContentsTexture() 277 219 { 278 if (!m_skipsDraw && m_contentsTexture) 279 m_contentsTexture->unreserve(); 280 } 281 282 void ContentLayerChromium::bindContentsTexture() 283 { 284 if (!m_skipsDraw && m_contentsTexture) 285 m_contentsTexture->bindTexture(); 220 m_tiler->unreserveTextures(); 221 } 222 223 void ContentLayerChromium::setIsMask(bool isMask) 224 { 225 setTilingOption(isMask ? NeverTile : AutoTile); 286 226 } 287 227 … … 296 236 LayerChromium::dumpLayerProperties(ts, indent); 297 237 writeIndent(ts, indent); 298 ts << "skipsDraw: " << m_ skipsDraw<< "\n";238 ts << "skipsDraw: " << m_tiler->skipsDraw() << "\n"; 299 239 } 300 240 -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h
r83511 r83915 36 36 37 37 #include "LayerChromium.h" 38 #include " PlatformCanvas.h"38 #include "LayerTilerChromium.h" 39 39 #include "TextureManager.h" 40 40 … … 47 47 friend class LayerRendererChromium; 48 48 public: 49 enum TilingOption { AlwaysTile, NeverTile, AutoTile }; 50 49 51 static PassRefPtr<ContentLayerChromium> create(GraphicsLayerChromium* owner = 0); 50 52 51 53 virtual ~ContentLayerChromium(); 52 54 53 virtual void paintContentsIfDirty( );55 virtual void paintContentsIfDirty(const IntRect& targetSurfaceRect); 54 56 virtual void updateCompositorResources(); 57 virtual void setIsMask(bool); 55 58 virtual void unreserveContentsTexture(); 56 59 virtual void bindContentsTexture(); 57 60 58 virtual void draw(); 59 virtual bool drawsContent() const { return m_owner && m_owner->drawsContent(); } 60 61 typedef ProgramBinding<VertexShaderPosTex, FragmentShaderTexAlpha> Program; 61 virtual void draw(const IntRect& targetSurfaceRect); 62 virtual bool drawsContent() const { return m_owner && m_owner->drawsContent() && (!m_tiler || !m_tiler->skipsDraw()); } 62 63 63 64 protected: 64 65 explicit ContentLayerChromium(GraphicsLayerChromium* owner); 65 66 66 virtual void cleanupResources();67 bool requiresClippedUpdateRect();68 void resizeUploadBuffer(const IntSize&);69 70 67 virtual const char* layerTypeAsString() const { return "ContentLayer"; } 71 68 virtual void dumpLayerProperties(TextStream&, int indent) const; 72 69 73 OwnPtr<LayerTexture> m_contentsTexture; 74 bool m_skipsDraw; 70 virtual void setLayerRenderer(LayerRendererChromium*); 75 71 76 // The portion of the upload buffer that has a pending update, in the coordinates of the texture. 77 IntRect m_uploadUpdateRect; 72 virtual IntRect layerBounds() const; 78 73 79 virtual void updateTextureIfNeeded(); 80 void updateTexture(const uint8_t* pixels, const IntSize&); 74 virtual TransformationMatrix tilingTransform(); 81 75 82 private: 83 PlatformCanvas m_canvas; 76 // For a given render surface rect that this layer will be transformed and 77 // drawn into, return the layer space rect that is visible in that surface. 78 IntRect visibleLayerRect(const IntRect&); 84 79 85 IntRect m_visibleRectInLayerCoords; 80 void updateLayerSize(const IntSize&); 81 void createTilerIfNeeded(); 82 void setTilingOption(TilingOption); 83 84 OwnPtr<LayerTilerChromium> m_tiler; 85 TilingOption m_tilingOption; 86 86 }; 87 87 -
trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
r83511 r83915 284 284 285 285 LayerChromium* maskLayerChromium = m_maskLayer ? m_maskLayer->platformLayer() : 0; 286 if (maskLayerChromium) 287 maskLayerChromium->setIsMask(true); 286 288 m_layer->setMaskLayer(maskLayerChromium); 287 289 } -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
r83558 r83915 35 35 #include "ImageLayerChromium.h" 36 36 37 #include "cc/CCLayerImpl.h" 37 38 #include "Image.h" 38 39 #include "LayerRendererChromium.h" … … 68 69 } 69 70 70 void ImageLayerChromium::paintContentsIfDirty( )71 void ImageLayerChromium::paintContentsIfDirty(const IntRect&) 71 72 { 72 73 ASSERT(layerRenderer()); 73 74 74 // FIXME: Remove this test when tiled layers are implemented.75 if (requiresClippedUpdateRect()) {76 // Use the base version of updateContents which draws a subset of the77 // image to a bitmap, as the pixel contents can't be uploaded directly.78 ContentLayerChromium::paintContentsIfDirty();79 return;80 }81 82 75 if (!m_dirtyRect.isEmpty()) { 83 76 m_decodedImage.updateFromImage(m_contents->nativeImageForCurrentFrame()); 84 m_uploadUpdateRect = IntRect(IntPoint(0, 0), m_decodedImage.size());85 77 } 86 78 } 87 79 88 void ImageLayerChromium::update TextureIfNeeded()80 void ImageLayerChromium::updateCompositorResources() 89 81 { 90 // FIXME: Remove this test when tiled layers are implemented. 91 if (requiresClippedUpdateRect()) { 92 ContentLayerChromium::updateTextureIfNeeded(); 93 return; 82 updateLayerSize(m_decodedImage.size()); 83 84 IntRect paintRect(IntPoint(0, 0), m_decodedImage.size()); 85 if (!m_dirtyRect.isEmpty()) { 86 m_tiler->invalidateRect(paintRect); 87 m_dirtyRect = IntRect(); 94 88 } 95 updateTexture(m_decodedImage.pixels(), m_decodedImage.size()); 89 m_tiler->updateFromPixels(paintRect, m_decodedImage.pixels()); 90 } 91 92 IntRect ImageLayerChromium::layerBounds() const 93 { 94 return IntRect(IntPoint(0, 0), m_decodedImage.size()); 95 } 96 97 TransformationMatrix ImageLayerChromium::tilingTransform() 98 { 99 // Tiler draws from the upper left corner. The draw transform 100 // specifies the middle of the layer. 101 TransformationMatrix transform = ccLayerImpl()->drawTransform(); 102 const IntRect sourceRect = layerBounds(); 103 const IntSize destSize = bounds(); 104 105 transform.translate(-destSize.width() / 2.0, -destSize.height() / 2.0); 106 107 // Tiler also draws at the original content size, so rescale the original 108 // image dimensions to the bounds that it is meant to be drawn at. 109 float scaleX = destSize.width() / static_cast<float>(sourceRect.size().width()); 110 float scaleY = destSize.height() / static_cast<float>(sourceRect.size().height()); 111 transform.scale3d(scaleX, scaleY, 1.0f); 112 113 return transform; 96 114 } 97 115 -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h
r83558 r83915 51 51 static PassRefPtr<ImageLayerChromium> create(GraphicsLayerChromium* owner = 0); 52 52 53 virtual void paintContentsIfDirty(); 53 virtual void paintContentsIfDirty(const IntRect& targetSurfaceRect); 54 virtual void updateCompositorResources(); 54 55 virtual bool drawsContent() const { return m_contents; } 55 56 … … 59 60 virtual const char* layerTypeAsString() const { return "ImageLayer"; } 60 61 62 virtual TransformationMatrix tilingTransform(); 63 virtual IntRect layerBounds() const; 64 61 65 private: 62 virtual void updateTextureIfNeeded();63 64 66 ImageLayerChromium(GraphicsLayerChromium* owner); 65 67 -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h
r83666 r83915 114 114 void setNeedsDisplay(const FloatRect& dirtyRect); 115 115 void setNeedsDisplay(); 116 virtual void invalidateRect(const FloatRect& dirtyRect) {} 116 117 const FloatRect& dirtyRect() const { return m_dirtyRect; } 117 118 void resetNeedsDisplay(); … … 157 158 // These methods typically need to be overwritten by derived classes. 158 159 virtual bool drawsContent() const { return false; } 160 virtual void paintContentsIfDirty(const IntRect&) { } 159 161 virtual void paintContentsIfDirty() { } 160 162 virtual void updateCompositorResources() { } 163 virtual void setIsMask(bool) {} 161 164 virtual void unreserveContentsTexture() { } 162 165 virtual void bindContentsTexture() { } 163 virtual void draw( ) { }166 virtual void draw(const IntRect&) { } 164 167 165 168 // These exists just for debugging (via drawDebugBorder()). -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r83828 r83915 167 167 void LayerRendererChromium::drawRootLayer() 168 168 { 169 m_rootLayerContentTiler->draw(m_viewportVisibleRect); 169 TransformationMatrix scroll; 170 scroll.translate(-m_viewportVisibleRect.x(), -m_viewportVisibleRect.y()); 171 172 m_rootLayerContentTiler->uploadCanvas(); 173 m_rootLayerContentTiler->draw(m_viewportVisibleRect, scroll, 1.0f); 174 m_rootLayerContentTiler->unreserveTextures(); 170 175 } 171 176 … … 359 364 360 365 GLC(m_context.get(), m_context->enable(GraphicsContext3D::BLEND)); 366 GLC(m_context.get(), m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA)); 361 367 GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST)); 362 368 … … 765 771 return; 766 772 773 const IntRect targetSurfaceRect = layer->ccLayerImpl()->scissorRect(); 774 767 775 if (layer->drawsContent()) 768 layer->paintContentsIfDirty( );776 layer->paintContentsIfDirty(targetSurfaceRect); 769 777 if (layer->maskLayer() && layer->maskLayer()->drawsContent()) 770 layer->maskLayer()->paintContentsIfDirty( );778 layer->maskLayer()->paintContentsIfDirty(targetSurfaceRect); 771 779 if (layer->replicaLayer() && layer->replicaLayer()->drawsContent()) 772 layer->replicaLayer()->paintContentsIfDirty( );780 layer->replicaLayer()->paintContentsIfDirty(targetSurfaceRect); 773 781 if (layer->replicaLayer() && layer->replicaLayer()->maskLayer() && layer->replicaLayer()->maskLayer()->drawsContent()) 774 layer->replicaLayer()->maskLayer()->paintContentsIfDirty( );782 layer->replicaLayer()->maskLayer()->paintContentsIfDirty(targetSurfaceRect); 775 783 } 776 784 … … 824 832 0.5 * m_defaultRenderSurface->m_contentRect.height(), 0); 825 833 m_defaultRenderSurface->m_drawOpacity = 1; 826 m_defaultRenderSurface->draw( );834 m_defaultRenderSurface->draw(m_defaultRenderSurface->m_contentRect); 827 835 } 828 836 } … … 865 873 { 866 874 if (layer->renderSurface() && layer->renderSurface() != targetSurface) { 867 layer->renderSurface()->draw( );875 layer->renderSurface()->draw(layer->getDrawRect()); 868 876 return; 869 877 } … … 905 913 } 906 914 907 layer->draw( );915 layer->draw(layer->scissorRect()); 908 916 909 917 // Draw the debug border if there is one. … … 978 986 m_sharedGeometry = adoptPtr(new GeometryBinding(m_context.get())); 979 987 m_borderProgram = adoptPtr(new LayerChromium::BorderProgram(m_context.get())); 980 m_contentLayerProgram = adoptPtr(new ContentLayerChromium::Program(m_context.get()));981 988 m_canvasLayerProgram = adoptPtr(new CCCanvasLayerImpl::Program(m_context.get())); 982 989 m_videoLayerRGBAProgram = adoptPtr(new CCVideoLayerImpl::RGBAProgram(m_context.get())); … … 988 995 989 996 if (!m_sharedGeometry->initialized() || !m_borderProgram->initialized() 990 || !m_c ontentLayerProgram->initialized() || !m_canvasLayerProgram->initialized()997 || !m_canvasLayerProgram->initialized() 991 998 || !m_videoLayerRGBAProgram->initialized() || !m_videoLayerYUVProgram->initialized() 992 999 || !m_pluginLayerProgram->initialized() || !m_renderSurfaceProgram->initialized() … … 1007 1014 m_sharedGeometry.clear(); 1008 1015 m_borderProgram.clear(); 1009 m_contentLayerProgram.clear();1010 1016 m_canvasLayerProgram.clear(); 1011 1017 m_videoLayerRGBAProgram.clear(); -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r83828 r83915 111 111 const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(); } 112 112 const LayerChromium::BorderProgram* borderProgram() const { return m_borderProgram.get(); } 113 const ContentLayerChromium::Program* contentLayerProgram() const { return m_contentLayerProgram.get(); }114 113 const RenderSurfaceChromium::Program* renderSurfaceProgram() const { return m_renderSurfaceProgram.get(); } 115 114 const RenderSurfaceChromium::MaskProgram* renderSurfaceMaskProgram() const { return m_renderSurfaceMaskProgram.get(); } … … 207 206 OwnPtr<GeometryBinding> m_sharedGeometry; 208 207 OwnPtr<LayerChromium::BorderProgram> m_borderProgram; 209 OwnPtr<ContentLayerChromium::Program> m_contentLayerProgram;210 208 OwnPtr<RenderSurfaceChromium::Program> m_renderSurfaceProgram; 211 209 OwnPtr<RenderSurfaceChromium::MaskProgram> m_renderSurfaceMaskProgram; -
trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp
r83511 r83915 41 41 using namespace std; 42 42 43 static int minTextureSize = 16; 44 43 45 namespace WebCore { 44 46 … … 70 72 } 71 73 72 void LayerTilerChromium::setTileSize(const IntSize& size) 73 { 74 void LayerTilerChromium::setTileSize(const IntSize& requestedSize) 75 { 76 IntSize size(max(minTextureSize, requestedSize.width()), max(minTextureSize, requestedSize.height())); 77 74 78 if (m_tileSize == size) 75 79 return; … … 80 84 m_tilePixels = adoptArrayPtr(new uint8_t[m_tileSize.width() * m_tileSize.height() * 4]); 81 85 m_tilingData.setMaxTextureSize(max(size.width(), size.height())); 86 } 87 88 LayerTexture* LayerTilerChromium::getSingleTexture() 89 { 90 Tile* tile = tileAt(0, 0); 91 return tile ? tile->texture() : 0; 82 92 } 83 93 … … 181 191 void LayerTilerChromium::invalidateRect(const IntRect& contentRect) 182 192 { 183 if (contentRect.isEmpty() )193 if (contentRect.isEmpty() || m_skipsDraw) 184 194 return; 185 195 … … 237 247 if (!tile->texture()->isValid(m_tileSize, GraphicsContext3D::RGBA)) 238 248 tile->m_dirtyLayerRect = tileLayerRect(tile); 249 else 250 tile->texture()->reserve(m_tileSize, GraphicsContext3D::RGBA); 239 251 dirtyLayerRect.unite(tile->m_dirtyLayerRect); 240 252 } … … 244 256 return; 245 257 246 const IntRect paintRect = layerRectToContentRect(dirtyLayerRect); 247 248 m_canvas.resize(paintRect.size()); 249 PlatformCanvas::Painter canvasPainter(&m_canvas); 250 canvasPainter.context()->translate(-paintRect.x(), -paintRect.y()); 258 m_paintRect = layerRectToContentRect(dirtyLayerRect); 259 260 m_canvas.resize(m_paintRect.size()); 261 262 // Assumption: if a tiler is using border texels, then it is because the 263 // layer is likely to be filtered or transformed. Because of it might be 264 // transformed, draw the text in grayscale instead of subpixel antialiasing. 265 PlatformCanvas::Painter::TextOption textOption = m_tilingData.borderTexels() ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText; 266 PlatformCanvas::Painter canvasPainter(&m_canvas, textOption); 267 canvasPainter.context()->translate(-m_paintRect.x(), -m_paintRect.y()); 251 268 { 252 269 TRACE_EVENT("LayerTilerChromium::update::paint", this, 0); 253 painter.paint(*canvasPainter.context(), paintRect); 254 } 255 270 painter.paint(*canvasPainter.context(), m_paintRect); 271 } 272 } 273 274 void LayerTilerChromium::uploadCanvas() 275 { 256 276 PlatformCanvas::AutoLocker locker(&m_canvas); 257 277 { 258 278 TRACE_EVENT("LayerTilerChromium::updateFromPixels", this, 0); 259 updateFromPixels( paintRect, locker.pixels());279 updateFromPixels(m_paintRect, locker.pixels()); 260 280 } 261 281 } … … 264 284 { 265 285 // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update. 266 if (!m_til es.size())286 if (!m_tilingData.totalSizeX() || !m_tilingData.totalSizeY()) 267 287 return; 268 288 … … 275 295 Tile* tile = tileAt(i, j); 276 296 if (!tile) 277 CRASH();278 if (!tile->dirty())297 tile = createTile(i, j); 298 else if (!tile->dirty()) 279 299 continue; 280 300 … … 283 303 const IntPoint anchor = sourceRect.location(); 284 304 sourceRect.intersect(layerRectToContentRect(tile->m_dirtyLayerRect)); 305 // Paint rect not guaranteed to line up on tile boundaries, so 306 // make sure that sourceRect doesn't extend outside of it. 307 sourceRect.intersect(paintRect); 285 308 if (sourceRect.isEmpty()) 286 309 continue; 287 310 288 if (!tile->texture()->reserve(m_tileSize, GraphicsContext3D::RGBA)) { 289 m_skipsDraw = true; 290 reset(); 291 return; 311 if (!tile->texture()->isReserved()) { 312 if (!tile->texture()->reserve(m_tileSize, GraphicsContext3D::RGBA)) { 313 m_skipsDraw = true; 314 reset(); 315 return; 316 } 292 317 } 293 318 … … 325 350 326 351 tile->texture()->bindTexture(); 327 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST)); 328 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::NEAREST)); 352 353 const GC3Dint filter = m_tilingData.borderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST; 354 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter)); 355 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter)); 329 356 330 357 GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource)); … … 340 367 } 341 368 342 void LayerTilerChromium::draw(const IntRect& contentRect )369 void LayerTilerChromium::draw(const IntRect& contentRect, const TransformationMatrix& globalTransform, float opacity) 343 370 { 344 371 if (m_skipsDraw || !m_tiles.size()) … … 355 382 for (int i = left; i <= right; ++i) { 356 383 Tile* tile = tileAt(i, j); 357 ASSERT(tile); 384 if (!tile) 385 continue; 358 386 359 387 tile->texture()->bindTexture(); 360 388 361 TransformationMatrix tileMatrix ;389 TransformationMatrix tileMatrix(globalTransform); 362 390 363 391 // Don't use tileContentRect here, as that contains the full … … 365 393 IntRect tileRect = m_tilingData.tileBounds(m_tilingData.tileIndex(tile->i(), tile->j())); 366 394 tileRect.move(m_layerPosition.x(), m_layerPosition.y()); 367 tileMatrix.translate3d(tileRect.x() - contentRect.x() + tileRect.width() / 2.0, tileRect.y() - contentRect.y() + tileRect.height() / 2.0, 0);395 tileMatrix.translate3d(tileRect.x() + tileRect.width() / 2.0, tileRect.y() + tileRect.height() / 2.0, 0); 368 396 369 397 IntPoint texOffset = m_tilingData.textureOffset(tile->i(), tile->j()); … … 375 403 float texScaleY = tileRect.height() / tileHeight; 376 404 377 drawTexturedQuad(context, layerRenderer()->projectionMatrix(), tileMatrix, tileRect.width(), tileRect.height(), 1, texTranslateX, texTranslateY, texScaleX, texScaleY, program); 378 379 tile->texture()->unreserve(); 405 drawTexturedQuad(context, layerRenderer()->projectionMatrix(), tileMatrix, tileRect.width(), tileRect.height(), opacity, texTranslateX, texTranslateY, texScaleX, texScaleY, program); 380 406 } 407 } 408 } 409 410 void LayerTilerChromium::unreserveTextures() 411 { 412 for (TileMap::iterator iter = m_tiles.begin(); iter != m_tiles.end(); ++iter) { 413 Tile* tile = iter->second.get(); 414 if (!tile) 415 continue; 416 tile->texture()->unreserve(); 381 417 } 382 418 } -
trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h
r83511 r83915 57 57 ~LayerTilerChromium(); 58 58 59 // Set invalidations to be potentially repainted during update(). 59 60 void invalidateRect(const IntRect& contentRect); 60 61 void invalidateEntireLayer(); 62 63 // Paint all invalidations and missing tiles needed to draw the contentRect 64 // into the internal canvas. 61 65 void update(TilePaintInterface& painter, const IntRect& contentRect); 66 67 // Reserve and upload tile textures from the internal canvas. 68 void uploadCanvas(); 69 70 // Reserve and upload tile textures from an externally painted buffer. 62 71 void updateFromPixels(const IntRect& paintRect, const uint8_t* pixels); 63 void draw(const IntRect& contentRect); 72 73 // Draw all tiles that intersect with the content rect. 74 void draw(const IntRect& contentRect, const TransformationMatrix&, float opacity); 75 76 // If uploadCanvas/updateFromPixels is called, this must be called after 77 // draw() to unreserve any textures that were reserved prior to uploading. 78 void unreserveTextures(); 64 79 65 80 // Set position of this tiled layer in content space. … … 67 82 // Change the tile size. This may invalidate all the existing tiles. 68 83 void setTileSize(const IntSize& size); 84 void setLayerRenderer(LayerRendererChromium* layerRenderer) { m_layerRenderer = layerRenderer; } 85 86 bool skipsDraw() const { return m_skipsDraw; } 69 87 70 88 typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderTexAlpha> Program; 89 90 // If this tiler has exactly one tile, return its texture. Otherwise, null. 91 LayerTexture* getSingleTexture(); 71 92 72 93 private: … … 141 162 Vector<RefPtr<Tile> > m_unusedTiles; 142 163 164 IntRect m_paintRect; 143 165 PlatformCanvas m_canvas; 144 166 -
trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.cpp
r83666 r83915 75 75 m_bitmap = 0; 76 76 #elif PLATFORM(CG) 77 m_pixels = &canvas->m_pixelData[0]; 77 if (canvas->m_pixelData) 78 m_pixels = &canvas->m_pixelData[0]; 78 79 #endif 79 80 } … … 87 88 } 88 89 89 PlatformCanvas::Painter::Painter(PlatformCanvas* canvas )90 PlatformCanvas::Painter::Painter(PlatformCanvas* canvas, PlatformCanvas::Painter::TextOption option) 90 91 { 91 92 #if USE(SKIA) 92 93 m_skiaContext = adoptPtr(new PlatformContextSkia(canvas->m_skiaCanvas.get())); 93 94 94 // This is needed to get text to show up correctly. 95 m_skiaContext->setDrawingToImageBuffer(true); 95 m_skiaContext->setDrawingToImageBuffer(option == GrayscaleText); 96 96 97 97 m_context = adoptPtr(new GraphicsContext(reinterpret_cast<PlatformGraphicsContext*>(m_skiaContext.get()))); -
trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.h
r83666 r83915 79 79 WTF_MAKE_NONCOPYABLE(Painter); 80 80 public: 81 explicit Painter(PlatformCanvas*); 81 enum TextOption { GrayscaleText, SubpixelText }; 82 83 Painter(PlatformCanvas*, TextOption); 82 84 ~Painter(); 83 85 -
trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp
r83511 r83915 144 144 } 145 145 146 void RenderSurfaceChromium::draw( )146 void RenderSurfaceChromium::draw(const IntRect&) 147 147 { 148 148 if (m_skipsDraw || !m_contentsTexture) -
trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h
r83511 r83915 53 53 bool prepareContentsTexture(); 54 54 void cleanupResources(); 55 void draw( );55 void draw(const IntRect& targetSurfaceRect); 56 56 57 57 String name() const; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp
r83511 r83915 48 48 } 49 49 50 void CCCanvasLayerImpl::draw( )50 void CCCanvasLayerImpl::draw(const IntRect&) 51 51 { 52 52 ASSERT(layerRenderer()); … … 78 78 79 79 #endif // USE(ACCELERATED_COMPOSITING) 80 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.h
r83511 r83915 43 43 typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexFlipAlpha> Program; 44 44 45 virtual void draw( );45 virtual void draw(const IntRect&); 46 46 47 47 virtual void dumpLayerProperties(TextStream&, int indent) const; … … 59 59 60 60 #endif // CCCanvasLayerImpl_h 61 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp
r83511 r83915 80 80 canvas.resize(hudSize); 81 81 { 82 PlatformCanvas::Painter painter(&canvas );82 PlatformCanvas::Painter painter(&canvas, PlatformCanvas::Painter::GrayscaleText); 83 83 drawHudContents(painter.context(), hudSize); 84 84 } … … 93 93 94 94 // Draw the HUD onto the default render surface. 95 const ContentLayerChromium::Program* program = m_layerRenderer->contentLayerProgram();95 const LayerTilerChromium::Program* program = m_layerRenderer->tilerProgram(); 96 96 ASSERT(program && program->initialized()); 97 97 GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp
r83551 r83915 130 130 } 131 131 132 void CCLayerImpl::draw( )133 { 134 return m_owner->draw( );132 void CCLayerImpl::draw(const IntRect& targetSurfaceRect) 133 { 134 return m_owner->draw(targetSurfaceRect); 135 135 } 136 136 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h
r83551 r83915 61 61 CCLayerImpl* replicaLayer() const; 62 62 63 virtual void draw( );63 virtual void draw(const IntRect& contentRect); 64 64 virtual void updateCompositorResources(); 65 65 void unreserveContentsTexture(); … … 207 207 208 208 #endif // CCLayerImpl_h 209 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp
r83511 r83915 47 47 } 48 48 49 void CCPluginLayerImpl::draw( )49 void CCPluginLayerImpl::draw(const IntRect&) 50 50 { 51 51 ASSERT(layerRenderer()); … … 82 82 83 83 #endif // USE(ACCELERATED_COMPOSITING) 84 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h
r83511 r83915 43 43 typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexFlipAlpha> Program; 44 44 45 virtual void draw( );45 virtual void draw(const IntRect&); 46 46 47 47 virtual void dumpLayerProperties(TextStream&, int indent) const; … … 58 58 59 59 #endif // CCPluginLayerImpl_h 60 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp
r83511 r83915 76 76 } 77 77 78 void CCVideoLayerImpl::draw( )78 void CCVideoLayerImpl::draw(const IntRect&) 79 79 { 80 80 if (m_skipsDraw) … … 171 171 172 172 #endif // USE(ACCELERATED_COMPOSITING) 173 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h
r83511 r83915 48 48 typedef ProgramBinding<VertexShaderPosTexYUVStretch, FragmentShaderYUVVideo> YUVProgram; 49 49 50 virtual void draw( );50 virtual void draw(const IntRect&); 51 51 52 52 virtual void dumpLayerProperties(TextStream&, int indent) const; … … 73 73 74 74 #endif // CCVideoLayerImpl_h 75
Note: See TracChangeset
for help on using the changeset viewer.