[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:59:12 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 56f3066ff925289a047dcdb80bc8674f4e5c9d22
Author: paroga at webkit.org <paroga at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Sep 30 22:08:40 2010 +0000
2010-09-30 Patrick Gansterer <paroga at webkit.org>
Reviewed by Adam Roben.
[WINCE] Use OwnPtr for HBRUSH and HPEN in GraphicsContext
https://bugs.webkit.org/show_bug.cgi?id=46881
Also add some missing SelectObject calls.
* platform/graphics/wince/GraphicsContextWinCE.cpp:
(WebCore::createPen):
(WebCore::createBrush):
(WebCore::GraphicsContext::drawRect):
(WebCore::GraphicsContext::drawLine):
(WebCore::GraphicsContext::drawEllipse):
(WebCore::GraphicsContext::strokeArc):
(WebCore::GraphicsContext::drawConvexPolygon):
(WebCore::GraphicsContext::strokeRect):
(WebCore::GraphicsContext::fillRoundedRect):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68839 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d102bba..81e417a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-09-30 Patrick Gansterer <paroga at webkit.org>
+
+ Reviewed by Adam Roben.
+
+ [WINCE] Use OwnPtr for HBRUSH and HPEN in GraphicsContext
+ https://bugs.webkit.org/show_bug.cgi?id=46881
+
+ Also add some missing SelectObject calls.
+
+ * platform/graphics/wince/GraphicsContextWinCE.cpp:
+ (WebCore::createPen):
+ (WebCore::createBrush):
+ (WebCore::GraphicsContext::drawRect):
+ (WebCore::GraphicsContext::drawLine):
+ (WebCore::GraphicsContext::drawEllipse):
+ (WebCore::GraphicsContext::strokeArc):
+ (WebCore::GraphicsContext::drawConvexPolygon):
+ (WebCore::GraphicsContext::strokeRect):
+ (WebCore::GraphicsContext::fillRoundedRect):
+ (WebCore::GraphicsContext::fillPath):
+ (WebCore::GraphicsContext::strokePath):
+
2010-09-30 Anders Carlsson <andersca at apple.com>
Reviewed by Dan Bernstein and Darin Adler.
diff --git a/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp
index a91b988..cc699e4 100644
--- a/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp
+++ b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp
@@ -347,7 +347,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 +367,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 +644,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 +694,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 +719,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 +801,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 +858,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 +901,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)
@@ -1124,8 +1100,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 +1117,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 +1261,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 +1299,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 +1356,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 +1371,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 +1394,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 +1409,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);
}
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list