[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

eric at webkit.org eric at webkit.org
Fri Feb 26 22:17:27 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 986bea304068614a9f82016ef3991c16150a9f6a
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Feb 11 02:46:59 2010 +0000

    2010-02-10  Stephan Aßmus  <superstippi at gmx.de>
    
            Reviewed by David Levin.
    
            Fixes to rect conversion and image rendering on Haiku
            https://bugs.webkit.org/show_bug.cgi?id=34684
    
            Covered by existing tests.
    
            The changes to the rect conversions are indeed correct. In Haiku (to stay
            compatibly with BeOS), a BRect specifies the left/top and bottom/right pixel
            *indices*, even though the values are floating point. So a rectangle covering
            just one pixel would be specified as BRect(0, 0, 0, 0). In WebCore and other
            frame works, such rectangles would be expressed as 0, 0, 1, 1. In WebCore, the
            width and height of rectangles refer to the distance between pixels, while on
            Haiku, a one pixel rect has indeed a width and height of 0, as confusing as
            that may be.
    
            The part of the patch that affects
            WebCore/platform/graphics/haiku/ImageHaiku.cpp also implements the drawing
            methods more correctly. Image observers are notified, and pattern drawing takes
            the "phase" into account which makes scrolled backgrounds render correctly.
            Transformations are still not supported, since the Haiku drawing backend itself
            does not yet support them.
    
            Use OwnPtr when creating the BBitmap to avoid future leaks with early returns.
    
            Convert the bitmap data to non pre-multiplied until Haiku supports drawing
            pre-multiplied bitmaps.
    
            * platform/graphics/haiku/FloatRectHaiku.cpp: Fixed conversion
            * platform/graphics/haiku/ImageHaiku.cpp:
            (WebCore::BitmapImage::draw): Fixed placement, notify observers
            (WebCore::Image::drawPattern): Implemented using "phase" to fix scrolling, notify observers
            * platform/graphics/haiku/IntRectHaiku.cpp: Fixed conversion
            * platform/image-decoders/haiku/ImageDecoderHaiku.cpp: Fixed conversion
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54637 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 18fbc10..0584b8c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,40 @@
+2010-02-10  Stephan Aßmus  <superstippi at gmx.de>
+
+        Reviewed by David Levin.
+
+        Fixes to rect conversion and image rendering on Haiku
+        https://bugs.webkit.org/show_bug.cgi?id=34684
+
+        Covered by existing tests.
+
+        The changes to the rect conversions are indeed correct. In Haiku (to stay
+        compatibly with BeOS), a BRect specifies the left/top and bottom/right pixel
+        *indices*, even though the values are floating point. So a rectangle covering
+        just one pixel would be specified as BRect(0, 0, 0, 0). In WebCore and other
+        frame works, such rectangles would be expressed as 0, 0, 1, 1. In WebCore, the
+        width and height of rectangles refer to the distance between pixels, while on
+        Haiku, a one pixel rect has indeed a width and height of 0, as confusing as
+        that may be.
+
+        The part of the patch that affects
+        WebCore/platform/graphics/haiku/ImageHaiku.cpp also implements the drawing
+        methods more correctly. Image observers are notified, and pattern drawing takes
+        the "phase" into account which makes scrolled backgrounds render correctly.
+        Transformations are still not supported, since the Haiku drawing backend itself
+        does not yet support them.
+
+        Use OwnPtr when creating the BBitmap to avoid future leaks with early returns.
+
+        Convert the bitmap data to non pre-multiplied until Haiku supports drawing
+        pre-multiplied bitmaps.
+
+        * platform/graphics/haiku/FloatRectHaiku.cpp: Fixed conversion
+        * platform/graphics/haiku/ImageHaiku.cpp:
+        (WebCore::BitmapImage::draw): Fixed placement, notify observers
+        (WebCore::Image::drawPattern): Implemented using "phase" to fix scrolling, notify observers
+        * platform/graphics/haiku/IntRectHaiku.cpp: Fixed conversion
+        * platform/image-decoders/haiku/ImageDecoderHaiku.cpp: Fixed conversion
+
 2010-02-10  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by David Levin.
diff --git a/WebCore/platform/graphics/haiku/FloatRectHaiku.cpp b/WebCore/platform/graphics/haiku/FloatRectHaiku.cpp
index 67af3af..18fd94b 100644
--- a/WebCore/platform/graphics/haiku/FloatRectHaiku.cpp
+++ b/WebCore/platform/graphics/haiku/FloatRectHaiku.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2007 Ryan Leavengood <leavengood at gmail.com>
+ * Copyright (C) 2010 Stephan Aßmus <superstippi at gmx.de>
  *
  * All rights reserved.
  *
@@ -35,13 +36,13 @@ namespace WebCore {
 
 FloatRect::FloatRect(const BRect& rect)
     : m_location(rect.LeftTop())
-    , m_size(rect.Width(), rect.Height())
+    , m_size(rect.Width() + 1, rect.Height() + 1)
 {
 }
 
 FloatRect::operator BRect() const
 {
-    return BRect(BPoint(x(), y()), BSize(width(), height()));
+    return BRect(BPoint(x(), y()), BSize(width() - 1, height() - 1));
 }
 
 } // namespace WebCore
diff --git a/WebCore/platform/graphics/haiku/ImageHaiku.cpp b/WebCore/platform/graphics/haiku/ImageHaiku.cpp
index 0fbd0a3..976154c 100644
--- a/WebCore/platform/graphics/haiku/ImageHaiku.cpp
+++ b/WebCore/platform/graphics/haiku/ImageHaiku.cpp
@@ -4,6 +4,7 @@
  * Copyright (C) 2006 Simon Hausmann <hausmann at kde.org>
  * Copyright (C) 2007 Ryan Leavengood <leavengood at gmail.com>
  * Copyright (C) 2008 Andrea Anzani <andrea.anzani at gmail.com>
+ * Copyright (C) 2010 Stephan Aßmus <superstippi at gmx.de>
  *
  * All rights reserved.
  *
@@ -35,13 +36,14 @@
 #include "BitmapImage.h"
 #include "FloatRect.h"
 #include "GraphicsContext.h"
+#include "ImageObserver.h"
 #include "NotImplemented.h"
 #include "PlatformString.h"
+#include "TransformationMatrix.h"
 #include <Application.h>
 #include <Bitmap.h>
 #include <View.h>
 
-
 // This function loads resources from WebKit
 Vector<char> loadResourceIntoArray(const char*);
 
@@ -85,6 +87,12 @@ void BitmapImage::invalidatePlatformData()
 // Drawing Routines
 void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op)
 {
+    if (!m_source.initialized())
+        return;
+
+    // Spin the animation to the correct frame before we try to draw it, so we
+    // don't draw an old frame and then immediately need to draw a newer one,
+    // causing flicker and wasting CPU.
     startAnimation();
 
     BBitmap* image = nativeImageForCurrentFrame();
@@ -105,42 +113,76 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatR
     // Test using example site at
     // http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
     ctxt->platformContext()->SetDrawingMode(B_OP_ALPHA);
-    ctxt->platformContext()->DrawBitmap(image, srcRect & image->Bounds(), dstRect);
+    ctxt->platformContext()->DrawBitmapAsync(image, srcRect, dstRect);
     ctxt->restore();
+
+    if (imageObserver())
+        imageObserver()->didDraw(this);
 }
 
 void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& srcPoint, ColorSpace, CompositeOperator op, const FloatRect& dstRect)
 {
-    // FIXME: finish this to support also phased position (srcPoint)
-    startAnimation();
-
     BBitmap* image = nativeImageForCurrentFrame();
     if (!image || !image->IsValid()) // If the image hasn't fully loaded.
         return;
 
-    float currentW = 0;
-    float currentH = 0;
+    // Figure out if the image has any alpha transparency, we can use faster drawing if not
+    bool hasAlpha = false;
+
+    uint8* bits = reinterpret_cast<uint8*>(image->Bits());
+    uint32 width = image->Bounds().IntegerWidth() + 1;
+    uint32 height = image->Bounds().IntegerHeight() + 1;
+
+    uint32 bytesPerRow = image->BytesPerRow();
+    for (uint32 y = 0; y < height && !hasAlpha; y++) {
+        uint8* p = bits;
+        for (uint32 x = 0; x < width && !hasAlpha; x++) {
+            hasAlpha = p[3] < 255;
+            p += 4;
+        }
+        bits += bytesPerRow;
+    }
 
     context->save();
-    context->platformContext()->SetDrawingMode(B_OP_ALPHA);
+    if (hasAlpha)
+        context->platformContext()->SetDrawingMode(B_OP_ALPHA);
+    else
+        context->platformContext()->SetDrawingMode(B_OP_COPY);
     context->clip(enclosingIntRect(dstRect));
-
-    while (currentW < dstRect.width()) {
-        while (currentH < dstRect.height()) {
-            context->platformContext()->DrawBitmap(image, BPoint(dstRect.x() + currentW, dstRect.y() + currentH));
-            currentH += tileRect.height();
+    float currentW = phase.x();
+    BRect bTileRect(tileRect);
+    while (currentW < dstRect.x() + dstRect.width()) {
+        float currentH = phase.y();
+        while (currentH < dstRect.y() + dstRect.height()) {
+            BRect bDstRect(currentW, currentH, currentW + width - 1, currentH + height - 1);
+            context->platformContext()->DrawBitmapAsync(image, bTileRect, bDstRect);
+            currentH += height;
         }
-        currentW += tileRect.width();
-        currentH = 0;
+        currentW += width;
     }
     context->restore();
+
+    if (imageObserver())
+        imageObserver()->didDraw(this);
 }
 
 void BitmapImage::checkForSolidColor()
 {
-    // FIXME: need to check the RGBA32 buffer to see if it is 1x1.
     m_isSolidColor = false;
     m_checkedForSolidColor = true;
+
+    if (frameCount() > 1)
+        return;
+
+    BBitmap* image = getBBitmap();
+    if (!image || !image->Bounds().IsValid()
+        || image->Bounds().IntegerWidth() > 0 || image->Bounds().IntegerHeight() > 0) {
+        return;
+    }
+
+    m_isSolidColor = true;
+    uint8* bits = reinterpret_cast<uint8*>(image->Bits());
+    m_solidColor = Color(bits[2], bits[1], bits[0], bits[3]);
 }
 
 BBitmap* BitmapImage::getBBitmap() const
diff --git a/WebCore/platform/graphics/haiku/IntRectHaiku.cpp b/WebCore/platform/graphics/haiku/IntRectHaiku.cpp
index 74a0b9d..5ee7207 100644
--- a/WebCore/platform/graphics/haiku/IntRectHaiku.cpp
+++ b/WebCore/platform/graphics/haiku/IntRectHaiku.cpp
@@ -35,13 +35,13 @@ namespace WebCore {
 
 IntRect::IntRect(const BRect& rect)
     : m_location(rect.LeftTop())
-    , m_size(rect.IntegerWidth(), rect.IntegerHeight())
+    , m_size(rect.IntegerWidth() + 1, rect.IntegerHeight() + 1)
 {
 }
 
 IntRect::operator BRect() const
 {
-    return BRect(BPoint(x(), y()), BSize(width(), height()));
+    return BRect(BPoint(x(), y()), BSize(width() - 1, height() - 1));
 }
 
 } // namespace WebCore
diff --git a/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp b/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
index dc120e3..7f00db2 100644
--- a/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
+++ b/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2010 Stephan Aßmus, <superstippi at gmx.de>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,9 +33,41 @@ namespace WebCore {
 
 NativeImagePtr RGBA32Buffer::asNewNativeImage() const
 {
-    BBitmap* bmp = new BBitmap(BRect(0, 0, width(), height()), B_RGB32);
-    bmp->SetBits(m_bytes.data(), m_size.width() * m_size.height(), 0, B_RGB32);
-    return bmp;
+    int bytesPerRow = width() * sizeof(PixelData);
+    OwnPtr<BBitmap> bitmap(new BBitmap(BRect(0, 0, width() - 1, height() - 1), 0, B_RGBA32, bytesPerRow));
+
+    const uint8* source = reinterpret_cast<const uint8*>(m_bytes.data());
+    uint8* destination = reinterpret_cast<uint8*>(bitmap->Bits());
+    int h = height();
+    int w = width();
+    for (int y = 0; y < h; y++) {
+#if 0
+// FIXME: Enable this conversion once Haiku has B_RGBA32P[remultiplied]...
+        memcpy(dst, source, bytesPerRow);
+#else
+        const uint8* sourceHandle = source;
+        uint8* destinationHandle = destination;
+        for (int x = 0; x < w; x++) {
+            if (sourceHandle[3] == 255 || !sourceHandle[3]) {
+                destinationHandle[0] = sourceHandle[0];
+                destinationHandle[1] = sourceHandle[1];
+                destinationHandle[2] = sourceHandle[2];
+                destinationHandle[3] = sourceHandle[3];
+            } else {
+                destinationHandle[0] = static_cast<uint16>(sourceHandle[0]) * 255 / sourceHandle[3];
+                destinationHandle[1] = static_cast<uint16>(sourceHandle[1]) * 255 / sourceHandle[3];
+                destinationHandle[2] = static_cast<uint16>(sourceHandle[2]) * 255 / sourceHandle[3];
+                destinationHandle[3] = sourceHandle[3];
+            }
+            destinationHandle += 4;
+            sourceHandle += 4;
+        }
+#endif
+        destination += bytesPerRow;
+        source += bytesPerRow;
+    }
+
+    return bitmap.release();
 }
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list