From fb54d2133b0d785a56fe0964114bc587b2c43d2b Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Tue, 26 Jun 2012 13:09:25 +0000 Subject: [PATCH] [Texmap] Bug fix typo about computing bytesPerLine in BitmapTextureGL. https://bugs.webkit.org/show_bug.cgi?id=89924 "bytesPerLine == targetRect.width() / 4" is invalid. This patch amended it into "bytesPerLine == targetRect.width() * 4". Moreover, changed magic number 4 to bytesPerPixel. Patch by Huang Dongsung on 2012-06-26 Reviewed by Noam Rosenthal. No new tests. Covered by existing tests. * platform/graphics/texmap/TextureMapperGL.cpp: (WebCore::BitmapTextureGL::updateContents): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121260 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 16 ++++++++++++++++ .../WebCore/platform/graphics/texmap/TextureMapperGL.cpp | 11 ++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index f882df6..d0b50af 100755 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,19 @@ +2012-06-26 Huang Dongsung + + [Texmap] Bug fix typo about computing bytesPerLine in BitmapTextureGL. + https://bugs.webkit.org/show_bug.cgi?id=89924 + + "bytesPerLine == targetRect.width() / 4" is invalid. + This patch amended it into "bytesPerLine == targetRect.width() * 4". + Moreover, changed magic number 4 to bytesPerPixel. + + Reviewed by Noam Rosenthal. + + No new tests. Covered by existing tests. + + * platform/graphics/texmap/TextureMapperGL.cpp: + (WebCore::BitmapTextureGL::updateContents): + 2012-06-26 Roland Takacs Shader compiler unprepared to make ESSL output when GLES is used diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp index 8df272c..6db7d6f 100644 --- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp +++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp @@ -474,7 +474,8 @@ void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect { GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id)); - if (bytesPerLine == targetRect.width() / 4 && sourceOffset == IntPoint::zero()) { + const unsigned bytesPerPixel = 4; + if (bytesPerLine == targetRect.width() * bytesPerPixel && sourceOffset == IntPoint::zero()) { GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), GL_RGBA, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data)); return; } @@ -482,11 +483,11 @@ void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect // For ES drivers that don't support sub-images. if (!driverSupportsSubImage()) { const char* bits = static_cast(data); - const char* src = bits + sourceOffset.y() * bytesPerLine + sourceOffset.x() * 4; - Vector temporaryData(targetRect.width() * targetRect.height() * 4); + const char* src = bits + sourceOffset.y() * bytesPerLine + sourceOffset.x() * bytesPerPixel; + Vector temporaryData(targetRect.width() * targetRect.height() * bytesPerPixel); char* dst = temporaryData.data(); - const int targetBytesPerLine = targetRect.width() * 4; + const int targetBytesPerLine = targetRect.width() * bytesPerPixel; for (int y = 0; y < targetRect.height(); ++y) { memcpy(dst, src, targetBytesPerLine); src += bytesPerLine; @@ -499,7 +500,7 @@ void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect #if !defined(TEXMAP_OPENGL_ES_2) // Use the OpenGL sub-image extension, now that we know it's available. - GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / 4)); + GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel)); GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y())); GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x())); GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), GL_RGBA, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data)); -- 2.7.4