diff options
Diffstat (limited to 'WebCore/platform/graphics/wince')
5 files changed, 68 insertions, 140 deletions
diff --git a/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp index a91b988..a0c10fc 100644 --- a/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp +++ b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2007-2009 Torch Mobile Inc. + * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,6 +25,7 @@ #include "AffineTransform.h" #include "CharacterNames.h" #include "Font.h" +#include "GDIExtras.h" #include "GlyphBuffer.h" #include "Gradient.h" #include "GraphicsContextPrivate.h" @@ -322,8 +324,7 @@ public: if (hdc == m_dc) return; -#if !defined(NO_ALPHABLEND) - if (alphaPaint == AlphaPaintOther) { + if (alphaPaint == AlphaPaintOther && hasAlphaBlendSupport()) { ASSERT(bmp && bmp->bytes() && bmp->is32bit()); unsigned* pixels = (unsigned*)bmp->bytes(); const unsigned* const pixelsEnd = pixels + bmp->bitmapInfo().numPixels(); @@ -332,13 +333,13 @@ public: ++pixels; } } - if (m_opacity < 1. || alphaPaint == AlphaPaintOther) { + if ((m_opacity < 1. || alphaPaint == AlphaPaintOther) && hasAlphaBlendSupport()) { const BLENDFUNCTION blend = { AC_SRC_OVER, 0 , m_opacity >= 1. ? 255 : (BYTE)(m_opacity * 255) , alphaPaint == AlphaPaintNone ? 0 : AC_SRC_ALPHA }; - AlphaBlend(m_dc, origRect.x(), origRect.y(), origRect.width(), origRect.height(), hdc, 0, 0, bmpRect.right, bmpRect.bottom, blend); + bool success = alphaBlendIfSupported(m_dc, origRect.x(), origRect.y(), origRect.width(), origRect.height(), hdc, 0, 0, bmpRect.right, bmpRect.bottom, blend); + ASSERT_UNUSED(success, success); } else -#endif StretchBlt(m_dc, origRect.x(), origRect.y(), origRect.width(), origRect.height(), hdc, 0, 0, bmpRect.right, bmpRect.bottom, SRCCOPY); } @@ -347,7 +348,7 @@ public: Vector<GraphicsContextPlatformPrivateData> m_backupData; }; -static HPEN createPen(const Color& col, double fWidth, StrokeStyle style) +static PassOwnPtr<HPEN> createPen(const Color& col, double fWidth, StrokeStyle style) { int width = stableRound(fWidth); if (width < 1) @@ -367,12 +368,12 @@ static HPEN createPen(const Color& col, double fWidth, StrokeStyle style) break; } - return CreatePen(penStyle, width, RGB(col.red(), col.green(), col.blue())); + return adoptPtr(CreatePen(penStyle, width, RGB(col.red(), col.green(), col.blue()))); } -static inline HGDIOBJ createBrush(const Color& col) +static inline PassOwnPtr<HBRUSH> createBrush(const Color& col) { - return CreateSolidBrush(RGB(col.red(), col.green(), col.blue())); + return adoptPtr(CreateSolidBrush(RGB(col.red(), col.green(), col.blue()))); } template <typename PixelType, bool Is16bit> static void _rotateBitmap(SharedBitmap* destBmp, const SharedBitmap* sourceBmp, const RotationTransform& transform) @@ -644,41 +645,33 @@ void GraphicsContext::drawRect(const IntRect& rect) return; trRect.move(transparentDC.toShift()); - HGDIOBJ brush = 0; + OwnPtr<HBRUSH> brush; HGDIOBJ oldBrush; if (fillColor().alpha()) { brush = createBrush(fillColor()); - oldBrush = SelectObject(dc, brush); + oldBrush = SelectObject(dc, brush.get()); } else - SelectObject(dc, GetStockObject(NULL_BRUSH)); + oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH)); - HGDIOBJ pen = 0; + OwnPtr<HPEN> pen; HGDIOBJ oldPen; if (strokeStyle() != NoStroke) { pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); - oldPen = SelectObject(dc, pen); + oldPen = SelectObject(dc, pen.get()); } else - SelectObject(dc, GetStockObject(NULL_PEN)); + oldPen = SelectObject(dc, GetStockObject(NULL_PEN)); - if (!brush && !pen) - return; - - if (trRect.width() <= 0) - trRect.setWidth(1); - if (trRect.height() <= 0) - trRect.setHeight(1); - - Rectangle(dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom()); + if (brush || pen) { + if (trRect.width() <= 0) + trRect.setWidth(1); + if (trRect.height() <= 0) + trRect.setHeight(1); - if (pen) { - SelectObject(dc, oldPen); - DeleteObject(pen); + Rectangle(dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom()); } - if (brush) { - SelectObject(dc, oldBrush); - DeleteObject(brush); - } + SelectObject(dc, oldPen); + SelectObject(dc, oldBrush); } void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) @@ -702,14 +695,13 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) trPoint1 += transparentDC.toShift(); trPoint2 += transparentDC.toShift(); - HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); - HGDIOBJ oldPen = SelectObject(dc, pen); + OwnPtr<HPEN> pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); + HGDIOBJ oldPen = SelectObject(dc, pen.get()); MoveToEx(dc, trPoint1.x(), trPoint1.y(), 0); LineTo(dc, trPoint2.x(), trPoint2.y()); SelectObject(dc, oldPen); - DeleteObject(pen); } void GraphicsContext::drawEllipse(const IntRect& rect) @@ -728,32 +720,27 @@ void GraphicsContext::drawEllipse(const IntRect& rect) return; trRect.move(transparentDC.toShift()); - HGDIOBJ brush = 0; + OwnPtr<HBRUSH> brush; HGDIOBJ oldBrush; if (fillColor().alpha()) { brush = createBrush(fillColor()); - oldBrush = SelectObject(dc, brush); + oldBrush = SelectObject(dc, brush.get()); } else - SelectObject(dc, GetStockObject(NULL_BRUSH)); - HGDIOBJ pen = 0; - HGDIOBJ oldPen; + oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH)); + + OwnPtr<HPEN> pen; + HGDIOBJ oldPen = 0; if (strokeStyle() != NoStroke) { pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); - oldPen = SelectObject(dc, pen); + oldPen = SelectObject(dc, pen.get()); } else - SelectObject(dc, GetStockObject(NULL_PEN)); - - Ellipse(dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom()); + oldPen = SelectObject(dc, GetStockObject(NULL_PEN)); - if (pen) { - SelectObject(dc, oldPen); - DeleteObject(pen); - } + if (brush || pen) + Ellipse(dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom()); - if (brush) { - SelectObject(dc, oldBrush); - DeleteObject(brush); - } + SelectObject(dc, oldPen); + SelectObject(dc, oldBrush); } static inline bool equalAngle(double a, double b) @@ -815,8 +802,8 @@ void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSp return; trRect.move(transparentDC.toShift()); - HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); - HGDIOBJ oldPen = SelectObject(dc, pen); + OwnPtr<HPEN> pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); + HGDIOBJ oldPen = SelectObject(dc, pen.get()); double a = trRect.width() * 0.5; double b = trRect.height() * 0.5; @@ -872,7 +859,6 @@ void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSp SelectClipRgn(dc, clipRgn.get()); SelectObject(dc, oldPen); - DeleteObject(pen); } void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias) @@ -916,36 +902,27 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points winPoints[i].y += transparentDC.toShift().height(); } - HGDIOBJ brush = 0; + OwnPtr<HBRUSH> brush; HGDIOBJ oldBrush; if (fillColor().alpha()) { brush = createBrush(fillColor()); - oldBrush = SelectObject(dc, brush); + oldBrush = SelectObject(dc, brush.get()); } else - SelectObject(dc, GetStockObject(NULL_BRUSH)); + oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH)); - HGDIOBJ pen = 0; + OwnPtr<HPEN> pen; HGDIOBJ oldPen; if (strokeStyle() != NoStroke) { pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); - oldPen = SelectObject(dc, pen); + oldPen = SelectObject(dc, pen.get()); } else - SelectObject(dc, GetStockObject(NULL_PEN)); - - if (!brush && !pen) - return; - - Polygon(dc, winPoints.data(), npoints); + oldPen = SelectObject(dc, GetStockObject(NULL_PEN)); - if (pen) { - SelectObject(dc, oldPen); - DeleteObject(pen); - } + if (brush || pen) + Polygon(dc, winPoints.data(), npoints); - if (brush) { - SelectObject(dc, oldBrush); - DeleteObject(brush); - } + SelectObject(dc, oldPen); + SelectObject(dc, oldBrush); } void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased) @@ -1104,7 +1081,7 @@ void GraphicsContext::clearRect(const FloatRect& rect) return; } - fillRect(rect, Color(Color::white), DeviceColorSpace); + fillRect(rect, Color(Color::white), ColorSpaceDeviceRGB); } void GraphicsContext::strokeRect(const FloatRect& rect, float width) @@ -1124,8 +1101,8 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float width) return; trRect.move(transparentDC.toShift()); - HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); - HGDIOBJ oldPen = SelectObject(dc, pen); + OwnPtr<HPEN> pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); + HGDIOBJ oldPen = SelectObject(dc, pen.get()); int right = trRect.right() - 1; int bottom = trRect.bottom() - 1; @@ -1141,7 +1118,6 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float width) Polyline(dc, intPoints, 5); SelectObject(dc, oldPen); - DeleteObject(pen); } void GraphicsContext::beginTransparencyLayer(float opacity) @@ -1286,9 +1262,9 @@ void GraphicsContext::fillRoundedRect(const IntRect& fillRect, const IntSize& to RECT rectWin = dstRect; - HGDIOBJ brush = createBrush(shadowColor); - HGDIOBJ oldBrush = SelectObject(dc, brush); - + OwnPtr<HBRUSH> brush = createBrush(shadowColor); + HGDIOBJ oldBrush = SelectObject(dc, brush.get()); + SelectObject(dc, GetStockObject(NULL_PEN)); IntPoint centerPoint = rectCenterPoint(rectWin); @@ -1324,7 +1300,6 @@ void GraphicsContext::fillRoundedRect(const IntRect& fillRect, const IntSize& to drawRoundCorner(needsNewClip, clipRect, rectWin, dc, stableRound(newBottomRight.width() * 2), stableRound(newBottomRight.height() * 2)); SelectObject(dc, oldBrush); - DeleteObject(brush); } @@ -1382,8 +1357,9 @@ void GraphicsContext::fillPath() if (!m_data->m_dc) return; + OwnPtr<HBRUSH> brush = createBrush(c); + if (m_data->m_opacity < 1.0f || m_data->hasAlpha()) { - HGDIOBJ brush = createBrush(c); for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i) { IntRect trRect = enclosingIntRect(m_data->mapRect(i->boundingRect())); trRect.inflate(1); @@ -1396,19 +1372,16 @@ void GraphicsContext::fillPath() tr.translate(transparentDC.toShift().width(), transparentDC.toShift().height()); SelectObject(dc, GetStockObject(NULL_PEN)); - HGDIOBJ oldBrush = SelectObject(dc, brush); + HGDIOBJ oldBrush = SelectObject(dc, brush.get()); i->platformPath()->fillPath(dc, &tr); SelectObject(dc, oldBrush); } - DeleteObject(brush); } else { SelectObject(m_data->m_dc, GetStockObject(NULL_PEN)); - HGDIOBJ brush = createBrush(c); - HGDIOBJ oldBrush = SelectObject(m_data->m_dc, brush); + HGDIOBJ oldBrush = SelectObject(m_data->m_dc, brush.get()); for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i) i->platformPath()->fillPath(m_data->m_dc, &m_data->m_transform); SelectObject(m_data->m_dc, oldBrush); - DeleteObject(brush); } } @@ -1422,8 +1395,9 @@ void GraphicsContext::strokePath() if (!m_data->m_dc) return; + OwnPtr<HPEN> pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); + if (m_data->m_opacity < 1.0f || m_data->hasAlpha()) { - HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i) { IntRect trRect = enclosingIntRect(m_data->mapRect(i->boundingRect())); trRect.inflate(1); @@ -1436,19 +1410,16 @@ void GraphicsContext::strokePath() tr.translate(transparentDC.toShift().width(), transparentDC.toShift().height()); SelectObject(dc, GetStockObject(NULL_BRUSH)); - HGDIOBJ oldPen = SelectObject(dc, pen); + HGDIOBJ oldPen = SelectObject(dc, pen.get()); i->platformPath()->strokePath(dc, &tr); SelectObject(dc, oldPen); } - DeleteObject(pen); } else { SelectObject(m_data->m_dc, GetStockObject(NULL_BRUSH)); - HGDIOBJ pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); - HGDIOBJ oldPen = SelectObject(m_data->m_dc, pen); + HGDIOBJ oldPen = SelectObject(m_data->m_dc, pen.get()); for (Vector<Path>::const_iterator i = m_data->m_paths.begin(); i != m_data->m_paths.end(); ++i) i->platformPath()->strokePath(m_data->m_dc, &m_data->m_transform); SelectObject(m_data->m_dc, oldPen); - DeleteObject(pen); } } @@ -1465,7 +1436,7 @@ void GraphicsContext::fillRect(const FloatRect& r, const Gradient* gradient) if (numStops == 1) { const Gradient::ColorStop& stop = stops.first(); Color color(stop.red, stop.green, stop.blue, stop.alpha); - fillRect(r, color, DeviceColorSpace); + fillRect(r, color, ColorSpaceDeviceRGB); return; } @@ -1555,7 +1526,7 @@ void GraphicsContext::fillRect(const FloatRect& rect) if (m_common->state.fillGradient) fillRect(rect, m_common->state.fillGradient.get()); else - fillRect(rect, fillColor(), DeviceColorSpace); + fillRect(rect, fillColor(), ColorSpaceDeviceRGB); restorePlatformState(); } diff --git a/WebCore/platform/graphics/wince/ImageWinCE.cpp b/WebCore/platform/graphics/wince/ImageWinCE.cpp index 61ec954..53b9b68 100644 --- a/WebCore/platform/graphics/wince/ImageWinCE.cpp +++ b/WebCore/platform/graphics/wince/ImageWinCE.cpp @@ -82,9 +82,9 @@ bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size) IntSize imageSize = BitmapImage::size(); if (size) - drawFrameMatchingSourceSize(&gc, FloatRect(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), DeviceColorSpace, CompositeCopy); + drawFrameMatchingSourceSize(&gc, FloatRect(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), ColorSpaceDeviceRGB, CompositeCopy); else - draw(&gc, FloatRect(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0, 0, imageSize.width(), imageSize.height()), DeviceColorSpace, CompositeCopy); + draw(&gc, FloatRect(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0, 0, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, CompositeCopy); } SelectObject(hdc.get(), hOldBmp); diff --git a/WebCore/platform/graphics/wince/PathWinCE.cpp b/WebCore/platform/graphics/wince/PathWinCE.cpp index 4f0195c..fa4c8fb 100644 --- a/WebCore/platform/graphics/wince/PathWinCE.cpp +++ b/WebCore/platform/graphics/wince/PathWinCE.cpp @@ -123,11 +123,6 @@ bool Path::isEmpty() const return m_path->isEmpty(); } -String Path::debugString() const -{ - return m_path->debugString(); -} - void Path::apply(void* info, PathApplierFunction function) const { m_path->apply(info, function); diff --git a/WebCore/platform/graphics/wince/PlatformPathWinCE.cpp b/WebCore/platform/graphics/wince/PlatformPathWinCE.cpp index 80e01a9..8534f89 100644 --- a/WebCore/platform/graphics/wince/PlatformPathWinCE.cpp +++ b/WebCore/platform/graphics/wince/PlatformPathWinCE.cpp @@ -754,43 +754,6 @@ void PlatformPath::addEllipse(const FloatRect& r) addEllipse(r.location() + radius, radius.width(), radius.height(), 0, 0, true); } -String PlatformPath::debugString() const -{ - String ret; - for (PlatformPathElements::const_iterator i(m_elements.begin()); i != m_elements.end(); ++i) { - switch (i->platformType()) { - case PlatformPathElement::PathMoveTo: - case PlatformPathElement::PathLineTo: - ret += String::format("M %f %f\n", i->pointAt(0).m_x, i->pointAt(0).m_y); - break; - case PlatformPathElement::PathArcTo: - ret += String::format("A %f %f %f %f %f %f %c\n" - , i->arcTo().m_end.m_x, i->arcTo().m_end.m_y - , i->arcTo().m_center.m_x, i->arcTo().m_center.m_y - , i->arcTo().m_radius.m_x, i->arcTo().m_radius.m_y - , i->arcTo().m_clockwise? 'Y' : 'N'); - break; - case PlatformPathElement::PathQuadCurveTo: - ret += String::format("Q %f %f %f %f\n" - , i->pointAt(0).m_x, i->pointAt(0).m_y - , i->pointAt(1).m_x, i->pointAt(1).m_y); - break; - case PlatformPathElement::PathBezierCurveTo: - ret += String::format("B %f %f %f %f %f %f\n" - , i->pointAt(0).m_x, i->pointAt(0).m_y - , i->pointAt(1).m_x, i->pointAt(1).m_y - , i->pointAt(2).m_x, i->pointAt(2).m_y); - break; - default: - ASSERT(i->platformType() == PlatformPathElement::PathCloseSubpath); - ret += "S\n"; - break; - } - } - - return ret; -} - void PlatformPath::apply(void* info, PathApplierFunction function) const { PathElement pelement; diff --git a/WebCore/platform/graphics/wince/PlatformPathWinCE.h b/WebCore/platform/graphics/wince/PlatformPathWinCE.h index 3414b04..4c86fc3 100644 --- a/WebCore/platform/graphics/wince/PlatformPathWinCE.h +++ b/WebCore/platform/graphics/wince/PlatformPathWinCE.h @@ -164,7 +164,6 @@ namespace WebCore { void addEllipse(const FloatPoint& p, float a, float b, float sar, float ear, bool anticlockwise); void addRect(const FloatRect& r); void addEllipse(const FloatRect& r); - String debugString() const; void apply(void* info, PathApplierFunction function) const; private: |