From eb2b1cb78cf15cf3e33bc5752ab080ecfd2ec6b9 Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Thu, 6 Jan 2011 11:56:00 -0800 Subject: Redo the clippingRect calculation Although the intersetcion is done correctly, but the clippingRect should take the parents' matrix into account. To make the code cleaner, we convert all the rects into screen coordinate for intersection. bug:3304761 Change-Id: Ia3dc3e7b72f2e72eaab66ba8e017d89ab71dc468 --- .../platform/graphics/android/ShaderProgram.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'WebCore/platform/graphics/android/ShaderProgram.cpp') diff --git a/WebCore/platform/graphics/android/ShaderProgram.cpp b/WebCore/platform/graphics/android/ShaderProgram.cpp index 15f120d..6c18a61 100644 --- a/WebCore/platform/graphics/android/ShaderProgram.cpp +++ b/WebCore/platform/graphics/android/ShaderProgram.cpp @@ -206,23 +206,29 @@ void ShaderProgram::setViewRect(const IntRect& viewRect) m_clippingMatrix.multiply(scale); } -void ShaderProgram::clip(const TransformationMatrix& drawMatrix, - const FloatRect& rect) +// This function transform a clip rect extracted from the current layer +// into a clip rect in screen coordinates +FloatRect ShaderProgram::clipRectInScreenCoord(const TransformationMatrix& drawMatrix, + const IntSize& size) { - if (rect == m_clipRect) - return; - - FloatRect srect(0, 0, rect.width(), rect.height()); + FloatRect srect(0, 0, size.width(), size.height()); TransformationMatrix renderMatrix = drawMatrix; renderMatrix.multiply(m_clippingMatrix); - FloatRect clip = renderMatrix.mapRect(srect); + return renderMatrix.mapRect(srect); +} + +// clip is in screen coordinates +void ShaderProgram::clip(const FloatRect& clip) +{ + if (clip == m_clipRect) + return; // we should only call glScissor in this function, so that we can easily // track the current clipping rect. glScissor(m_viewRect.x() + clip.x(), m_viewRect.y() + clip.y(), clip.width(), clip.height()); - m_clipRect = rect; + m_clipRect = clip; } void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix, -- cgit v1.1