Changeset 38685 in webkit


Ignore:
Timestamp:
Nov 21, 2008 7:08:15 PM (15 years ago)
Author:
kevino@webkit.org
Message:

Reviewed by Kevin Ollivier.

Improve wx image drawing performance considerably when using wxGraphicsContext
by avoiding unnecessary copies and drawing.

https://bugs.webkit.org/show_bug.cgi?id=22404

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r38684 r38685  
     12008-11-15  Kevin Watters  <kevinwatters@gmail.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Improve wx image drawing performance considerably when using wxGraphicsContext
     6        by avoiding unnecessary copies and drawing.
     7       
     8        https://bugs.webkit.org/show_bug.cgi?id=22404
     9
     10        * platform/graphics/wx/ImageWx.cpp:
     11        (WebCore::BitmapImage::draw):
     12        (WebCore::BitmapImage::drawPattern):
     13
     14
    1152008-11-21  Kevin Watters  <kevinwatters@gmail.com>
    216
  • trunk/WebCore/platform/graphics/wx/ImageWx.cpp

    r37612 r38685  
    9696#if USE(WXGC)
    9797    wxGCDC* context = (wxGCDC*)ctxt->platformContext();
     98    wxGraphicsContext* gc = context->GetGraphicsContext();
    9899#else
    99100    wxWindowDC* context = ctxt->platformContext();
     
    115116    // Set the compositing operation.
    116117    ctxt->setCompositeOperation(op);
    117 
     118   
     119#if USE(WXGC)
     120    float scaleX = src.width() / dst.width();
     121    float scaleY = src.height() / dst.height();
     122
     123    FloatRect adjustedDestRect = dst;
     124    FloatSize selfSize = currentFrameSize();
     125   
     126    if (src.size() != selfSize) {
     127        adjustedDestRect.setLocation(FloatPoint(dst.x() - src.x() / scaleX, dst.y() - src.y() / scaleY));
     128        adjustedDestRect.setSize(FloatSize(selfSize.width() / scaleX, selfSize.height() / scaleY));
     129    }
     130   
     131    // If the image is only partially loaded, then shrink the destination rect that we're drawing into accordingly.
     132    int currHeight = bitmap->GetHeight();
     133    if (currHeight < selfSize.height())
     134        adjustedDestRect.setHeight(adjustedDestRect.height() * currHeight / selfSize.height());
     135
     136    gc->DrawBitmap(*bitmap, adjustedDestRect.x(), adjustedDestRect.y(), adjustedDestRect.width(), adjustedDestRect.height());
     137#else
    118138    IntRect srcIntRect(src);
    119139    IntRect dstIntRect(dst);
     
    125145        img.Rescale(dstIntRect.width(), dstIntRect.height());
    126146        bitmap = new wxBitmap(img);
    127     }   
     147    }
     148   
    128149    wxMemoryDC mydc;
    129150    ASSERT(bitmap->GetRefData());
     
    144165        bitmap = NULL;
    145166    }
     167#endif
     168
    146169    ctxt->restore();
    147170}
     
    170193    wxGraphicsContext* gc = context->GetGraphicsContext();
    171194    gc->ConcatTransform(patternTransform);
    172 #endif
    173 
     195#else
    174196    wxMemoryDC mydc;
    175197    mydc.SelectObject(*bitmap);
    176 
    177     while ( currentW < dstRect.width() ) {
    178         while ( currentH < dstRect.height() ) {
     198#endif
     199
     200    wxPoint origin(context->GetDeviceOrigin());
     201    wxSize clientSize(context->GetSize());
     202
     203    while ( currentW < dstRect.width()  && currentW < clientSize.x - origin.x ) {
     204        while ( currentH < dstRect.height() && currentH < clientSize.y - origin.y) {
     205#if USE(WXGC)
     206            gc->DrawBitmap(*bitmap, (wxDouble)dstRect.x() + currentW, (wxDouble)dstRect.y() + currentH, (wxDouble)srcRect.width(), (wxDouble)srcRect.height());
     207#else
    179208            context->Blit((wxCoord)dstRect.x() + currentW, (wxCoord)dstRect.y() + currentH, 
    180209                            (wxCoord)srcRect.width(), (wxCoord)srcRect.height(), &mydc,
    181210                            (wxCoord)srcRect.x(), (wxCoord)srcRect.y(), wxCOPY, true);
     211#endif
    182212            currentH += srcRect.height();
    183213        }
     
    186216    }
    187217    ctxt->restore();
     218
     219#if !USE(WXGC)
    188220    mydc.SelectObject(wxNullBitmap);
     221#endif   
    189222   
    190223    // NB: delete is causing crashes during page load, but not during the deletion
Note: See TracChangeset for help on using the changeset viewer.