Skip to content

Commit

Permalink
fixing some texture update issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Hanel committed Jul 19, 2012
1 parent 5bb2694 commit f55f813
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ static bool driverSupportsBGRASwizzling()
{
#if defined(TEXMAP_OPENGL_ES_2)
// FIXME: Implement reliable detection. See also https://bugs.webkit.org/show_bug.cgi?id=81103.
if(strstr((char*)glGetString(GL_EXTENSIONS), " GL_EXT_texture_format_BGRA8888 ")) {
return true;
}
return false;
#else
return true;
Expand Down Expand Up @@ -473,9 +476,12 @@ void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect
else
swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(const_cast<void*>(data)), IntRect(sourceOffset, targetRect.size()), bytesPerLine / 4);

if (bytesPerLine == targetRect.width() / 4 && sourceOffset == IntPoint::zero()) {
if (bytesPerLine == targetRect.width() * 4 && sourceOffset == IntPoint::zero()) {
GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data));
return;
} else if (bytesPerLine == targetRect.width() * 3 && sourceOffset == IntPoint::zero()) {
GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), GL_RGB, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data));
return;
}

// For ES drivers that don't support sub-images, transfer the pixels row-by-row.
Expand Down Expand Up @@ -520,6 +526,15 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co
// This might be a deep copy, depending on other references to the pixmap.
qtImage = frameImage->toImage();
#endif

if(qtImage.hasAlphaChannel() && isOpaque()) {
// upgrade the texture to RGBA
reset(size(), BitmapTexture::SupportsAlpha);
} else if (!qtImage.hasAlphaChannel() && !isOpaque()) {
//downgrade to RGB
reset(size()); //defaults to no alpha!
}

imageData = reinterpret_cast<const char*>(qtImage.constBits());
bytesPerLine = qtImage.bytesPerLine();
#elif USE(CAIRO)
Expand Down

0 comments on commit f55f813

Please sign in to comment.