[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

paroga at webkit.org paroga at webkit.org
Wed Dec 22 13:28:20 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 410bc1ec82626f50944f202429986d9fa69d7ae6
Author: paroga at webkit.org <paroga at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Sep 16 15:57:20 2010 +0000

    2010-09-16  Patrick Gansterer  <paroga at paroga.com>
    
            Reviewed by Adam Roben.
    
            [WINCE] Add platform-specific Image methods
            https://bugs.webkit.org/show_bug.cgi?id=28272
    
            * platform/graphics/wince/ImageWinCE.cpp: Added.
            (WebCore::RGBA32Buffer::asNewNativeImage):
            (WebCore::FrameData::clear):
            (WebCore::BitmapImage::getHBITMAPOfSize):
            (WebCore::BitmapImage::drawFrameMatchingSourceSize):
            (WebCore::BitmapImage::draw):
            (WebCore::Image::drawPattern):
            (WebCore::BitmapImage::drawPattern):
            (WebCore::BitmapImage::checkForSolidColor):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67624 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 433b1d6..648c3a2 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-16  Patrick Gansterer  <paroga at paroga.com>
+
+        Reviewed by Adam Roben.
+
+        [WINCE] Add platform-specific Image methods
+        https://bugs.webkit.org/show_bug.cgi?id=28272
+
+        * platform/graphics/wince/ImageWinCE.cpp: Added.
+        (WebCore::RGBA32Buffer::asNewNativeImage):
+        (WebCore::FrameData::clear):
+        (WebCore::BitmapImage::getHBITMAPOfSize):
+        (WebCore::BitmapImage::drawFrameMatchingSourceSize):
+        (WebCore::BitmapImage::draw):
+        (WebCore::Image::drawPattern):
+        (WebCore::BitmapImage::drawPattern):
+        (WebCore::BitmapImage::checkForSolidColor):
+
 2010-09-16  Yury Semikhatsky  <yurys at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/platform/graphics/wince/ImageWinCE.cpp b/WebCore/platform/graphics/wince/ImageWinCE.cpp
new file mode 100644
index 0000000..61ec954
--- /dev/null
+++ b/WebCore/platform/graphics/wince/ImageWinCE.cpp
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2007-2009 Torch Mobile Inc.
+ * Copyright (C) 2010 Patrick Gansterer <paroga at paroga.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Image.h"
+
+#include "BitmapImage.h"
+#include "GraphicsContext.h"
+#include "ImageDecoder.h"
+#include "NotImplemented.h"
+#include "PlatformString.h"
+#include "SharedBuffer.h"
+#include "TransformationMatrix.h"
+#include "WinceGraphicsExtras.h"
+#include <wtf/OwnPtr.h>
+
+#include <windows.h>
+
+namespace WebCore {
+
+NativeImagePtr RGBA32Buffer::asNewNativeImage() const
+{
+    NativeImagePtr image = SharedBitmap::createInstance(false, width(), height(), false);
+
+    memcpy(image->bytes(), m_bytes.data(), m_bytes.size() * sizeof(PixelData));
+
+    return image;
+}
+
+bool FrameData::clear(bool clearMetaData)
+{
+    if (clearMetaData)
+        m_haveMetadata = false;
+
+    if (m_frame) {
+        m_frame = 0;
+        return true;
+    }
+
+    return false;
+}
+
+bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size)
+{
+    if (!bmp)
+        return false;
+
+    BITMAP bmpInfo;
+    GetObject(bmp, sizeof(BITMAP), &bmpInfo);
+
+    ASSERT(bmpInfo.bmBitsPixel == 32);
+    int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
+
+    OwnPtr<HDC> hdc(CreateCompatibleDC(0));
+    HGDIOBJ hOldBmp = SelectObject(hdc.get(), bmp);
+
+    {
+        GraphicsContext gc(hdc.get());
+
+        IntSize imageSize = BitmapImage::size();
+        if (size)
+            drawFrameMatchingSourceSize(&gc, FloatRect(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), DeviceColorSpace, CompositeCopy);
+        else
+            draw(&gc, FloatRect(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0, 0, imageSize.width(), imageSize.height()), DeviceColorSpace, CompositeCopy);
+    }
+
+    SelectObject(hdc.get(), hOldBmp);
+
+    return true;
+}
+
+void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const FloatRect& dstRect, const IntSize& srcSize, ColorSpace styleColorSpace, CompositeOperator compositeOp)
+{
+    int frames = frameCount();
+    for (int i = 0; i < frames; ++i) {
+        RefPtr<SharedBitmap> bmp = frameAtIndex(i);
+        if (!bmp || bmp->height() != static_cast<unsigned>(srcSize.height()) || bmp->width() != static_cast<unsigned>(srcSize.width()))
+            continue;
+
+        size_t currentFrame = m_currentFrame;
+        m_currentFrame = i;
+        draw(ctxt, dstRect, FloatRect(0, 0, srcSize.width(), srcSize.height()), styleColorSpace, compositeOp);
+        m_currentFrame = currentFrame;
+        return;
+    }
+
+    // No image of the correct size was found, fallback to drawing the current frame
+    IntSize imageSize = BitmapImage::size();
+    draw(ctxt, dstRect, FloatRect(0, 0, imageSize.width(), imageSize.height()), styleColorSpace, compositeOp);
+}
+
+void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRectIn, ColorSpace styleColorSpace, CompositeOperator compositeOp)
+{
+    if (!m_source.initialized())
+        return;
+
+    if (mayFillWithSolidColor())
+        fillWithSolidColor(ctxt, dstRect, solidColor(), styleColorSpace, compositeOp);
+    else {
+        IntRect intSrcRect(srcRectIn);
+        RefPtr<SharedBitmap> bmp = frameAtIndex(m_currentFrame);
+
+        if (bmp->width() != m_source.size().width()) {
+            double scaleFactor = static_cast<double>(bmp->width()) / m_source.size().width();
+
+            intSrcRect.setX(stableRound(srcRectIn.x() * scaleFactor));
+            intSrcRect.setWidth(stableRound(srcRectIn.width() * scaleFactor));
+            intSrcRect.setY(stableRound(srcRectIn.y() * scaleFactor));
+            intSrcRect.setHeight(stableRound(srcRectIn.height() * scaleFactor));
+        }
+        bmp->draw(ctxt, enclosingIntRect(dstRect), intSrcRect, styleColorSpace, compositeOp);
+    }
+
+    startAnimation();
+}
+
+void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
+                        const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+{
+    notImplemented();
+}
+
+void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRectIn, const AffineTransform& patternTransform,
+                        const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+{
+    RefPtr<SharedBitmap> bmp = nativeImageForCurrentFrame();
+    if (!bmp)
+        return;
+
+    bmp->drawPattern(ctxt, tileRectIn, patternTransform, phase, styleColorSpace, op, destRect, m_source.size());
+}
+
+void BitmapImage::checkForSolidColor()
+{
+    if (m_checkedForSolidColor)
+        return;
+
+    if (frameCount() != 1) {
+        m_isSolidColor = false;
+        m_checkedForSolidColor = true;
+        return;
+    }
+
+    RefPtr<SharedBitmap> bmp = frameAtIndex(0);
+    if (!bmp || !bmp->validHeight()) {
+        m_isSolidColor = false;
+        return;
+    }
+
+    if (bmp->width() != 1 || bmp->validHeight() != 1) {
+        m_isSolidColor = false;
+        m_checkedForSolidColor = true;
+        return;
+    }
+
+    m_isSolidColor = true;
+
+    if (bmp->is16bit()) {
+        unsigned short c = ((unsigned short *)bmp->bytes())[0];
+        int r = (c >> 7) & 0xF8;
+        int g = (c >> 2) & 0xF8;
+        int b = (c << 3) & 0xF8;
+        if (bmp->usesTransparentColor() && bmp->transparentColor() == RGB(r, g, b))
+            m_solidColor = Color(r, g, b, 0);
+        else
+            m_solidColor = Color(r, g, b);
+    } else {
+        unsigned c = ((unsigned *)bmp->bytes())[0];
+        m_solidColor = Color(c);
+    }
+
+    if (bmp->validHeight() == bmp->height())
+        m_checkedForSolidColor = true;
+}
+
+} // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list