Changeset 150809 in webkit
- Timestamp:
- May 28, 2013 10:28:35 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150805 r150809 1 2013-05-28 Arvid Nilsson <anilsson@rim.com> 2 3 [BlackBerry] backface-visibility: hidden doesn't work properly with masks and filters 4 https://bugs.webkit.org/show_bug.cgi?id=116616 5 6 Reviewed by Carlos Garcia Campos. 7 8 The BlackBerry::Platform::Graphics::GraphicsContext generates geometry 9 with a different winding order than the accelerated compositing backend 10 of the BlackBerry port. So, when we switched from Skia to this new 11 rendering engine, we switched from glFrontFace(GL_CCW) to 12 glFrontFace(GL_CW), and all was well when drawing display lists. 13 However, we forgot to update the winding order of geometry generated 14 within the accelerated compositing backend, which is used for masks and 15 filters, so they were getting erroneously culled out when 16 backface-visibility: hidden was applied to them. Fixed by switching the 17 winding order of all geometry generated up here, which has the added 18 benefit of enabling us to use TransformationMatrix::mapQuad instead of 19 transforming point-by-point. 20 21 To further complicate matters, a right-side up transform is used when 22 drawing layers into surfaces, reversing the winding order and requiring 23 us to switch back to glFrontFace(GL_CCW) temporarily, when drawing 24 layers to surfaces, or the layers will get culled out inside the 25 surface. 26 27 Also fix spelling error, "drawed" should be "drawn". 28 29 No new tests, this is only detectable by pixel tests, which the 30 BlackBerry port currently doesn't support. 31 32 PR 341945. 33 34 * platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.cpp: 35 (WebCore::EGLImageLayerCompositingThreadClient::drawTextures): 36 * platform/graphics/blackberry/LayerCompositingThread.cpp: 37 (WebCore::LayerCompositingThread::setDrawTransform): 38 (WebCore::getTransformedRect): 39 (WebCore::LayerCompositingThread::drawTextures): 40 (WebCore::LayerCompositingThread::drawSurface): 41 * platform/graphics/blackberry/LayerCompositingThread.h: 42 (LayerCompositingThread): 43 (WebCore::LayerCompositingThread::origin): 44 * platform/graphics/blackberry/LayerFilterRenderer.cpp: 45 (WebCore): 46 * platform/graphics/blackberry/LayerRenderer.cpp: 47 (WebCore::LayerRenderer::compositeLayers): 48 (WebCore): 49 (WebCore::LayerRenderer::drawLayersOnSurfaces): 50 * platform/graphics/blackberry/LayerRendererSurface.cpp: 51 (WebCore::LayerRendererSurface::drawRect): 52 (WebCore::LayerRendererSurface::transformedBounds): 53 * platform/graphics/blackberry/LayerRendererSurface.h: 54 (WebCore::LayerRendererSurface::origin): 55 (LayerRendererSurface): 56 * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp: 57 (WebCore): 58 (WebCore::loadBufferingImageData): 59 (WebCore::MediaPlayerPrivate::drawBufferingAnimation): 60 1 61 2013-05-28 Andreas Kling <akling@apple.com> 2 62 -
trunk/Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.cpp
r144465 r150809 48 48 void EGLImageLayerCompositingThreadClient::drawTextures(LayerCompositingThread* layer, double /*scale*/, const GLES2Program& program) 49 49 { 50 static float upsideDown[4 * 2] = { 0, 1, 0, 0, 1, 0, 1, 1};50 static float upsideDown[4 * 2] = { 0, 1, 1, 1, 1, 0, 0, 0 }; 51 51 52 52 if (!m_textureAccessor || !m_textureAccessor->textureID()) -
trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp
r148192 r150809 134 134 m_drawTransform = matrix; 135 135 136 float bx = m_bounds.width() / 2.0; 137 float by = m_bounds.height() / 2.0; 138 139 if (sizeIsScaleInvariant()) { 140 bx /= scale; 141 by /= scale; 142 } 143 144 m_transformedBounds.setP1(matrix.mapPoint(FloatPoint(-bx, -by))); 145 m_transformedBounds.setP2(matrix.mapPoint(FloatPoint(-bx, by))); 146 m_transformedBounds.setP3(matrix.mapPoint(FloatPoint(bx, by))); 147 m_transformedBounds.setP4(matrix.mapPoint(FloatPoint(bx, -by))); 148 136 FloatRect boundsRect(-origin(), bounds()); 137 138 if (sizeIsScaleInvariant()) 139 boundsRect.scale(1 / scale); 140 141 m_transformedBounds = matrix.mapQuad(boundsRect); 149 142 m_drawRect = m_transformedBounds.boundingBox(); 150 143 } … … 152 145 static FloatQuad getTransformedRect(const IntSize& bounds, const IntRect& rect, const TransformationMatrix& drawTransform) 153 146 { 154 float x = -bounds.width() / 2.0 + rect.x(); 155 float y = -bounds.height() / 2.0 + rect.y(); 156 float w = rect.width(); 157 float h = rect.height(); 158 FloatQuad result; 159 result.setP1(drawTransform.mapPoint(FloatPoint(x, y))); 160 result.setP2(drawTransform.mapPoint(FloatPoint(x, y + h))); 161 result.setP3(drawTransform.mapPoint(FloatPoint(x + w, y + h))); 162 result.setP4(drawTransform.mapPoint(FloatPoint(x + w, y))); 163 164 return result; 147 FloatPoint origin(bounds.width() / 2.0f, bounds.height() / 2.0f); 148 FloatRect layerRect(rect); 149 layerRect.moveBy(-origin); 150 return drawTransform.mapQuad(layerRect); 165 151 } 166 152 … … 214 200 void LayerCompositingThread::drawTextures(double scale, const GLES2Program& program, const FloatRect& visibleRect) 215 201 { 216 static float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0};202 static float texcoords[4 * 2] = { 0, 0, 1, 0, 1, 1, 0, 1 }; 217 203 218 204 if (m_pluginView) { … … 304 290 glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, &surfaceQuad); 305 291 306 static float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0};292 static float texcoords[4 * 2] = { 0, 0, 1, 0, 1, 1, 0, 1 }; 307 293 glVertexAttribPointer(program.texCoordLocation(), 2, GL_FLOAT, GL_FALSE, 0, texcoords); 308 294 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); -
trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h
r149824 r150809 162 162 void setLayerRenderer(LayerRenderer*); 163 163 164 // The draw transform expects the origin to be located at the center of the layer. 165 FloatPoint origin() const { return FloatPoint(m_bounds.width() / 2.0f, m_bounds.height() / 2.0f); } 166 164 167 void setDrawTransform(double scale, const TransformationMatrix&); 165 168 const TransformationMatrix& drawTransform() const { return m_drawTransform; } -
trunk/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.cpp
r149824 r150809 683 683 } 684 684 685 static float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0};685 static float texcoords[4 * 2] = { 0, 0, 1, 0, 1, 1, 0, 1 }; 686 686 687 687 void LayerFilterRenderer::applyActions(unsigned& fbo, LayerCompositingThread* layer, Vector<RefPtr<LayerFilterRendererAction> > actions) -
trunk/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp
r149824 r150809 332 332 return; 333 333 334 // If some layers should be drawed on temporary surfaces, we should do it first. 335 drawLayersOnSurfaces(surfaceLayers); 334 // If some layers should be drawn on temporary surfaces, we should do it first. 335 if (!surfaceLayers.isEmpty()) 336 drawLayersOnSurfaces(surfaceLayers); 336 337 337 338 // Don't render the root layer, the BlackBerry port uses the BackingStore to draw the … … 373 374 } 374 375 375 static float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0};376 static float texcoords[4 * 2] = { 0, 0, 1, 0, 1, 1, 0, 1 }; 376 377 377 378 void LayerRenderer::compositeBuffer(const TransformationMatrix& transform, const FloatRect& contents, BlackBerry::Platform::Graphics::Buffer* buffer, bool contentsOpaque, float opacity) … … 466 467 void LayerRenderer::drawLayersOnSurfaces(const Vector<RefPtr<LayerCompositingThread> >& surfaceLayers) 467 468 { 469 // Normally, an upside-down transform is used, as is the GL custom. However, when drawing 470 // layers to surfaces, a right-side-up transform is used, so we need to switch the winding order 471 // for culling. 472 glFrontFace(GL_CCW); 473 468 474 for (int i = surfaceLayers.size() - 1; i >= 0; i--) { 469 475 LayerCompositingThread* layer = surfaceLayers[i].get(); … … 492 498 } 493 499 494 // If there are layers drawed on surfaces, we need to switch to default framebuffer. 500 glFrontFace(GL_CW); 501 502 // If there are layers drawn on surfaces, we need to switch to default framebuffer. 495 503 // Otherwise, we just need to set viewport. 496 if (surfaceLayers.size()) { 497 useSurface(0); 498 glEnable(GL_SCISSOR_TEST); 499 glScissor(m_scissorRect.x(), m_scissorRect.y(), m_scissorRect.width(), m_scissorRect.height()); 500 } 504 useSurface(0); 505 glEnable(GL_SCISSOR_TEST); 506 glScissor(m_scissorRect.x(), m_scissorRect.y(), m_scissorRect.width(), m_scissorRect.height()); 501 507 } 502 508 … … 935 941 drawDebugBorder(layer); 936 942 937 // The texture for the LayerRendererSurface can be released after the surface was draw edon another surface.943 // The texture for the LayerRendererSurface can be released after the surface was drawn on another surface. 938 944 if (layerAlreadyOnSurface(layer)) { 939 945 layer->layerRendererSurface()->releaseTexture(); -
trunk/Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.cpp
r148200 r150809 48 48 FloatRect LayerRendererSurface::drawRect() const 49 49 { 50 float bx = m_size.width() / 2.0;51 float by = m_size.height() / 2.0;52 53 50 FloatRect rect = transformedBounds().boundingBox(); 54 51 55 if (m_ownerLayer->replicaLayer()) { 56 FloatQuad bounds; 57 bounds.setP1(m_replicaDrawTransform.mapPoint(FloatPoint(-bx, -by))); 58 bounds.setP2(m_replicaDrawTransform.mapPoint(FloatPoint(-bx, by))); 59 bounds.setP3(m_replicaDrawTransform.mapPoint(FloatPoint(bx, by))); 60 bounds.setP4(m_replicaDrawTransform.mapPoint(FloatPoint(bx, -by))); 61 rect.unite(bounds.boundingBox()); 62 } 52 if (m_ownerLayer->replicaLayer()) 53 rect.unite(m_replicaDrawTransform.mapQuad(FloatRect(-origin(), size())).boundingBox()); 63 54 64 55 return rect; … … 67 58 FloatQuad LayerRendererSurface::transformedBounds() const 68 59 { 69 float bx = m_size.width() / 2.0; 70 float by = m_size.height() / 2.0; 71 72 FloatQuad bounds; 73 bounds.setP1(m_drawTransform.mapPoint(FloatPoint(-bx, -by))); 74 bounds.setP2(m_drawTransform.mapPoint(FloatPoint(-bx, by))); 75 bounds.setP3(m_drawTransform.mapPoint(FloatPoint(bx, by))); 76 bounds.setP4(m_drawTransform.mapPoint(FloatPoint(bx, -by))); 77 78 return bounds; 60 return m_drawTransform.mapQuad(FloatRect(-origin(), size())); 79 61 } 80 62 -
trunk/Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.h
r148200 r150809 46 46 void setClipRect(const FloatRect& rect) { m_clipRect = rect; } 47 47 48 FloatPoint origin() const { return FloatPoint(m_size.width() / 2.0f, m_size.height() / 2.0f); } 49 48 50 void setDrawTransform(const TransformationMatrix& matrix) { m_drawTransform = matrix; } 49 51 const TransformationMatrix& drawTransform() const { return m_drawTransform; } -
trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp
r149824 r150809 877 877 static const double BufferingAnimationDelay = 1.0 / 24; 878 878 static unsigned* s_bufferingImageData = 0; 879 static int s_bufferingImageWidth = 0; 880 static int s_bufferingImageHeight = 0; 879 static IntSize s_bufferingImageSize; 881 880 882 881 PlatformMedia MediaPlayerPrivate::platformMedia() const … … 906 905 907 906 loaded = true; 908 s_bufferingImageWidth = bufferingIcon->width(); 909 s_bufferingImageHeight = bufferingIcon->height(); 907 s_bufferingImageSize = bufferingIcon->size(); 910 908 int bufSize = bufferingIcon->decodedSize(); 911 909 s_bufferingImageData = static_cast<unsigned*>(malloc(bufSize)); 912 910 913 nativeImage->readPixels(s_bufferingImageData, s_bufferingImage Width * s_bufferingImageHeight);911 nativeImage->readPixels(s_bufferingImageData, s_bufferingImageSize.width() * s_bufferingImageSize.height()); 914 912 915 913 bufferingIcon->deref(); … … 973 971 if (!initialized) { 974 972 initialized = true; 975 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, s_bufferingImage Width, s_bufferingImageHeight,973 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, s_bufferingImageSize.width(), s_bufferingImageSize.height(), 976 974 0, GL_RGBA, GL_UNSIGNED_BYTE, s_bufferingImageData); 977 975 free(s_bufferingImageData); 978 976 } 979 977 980 float texcoords[] = { 0, 0, 0, 1, 1, 1, 1, 0 }; 981 FloatPoint vertices[4]; 982 float bx = s_bufferingImageWidth / 2.0; 983 float by = s_bufferingImageHeight / 2.0; 984 vertices[0] = renderMatrix.mapPoint(FloatPoint(-bx, -by)); 985 vertices[1] = renderMatrix.mapPoint(FloatPoint(-bx, by)); 986 vertices[2] = renderMatrix.mapPoint(FloatPoint(bx, by)); 987 vertices[3] = renderMatrix.mapPoint(FloatPoint(bx, -by)); 978 float texcoords[] = { 0, 0, 1, 0, 1, 1, 0, 1 }; 979 FloatRect bufferingImageRect(FloatPoint(-s_bufferingImageSize.width() / 2.0f, -s_bufferingImageSize.height() / 2.0f), s_bufferingImageSize); 980 FloatQuad transformedQuad = renderMatrix.mapQuad(bufferingImageRect); 988 981 989 982 glEnable(GL_BLEND); 990 983 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 991 984 glUniform1f(program.opacityLocation(), 1.0); 992 glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, vertices);985 glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, &transformedQuad); 993 986 glVertexAttribPointer(program.texCoordLocation(), 2, GL_FLOAT, GL_FALSE, 0, texcoords); 994 987 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
Note: See TracChangeset
for help on using the changeset viewer.