Bug 118249

Summary: Fix cast-align warnings in WebCore/platform/graphics/texmap/TextureMapperGL.cpp
Product: WebKit Reporter: Csaba Osztrogonác <ossy>
Component: New BugsAssignee: Csaba Osztrogonác <ossy>
Status: RESOLVED FIXED    
Severity: Normal CC: allan.jensen, cmarcelo, commit-queue, luiz, noam, ossy
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Csaba Osztrogonác 2013-07-01 08:35:28 PDT
/home/oszi/WebKit/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:894:59: warning: cast from 'char*' to 'uint32_t* {aka unsigned int*}' increases required alignment of target type [-Wcast-align]

void BitmapTextureGL::updateContents(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag updateContentsFlag)
{
....
    char* data = reinterpret_cast<char*>(const_cast<void*>(srcData));
...
  swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(data), IntRect(adjustedSourceOffset, targetRect.size()), bytesPerLine / bytesPerPixel);   < ---- line 894
...
}

...
void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag)
{
    if (!image)
        return;
    NativeImagePtr frameImage = image->nativeImageForCurrentFrame();
    if (!frameImage)
        return;

    int bytesPerLine;
    const char* imageData;

#if PLATFORM(QT)
    QImage qImage = frameImage->toImage();
    imageData = reinterpret_cast<const char*>(qImage.constBits());
    bytesPerLine = qImage.bytesPerLine();
#elif USE(CAIRO)
    cairo_surface_t* surface = frameImage.get();
    imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface));
    bytesPerLine = cairo_image_surface_get_stride(surface);
#endif

    updateContents(imageData, targetRect, offset, bytesPerLine, updateContentsFlag);   < ------ call!
}
...

The problematic data is come from cairo_image_surface_get_data(surface) or qImage.constBits().
Both of them contains BGRA data, so I think we can assume that they are 32 bit aligned.
Comment 1 Csaba Osztrogonác 2013-07-01 08:38:30 PDT
Created attachment 205813 [details]
Patch
Comment 2 Csaba Osztrogonác 2013-07-02 02:13:29 PDT
ping for Qt and Cairo review.
Comment 3 Csaba Osztrogonác 2013-07-02 04:19:48 PDT
Comment on attachment 205813 [details]
Patch

Clearing flags on attachment: 205813

Committed r152283: <http://trac.webkit.org/changeset/152283>
Comment 4 Csaba Osztrogonác 2013-07-02 04:19:54 PDT
All reviewed patches have been landed.  Closing bug.