LayoutTests/ChangeLog

 12010-10-10 Adrienne Walker <enne@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Add a test for very large image layers. Skip this test for mac-wk2
 6 because of the use of layerTreeAsText().
 7 https://bugs.webkit.org/show_bug.cgi?id=47016
 8
 9 * compositing/tiling/huge-layer-img-expected.txt: Added.
 10 * compositing/tiling/huge-layer-img.html: Added.
 11 * platform/mac-wk2/Skipped:
 12
1132010-10-07 Albert J. Wong <ajwong@chromium.org>
214
315 Unreviewed. Chromium build fix.

LayoutTests/compositing/tiling/huge-layer-img-expected.txt

 1The yellow box should be large enough to scroll off the bottom. There should be a red box on the first page and a blue box near the bottom of the yellow box. This tests that we can support very large composited image layers.
 2
 3
 4(GraphicsLayer
 5 (bounds 785.00 20113.00)
 6 (children 1
 7 (GraphicsLayer
 8 (bounds 785.00 20113.00)
 9 (children 1
 10 (GraphicsLayer
 11 (position 8.00 68.00)
 12 (bounds 500.00 20000.00)
 13 (usingTiledLayer 1)
 14 (drawsContent 1)
 15 )
 16 )
 17 )
 18 )
 19)
 20

LayoutTests/compositing/tiling/huge-layer-img.html

 1<!DOCTYPE html>
 2<html>
 3 <head>
 4 <title>Test of very large image layer</title>
 5
 6 <style type="text/css" media="screen">
 7 #container {
 8 width: 500px;
 9 height: 20000px;
 10 -webkit-transform:translateZ(0);
 11 }
 12 </style>
 13 <script type="text/javascript" charset="utf-8">
 14 if (window.layoutTestController) {
 15 layoutTestController.dumpAsText();
 16 layoutTestController.waitUntilDone();
 17 }
 18
 19 function testOnLoad()
 20 {
 21 var canvas = document.createElement('canvas');
 22 var img = document.getElementById("container")
 23 canvas.width = img.width;
 24 canvas.height = img.height;
 25 var context = canvas.getContext('2d');
 26 context.fillStyle = "yellow";
 27 context.fillRect(0, 0, canvas.width, canvas.height);
 28 context.fillStyle = "red";
 29 context.fillRect(50, 50, 200, 200);
 30 context.fillStyle = "blue";
 31 context.fillRect(50, canvas.height - 250, 200, 200);
 32 img.src = canvas.toDataURL();
 33
 34 window.setTimeout(function() {
 35 if (window.layoutTestController) {
 36 document.getElementById('layers').innerHTML = layoutTestController.layerTreeAsText();
 37 layoutTestController.notifyDone();
 38 }
 39 }, 0);
 40 }
 41
 42 window.addEventListener('load', testOnLoad, false);
 43 </script>
 44 </head>
 45 <body>
 46 <p>
 47 The yellow box should be large enough to scroll off the bottom.
 48 There should be a red box on the first page and a blue box
 49 near the bottom of the yellow box. This tests that we can support
 50 very large composited image layers.
 51 </p>
 52 <img id="container">
 53 <pre id="layers">Layer tree appears here in DRT.</pre>
 54 </body>
 55</html>

LayoutTests/platform/mac-wk2/Skipped

@@compositing/tiling/huge-layer-resize.html
7878compositing/tiling/huge-layer-with-layer-children-resize.html
7979compositing/tiling/huge-layer-with-layer-children.html
8080compositing/tiling/huge-layer.html
 81compositing/tiling/huge-layer-img.html
8182compositing/video/video-poster.html
8283
8384# Uncategorized editing failures

WebCore/ChangeLog

 12010-10-10 Adrienne Walker <enne@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Add a short-term solution for large layers. Layers that are too
 6 large to be contained in a single texture just upload the portion of
 7 the layer that is within the content rect. A longer-term solution
 8 is still tiling with proper memory management. Layers that have full
 9 3D transforms (more than just translations) are still not drawn.
 10 https://bugs.webkit.org/show_bug.cgi?id=47016
 11
 12 Test: compositing/tiling
 13
 14 * platform/graphics/chromium/ContentLayerChromium.cpp:
 15 (WebCore::ContentLayerChromium::ContentLayerChromium):
 16 (WebCore::ContentLayerChromium::requiresClippedUpdateRect):
 17 (WebCore::ContentLayerChromium::calculateClippedUpdateRect):
 18 (WebCore::ContentLayerChromium::updateContents):
 19 (WebCore::ContentLayerChromium::updateTextureRect):
 20 (WebCore::ContentLayerChromium::draw):
 21 * platform/graphics/chromium/ContentLayerChromium.h:
 22 * platform/graphics/chromium/ImageLayerChromium.cpp:
 23 (WebCore::ImageLayerChromium::updateContents):
 24 * platform/graphics/chromium/LayerRendererChromium.cpp:
 25 (WebCore::LayerRendererChromium::drawLayers):
 26 * platform/graphics/chromium/LayerRendererChromium.h:
 27 (WebCore::LayerRendererChromium::rootLayerContentRect):
 28
1292010-10-05 Diego Gonzalez <diegohcg@webkit.org>
230
331 Reviewed by Andreas Kling.

WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

@@PassRefPtr<ContentLayerChromium> ContentLayerChromium::create(GraphicsLayerChrom
124124ContentLayerChromium::ContentLayerChromium(GraphicsLayerChromium* owner)
125125 : LayerChromium(owner)
126126 , m_contentsTexture(0)
 127 , m_skipsDraw(false)
127128{
128129}
129130

@@void ContentLayerChromium::cleanupResources()
142143 }
143144}
144145
 146bool ContentLayerChromium::requiresClippedUpdateRect() const
 147{
 148 return !layerRenderer()->checkTextureSize(m_bounds);
 149}
 150
 151void ContentLayerChromium::calculateClippedUpdateRect(IntRect& dirtyRect, IntRect& drawRect) const
 152{
 153 // For the given layer size and content rect, calculate:
 154 // 1) The minimal texture space rectangle to be uploaded, returned in dirtyRect.
 155 // 2) The content rect-relative rectangle to draw this texture in, returned in drawRect.
 156
 157 const IntRect contentRect = layerRenderer()->rootLayerContentRect();
 158 const TransformationMatrix& transform = drawTransform();
 159 // The layer's draw transform points to the center of the layer, relative to
 160 // the content rect. layerPos is the distance from the top left of the
 161 // layer to the top left of the content rect.
 162 const IntPoint layerPos(m_bounds.width() / 2 - transform.m41(),
 163 m_bounds.height() / 2 - transform.m42());
 164 // Transform the contentRect into the space of the layer.
 165 IntRect contentRectInLayerSpace(layerPos, contentRect.size());
 166
 167 // Clip the entire layer against the visible region in the content rect
 168 // and use that as the drawable texture, instead of the entire layer.
 169 dirtyRect = IntRect(IntPoint(0, 0), m_bounds);
 170 dirtyRect.intersect(contentRectInLayerSpace);
 171
 172 // The draw position is relative to the content rect.
 173 drawRect = IntRect(toPoint(dirtyRect.location() - layerPos), dirtyRect.size());
 174}
 175
145176void ContentLayerChromium::updateContents()
146177{
147178 RenderLayerBacking* backing = static_cast<RenderLayerBacking*>(m_owner->client());

@@void ContentLayerChromium::updateContents()
152183
153184 ASSERT(layerRenderer());
154185
155  // FIXME: Remove this test when tiled layers are implemented.
156  m_skipsDraw = false;
157  if (!layerRenderer()->checkTextureSize(m_bounds)) {
158  m_skipsDraw = true;
159  return;
160  }
161 
162186 void* pixels = 0;
163  IntRect dirtyRect(m_dirtyRect);
 187 IntRect dirtyRect;
 188 IntRect updateRect;
164189 IntSize requiredTextureSize;
165190 IntSize bitmapSize;
166191
167  requiredTextureSize = m_bounds;
168  IntRect boundsRect(IntPoint(0, 0), m_bounds);
169 
170  // If the texture needs to be reallocated then we must redraw the entire
171  // contents of the layer.
172  if (requiredTextureSize != m_allocatedTextureSize)
173  dirtyRect = boundsRect;
174  else {
175  // Clip the dirtyRect to the size of the layer to avoid drawing outside
176  // the bounds of the backing texture.
177  dirtyRect.intersect(boundsRect);
 192 // FIXME: Remove this test when tiled layers are implemented.
 193 if (requiresClippedUpdateRect()) {
 194 // A layer with 3D transforms could require an arbitrarily large number
 195 // of texels to be repainted, so ignore these layers until tiling is
 196 // implemented.
 197 if (!drawTransform().isIdentityOrTranslation()) {
 198 m_skipsDraw = true;
 199 return;
 200 }
 201
 202 calculateClippedUpdateRect(dirtyRect, m_largeLayerDrawRect);
 203 if (!layerRenderer()->checkTextureSize(m_largeLayerDrawRect.size())) {
 204 m_skipsDraw = true;
 205 return;
 206 }
 207 if (m_largeLayerDirtyRect == dirtyRect)
 208 return;
 209
 210 m_largeLayerDirtyRect = dirtyRect;
 211 requiredTextureSize = dirtyRect.size();
 212 updateRect = IntRect(IntPoint(0, 0), dirtyRect.size());
 213 } else {
 214 dirtyRect = IntRect(m_dirtyRect);
 215 IntRect boundsRect(IntPoint(0, 0), m_bounds);
 216 requiredTextureSize = m_bounds;
 217 // If the texture needs to be reallocated then we must redraw the entire
 218 // contents of the layer.
 219 if (requiredTextureSize != m_allocatedTextureSize)
 220 dirtyRect = boundsRect;
 221 else {
 222 // Clip the dirtyRect to the size of the layer to avoid drawing
 223 // outside the bounds of the backing texture.
 224 dirtyRect.intersect(boundsRect);
 225 }
 226 updateRect = dirtyRect;
178227 }
179228
180229#if PLATFORM(SKIA)

@@void ContentLayerChromium::updateContents()
239288 textureId = layerRenderer()->createLayerTexture();
240289
241290 if (pixels)
242  updateTextureRect(pixels, bitmapSize, requiredTextureSize, dirtyRect, textureId);
 291 updateTextureRect(pixels, bitmapSize, requiredTextureSize, updateRect, textureId);
243292}
244293
245294static inline bool isPowerOfTwo(int x)

@@void ContentLayerChromium::updateTextureRect(void* pixels, const IntSize& bitmap
290339 GLC(context, context->generateMipmap(GraphicsContext3D::TEXTURE_2D));
291340
292341 m_dirtyRect.setSize(FloatSize());
293  m_contentsDirty = false;
 342 // Large layers always stay dirty, because they need to update when the content rect changes.
 343 m_contentsDirty = requiresClippedUpdateRect();
294344}
295345
296346void ContentLayerChromium::draw()

@@void ContentLayerChromium::draw()
306356 GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_contentsTexture));
307357 layerRenderer()->useShader(sv->contentShaderProgram());
308358 GLC(context, context->uniform1i(sv->shaderSamplerLocation(), 0));
309  drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(),
310  bounds().width(), bounds().height(), drawOpacity(),
311  sv->shaderMatrixLocation(), sv->shaderAlphaLocation());
 359
 360 if (requiresClippedUpdateRect()) {
 361 float m43 = drawTransform().m43();
 362 TransformationMatrix transform;
 363 transform.translate3d(m_largeLayerDrawRect.center().x(), m_largeLayerDrawRect.center().y(), m43);
 364 drawTexturedQuad(context, layerRenderer()->projectionMatrix(),
 365 transform, m_largeLayerDrawRect.width(),
 366 m_largeLayerDrawRect.height(), drawOpacity(),
 367 sv->shaderMatrixLocation(), sv->shaderAlphaLocation());
 368 } else {
 369 drawTexturedQuad(context, layerRenderer()->projectionMatrix(),
 370 drawTransform(), m_bounds.width(), m_bounds.height(),
 371 drawOpacity(), sv->shaderMatrixLocation(),
 372 sv->shaderAlphaLocation());
 373 }
312374}
313375
314376}

WebCore/platform/graphics/chromium/ContentLayerChromium.h

@@protected:
8484 const IntRect& updateRect, unsigned textureId, MipmapUse generateMipmap = noMipmap);
8585
8686 virtual void cleanupResources();
 87 bool requiresClippedUpdateRect() const;
8788
8889 unsigned m_contentsTexture;
8990 IntSize m_allocatedTextureSize;
9091 bool m_skipsDraw;
9192
 93private:
 94 void calculateClippedUpdateRect(IntRect& dirtyRect, IntRect& drawRect) const;
 95 IntRect m_largeLayerDrawRect;
 96 IntRect m_largeLayerDirtyRect;
9297};
9398
9499}

WebCore/platform/graphics/chromium/ImageLayerChromium.cpp

@@void ImageLayerChromium::updateContents()
7575{
7676 ASSERT(layerRenderer());
7777
 78 // FIXME: Remove this test when tiled layers are implemented.
 79 if (requiresClippedUpdateRect()) {
 80 // Use the base version of updateContents which draws a subset of the
 81 // image to a bitmap, as the pixel contents can't be uploaded directly.
 82 ContentLayerChromium::updateContents();
 83 return;
 84 }
 85
7886 void* pixels = 0;
7987 IntSize requiredTextureSize;
8088 IntSize bitmapSize;

@@void ImageLayerChromium::updateContents()
136144#else
137145#error "Need to implement for your platform."
138146#endif
139  // FIXME: Remove this test when tiled layers are implemented.
140  m_skipsDraw = false;
141  if (!layerRenderer()->checkTextureSize(requiredTextureSize)) {
142  m_skipsDraw = true;
143  return;
144  }
145147
146148 unsigned textureId = m_contentsTexture;
147149 if (!textureId)

WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

@@void LayerRendererChromium::drawLayers(const IntRect& visibleRect, const IntRect
307307 GLC(m_context, m_context->enable(GraphicsContext3D::BLEND));
308308 GLC(m_context, m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
309309
310  // Set the rootVisibleRect --- used by subsequent drawLayers calls
 310 // Set the root visible/content rects --- used by subsequent drawLayers calls.
311311 m_rootVisibleRect = visibleRect;
 312 m_rootContentRect = contentRect;
312313
313314 // Traverse the layer tree and update the layer transforms.
314315 float opacity = 1;

WebCore/platform/graphics/chromium/LayerRendererChromium.h

@@public:
109109 void resizeOnscreenContent(const IntSize&);
110110
111111 IntSize rootLayerTextureSize() const { return IntSize(m_rootLayerTextureWidth, m_rootLayerTextureHeight); }
 112 IntRect rootLayerContentRect() const { return m_rootContentRect; }
112113 void getFramebufferPixels(void *pixels, const IntRect& rect);
113114
114115private:

@@private:
160161 IntSize m_rootLayerCanvasSize;
161162
162163 IntRect m_rootVisibleRect;
 164 IntRect m_rootContentRect;
163165
164166 int m_maxTextureSize;
165167