⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 136147 in webkit


Ignore:
Timestamp:
Nov 29, 2012, 12:12:54 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

Be consistent in handling of frameAtIndex (and related) returns.
​https://bugs.webkit.org/show_bug.cgi?id=103207

Patch by Brent Fulgham <​bfulgham@gmail.com> on 2012-11-29
Reviewed by David Hyatt.

Under various conditions, frameAtIndex (and therefore,
nativeImageForCurrentFrame) returns null. A series of bugs over
the years has ensured null returns are handled in some cases,
but there are a handful of remaining cases where this is still a
problem.

No new tests, as these low-level functions are covered by
numerous existing test cases.

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r136146 r136147  
     12012-11-29  Brent Fulgham  <bfulgham@gmail.com>
     2
     3        Be consistent in handling of frameAtIndex (and related) returns.
     4        https://bugs.webkit.org/show_bug.cgi?id=103207
     5
     6        Reviewed by David Hyatt.
     7
     8        Under various conditions, frameAtIndex (and therefore,
     9        nativeImageForCurrentFrame) returns null. A series of bugs over
     10        the years has ensured null returns are handled in some cases,
     11        but there are a handful of remaining cases where this is still a
     12        problem.
     13
     14        No new tests, as these low-level functions are covered by
     15        numerous existing test cases.
     16
    1172012-11-29  David Hyatt  <hyatt@apple.com>
    218
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp

    r130525 r136147  
    180180        imageSurface = nativeImage->surface();
    181181    } else {
    182         imageSurface = image->nativeImageForCurrentFrame()->surface();
     182        NativeImageCairo* nativeImage = image->nativeImageForCurrentFrame();
     183        imageSurface = (nativeImage) ? nativeImage->surface() : 0;
    183184        if (!premultiplyAlpha)
    184185            alphaOp = AlphaDoUnmultiply;
  • trunk/Source/WebCore/platform/graphics/filters/skia/FEBlendSkia.cpp

    r135390 r136147  
    7373    RefPtr<Image> background = in2->asImageBuffer()->copyImage(DontCopyBackingStore);
    7474
    75     SkBitmap foregroundBitmap = foreground->nativeImageForCurrentFrame()->bitmap();
    76     SkBitmap backgroundBitmap = background->nativeImageForCurrentFrame()->bitmap();
     75    NativeImageSkia* foregroundNativeImage = foreground->nativeImageForCurrentFrame();
     76    NativeImageSkia* backgroundNativeImage = background->nativeImageForCurrentFrame();
     77
     78    if (!foregroundNativeImage || !backgroundNativeImage)
     79        return false;
     80
     81    SkBitmap foregroundBitmap = foregroundNativeImage->bitmap();
     82    SkBitmap backgroundBitmap = backgroundNativeImage->bitmap();
    7783
    7884    SkAutoTUnref<SkImageFilter> backgroundSource(new SkBitmapSource(backgroundBitmap));
  • trunk/Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp

    r135390 r136147  
    4444
    4545    RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
    46     SkBitmap bitmap = image->nativeImageForCurrentFrame()->bitmap();
     46    NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
     47    if (!nativeImage)
     48        return false;
    4749
    4850    unsigned char rValues[256], gValues[256], bValues[256], aValues[256];
    … …  
    5254    paint.setColorFilter(SkTableColorFilter::CreateARGB(aValues, rValues, gValues, bValues))->unref();
    5355    paint.setXfermodeMode(SkXfermode::kSrc_Mode);
    54     resultImage->context()->platformContext()->drawBitmap(bitmap, 0, 0, &paint);
     56    resultImage->context()->platformContext()->drawBitmap(nativeImage->bitmap(), 0, 0, &paint);
    5557
    5658    return true;
  • trunk/Source/WebCore/platform/graphics/filters/skia/FELightingSkia.cpp

    r135390 r136147  
    9999    RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
    100100    NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
     101    if (!nativeImage)
     102        return false;
    101103
    102104    GraphicsContext* dstContext = resultImage->context();
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp

    r135998 r136147  
    504504    else {
    505505        QPixmap* nativePixmap = image->nativeImageForCurrentFrame();
     506        if (!nativePixmap)
     507            return false;
     508
    506509        // With QPA, we can avoid a deep copy.
    507510        qtImage = *nativePixmap->handle()->buffer();
  • trunk/Source/WebCore/platform/graphics/win/ImageCGWin.cpp

    r127757 r136147  
    9292    for (size_t i = 0; i < frames; ++i) {
    9393        CGImageRef image = frameAtIndex(i);
    94         if (CGImageGetHeight(image) == static_cast<size_t>(srcSize.height()) && CGImageGetWidth(image) == static_cast<size_t>(srcSize.width())) {
     94        if (image && CGImageGetHeight(image) == static_cast<size_t>(srcSize.height()) && CGImageGetWidth(image) == static_cast<size_t>(srcSize.width())) {
    9595            size_t currentFrame = m_currentFrame;
    9696            m_currentFrame = i;
  • trunk/Source/WebCore/platform/graphics/wince/ImageWinCE.cpp

    r127757 r136147  
    119119        IntRect intSrcRect(srcRectIn);
    120120        RefPtr<SharedBitmap> bmp = frameAtIndex(m_currentFrame);
     121        if (bmp) {
     122            if (bmp->width() != m_source.size().width()) {
     123                double scaleFactor = static_cast<double>(bmp->width()) / m_source.size().width();
    121124
    122         if (bmp->width() != m_source.size().width()) {
    123             double scaleFactor = static_cast<double>(bmp->width()) / m_source.size().width();
    124 
    125             intSrcRect.setX(stableRound(srcRectIn.x() * scaleFactor));
    126             intSrcRect.setWidth(stableRound(srcRectIn.width() * scaleFactor));
    127             intSrcRect.setY(stableRound(srcRectIn.y() * scaleFactor));
    128             intSrcRect.setHeight(stableRound(srcRectIn.height() * scaleFactor));
     125                intSrcRect.setX(stableRound(srcRectIn.x() * scaleFactor));
     126                intSrcRect.setWidth(stableRound(srcRectIn.width() * scaleFactor));
     127                intSrcRect.setY(stableRound(srcRectIn.y() * scaleFactor));
     128                intSrcRect.setHeight(stableRound(srcRectIn.height() * scaleFactor));
     129            }
     130            bmp->draw(ctxt, enclosingIntRect(dstRect), intSrcRect, styleColorSpace, compositeOp);
    129131        }
    130         bmp->draw(ctxt, enclosingIntRect(dstRect), intSrcRect, styleColorSpace, compositeOp);
    131132    }
    132133
  • trunk/Source/WebCore/platform/win/DragImageCGWin.cpp

    r113486 r136147  
    149149    CGContextSetFillColor(drawContext, white);
    150150    CGContextFillRect(drawContext, rect);
    151     CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
    152     CGContextDrawImage(drawContext, rect, srcImage);
     151    if (srcImage) {
     152        CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
     153        CGContextDrawImage(drawContext, rect, srcImage);
     154    }
    153155    CGContextRelease(drawContext);
    154156
  • trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp

    r117322 r136147  
    174174    cairo_fill_preserve(cr);
    175175
    176     cairo_surface_t* srcImage = img->nativeImageForCurrentFrame()->surface();
     176    NativeImageCairo* srcNativeImage = img->nativeImageForCurrentFrame();
     177    cairo_surface_t* srcImage = (srcNativeImage) ? srcNativeImage->surface() : 0;
    177178
    178     // Draw the image.
    179     cairo_set_source_surface(cr, srcImage, 0.0, 0.0);
    180     cairo_paint(cr);
     179    if (srcImage) {
     180        // Draw the image.
     181        cairo_set_source_surface(cr, srcImage, 0.0, 0.0);
     182        cairo_paint(cr);
     183    }
    181184
    182185    deallocContext(drawContext);
Note: See TracChangeset for help on using the changeset viewer.