summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/wx/ImageWx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/wx/ImageWx.cpp')
-rw-r--r--WebCore/platform/graphics/wx/ImageWx.cpp52
1 files changed, 38 insertions, 14 deletions
diff --git a/WebCore/platform/graphics/wx/ImageWx.cpp b/WebCore/platform/graphics/wx/ImageWx.cpp
index 785466c..a05a31f 100644
--- a/WebCore/platform/graphics/wx/ImageWx.cpp
+++ b/WebCore/platform/graphics/wx/ImageWx.cpp
@@ -57,8 +57,9 @@ void FrameData::clear()
if (m_frame) {
delete m_frame;
m_frame = 0;
- m_duration = 0.;
- m_hasAlpha = true;
+ // NOTE: We purposefully don't reset metadata here, so that even if we
+ // throw away previously-decoded data, animation loops can still access
+ // properties like frame durations without re-decoding.
}
}
@@ -66,13 +67,13 @@ void FrameData::clear()
// Image Class
// ================================================
-Image* Image::loadPlatformResource(const char *name)
+PassRefPtr<Image> Image::loadPlatformResource(const char *name)
{
Vector<char> arr = loadResourceIntoArray(name);
- Image* img = new BitmapImage();
- RefPtr<SharedBuffer> buffer = new SharedBuffer(arr.data(), arr.size());
+ RefPtr<Image> img = BitmapImage::create();
+ RefPtr<SharedBuffer> buffer = SharedBuffer::create(arr.data(), arr.size());
img->setData(buffer, true);
- return img;
+ return img.release();
}
void BitmapImage::initPlatformData()
@@ -87,30 +88,49 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatR
if (!m_source.initialized())
return;
+ if (mayFillWithSolidColor()) {
+ fillWithSolidColor(ctxt, dst, solidColor(), op);
+ return;
+ }
+
#if USE(WXGC)
wxGCDC* context = (wxGCDC*)ctxt->platformContext();
#else
wxWindowDC* context = ctxt->platformContext();
#endif
+ startAnimation();
+
wxBitmap* bitmap = frameAtIndex(m_currentFrame);
if (!bitmap) // If it's too early we won't have an image yet.
return;
-
- IntSize selfSize = size();
- FloatRect srcRect(src);
- FloatRect dstRect(dst);
// If we're drawing a sub portion of the image or scaling then create
// a pattern transformation on the image and draw the transformed pattern.
// Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
// FIXME: NYI
+ ctxt->save();
+
+ // Set the compositing operation.
+ ctxt->setCompositeOperation(op);
+
+ IntRect srcIntRect(src);
+ IntRect dstIntRect(dst);
+ bool rescaling = false;
+ if ((dstIntRect.width() != srcIntRect.width()) || (dstIntRect.height() != srcIntRect.height()))
+ {
+ rescaling = true;
+ wxImage img = bitmap->ConvertToImage();
+ img.Rescale(dstIntRect.width(), dstIntRect.height());
+ bitmap = new wxBitmap(img);
+ }
wxMemoryDC mydc;
ASSERT(bitmap->GetRefData());
mydc.SelectObject(*bitmap);
- context->Blit((wxCoord)dst.x(),(wxCoord)dst.y(), (wxCoord)dst.width(), (wxCoord)dst.height(), &mydc,
- (wxCoord)src.x(), (wxCoord)src.y(), wxCOPY, true);
+
+ context->Blit((wxCoord)dstIntRect.x(),(wxCoord)dstIntRect.y(), (wxCoord)dstIntRect.width(), (wxCoord)dstIntRect.height(), &mydc,
+ (wxCoord)srcIntRect.x(), (wxCoord)srcIntRect.y(), wxCOPY, true);
mydc.SelectObject(wxNullBitmap);
// NB: delete is causing crashes during page load, but not during the deletion
@@ -118,10 +138,14 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatR
// suddenly becomes invalid after returning. It's possible these errors deal
// with reentrancy and threding problems.
//delete bitmap;
- startAnimation();
+ if (rescaling)
+ {
+ delete bitmap;
+ bitmap = NULL;
+ }
+ ctxt->restore();
}
-
void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, CompositeOperator, const FloatRect& dstRect)
{
if (!m_source.initialized())