https://bugs.webkit.org/show_bug.cgi?id=76750
Reviewed by Adam Roben.
Source/WebKit/win:
* FullscreenVideoController.cpp:
(createCompatibleDCForWindow): Moved out the code which creates a DC for a window
to keep the same scope for the DC lifetime.
(FullscreenVideoController::draw): Switch to using OwnPtr<HDC>
since createCompatibleDCForWindow returns a PassOwnPtr.
* WebNodeHighlight.cpp:
(WebNodeHighlight::update):
Cleaned up leaks from calling GetDC without release.
Note that there is a potential leak of hdc that previously existed
and still does in an early exit scenario. (This could be easily fixed
by using OwnPtr<HDC> but I was trying to keep this patch focused.)
* WebView.cpp:
(WebView::scrollBackingStore): Typical conversion.
(WebView::updateBackingStore): Reduced the scope of windowDC to be
right where it is being used.
(WebView::performLayeredWindowUpdate): Typical conversion.
(WebView::paintIntoBackingStore): Ditto.
Source/WebKit2:
* Shared/win/ShareableBitmapWin.cpp:
(WebKit::ShareableBitmap::windowsContext): Fix incorrect usage of OwnPtr<HDC> which
would do a DeleteDC instead of a ReleaseDC.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105667
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2012-01-23 David Levin <levin@chromium.org>
+ [windows] Convert usages of GetDC to HWndDC Part 2.
+ https://bugs.webkit.org/show_bug.cgi?id=76750
+
+ Reviewed by Adam Roben.
+
+ * FullscreenVideoController.cpp:
+ (createCompatibleDCForWindow): Moved out the code which creates a DC for a window
+ to keep the same scope for the DC lifetime.
+ (FullscreenVideoController::draw): Switch to using OwnPtr<HDC>
+ since createCompatibleDCForWindow returns a PassOwnPtr.
+ * WebNodeHighlight.cpp:
+ (WebNodeHighlight::update):
+ Cleaned up leaks from calling GetDC without release.
+ Note that there is a potential leak of hdc that previously existed
+ and still does in an early exit scenario. (This could be easily fixed
+ by using OwnPtr<HDC> but I was trying to keep this patch focused.)
+ * WebView.cpp:
+ (WebView::scrollBackingStore): Typical conversion.
+ (WebView::updateBackingStore): Reduced the scope of windowDC to be
+ right where it is being used.
+ (WebView::performLayeredWindowUpdate): Typical conversion.
+ (WebView::paintIntoBackingStore): Ditto.
+
+2012-01-23 David Levin <levin@chromium.org>
+
[windows] Convert usages of GetDC to HWndDC Part 1.
https://bugs.webkit.org/show_bug.cgi?id=76744
#include <WebCore/Font.h>
#include <WebCore/FontSelector.h>
#include <WebCore/GraphicsContext.h>
+#include <WebCore/HWndDC.h>
#include <WebCore/Page.h>
#include <WebCore/PlatformCALayer.h>
#include <WebCore/TextRun.h>
#include <WebKitSystemInterface/WebKitSystemInterface.h>
#include <windowsx.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/StdLibExtras.h>
using namespace std;
void FullscreenVideoController::draw()
{
- HDC windowDC = GetDC(m_hudWindow);
- HDC bitmapDC = CreateCompatibleDC(windowDC);
- ::ReleaseDC(m_hudWindow, windowDC);
- HGDIOBJ oldBitmap = SelectObject(bitmapDC, m_bitmap.get());
+ OwnPtr<HDC> bitmapDC = adoptPtr(CreateCompatibleDC(HWndDC(m_hudWindow)));
+ HGDIOBJ oldBitmap = SelectObject(bitmapDC.get(), m_bitmap.get());
- GraphicsContext context(bitmapDC, true);
+ GraphicsContext context(bitmapDC.get(), true);
context.save();
SIZE size = { windowWidth, windowHeight };
POINT sourcePoint = {0, 0};
POINT destPoint = { m_hudPosition.x(), m_hudPosition.y() };
- BOOL result = UpdateLayeredWindow(m_hudWindow, 0, &destPoint, &size, bitmapDC, &sourcePoint, 0, &blendFunction, ULW_ALPHA);
+ BOOL result = UpdateLayeredWindow(m_hudWindow, 0, &destPoint, &size, bitmapDC.get(), &sourcePoint, 0, &blendFunction, ULW_ALPHA);
context.restore();
- ::SelectObject(bitmapDC, oldBitmap);
- ::DeleteDC(bitmapDC);
+ ::SelectObject(bitmapDC.get(), oldBitmap);
}
LRESULT FullscreenVideoController::hudWndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam)
#include <WebCore/BitmapInfo.h>
#include <WebCore/Color.h>
#include <WebCore/GraphicsContext.h>
+#include <WebCore/HWndDC.h>
#include <WebCore/InspectorController.h>
#include <WebCore/Page.h>
#include <WebCore/WindowMessageBroadcaster.h>
-#include <wtf/OwnPtr.h>
#include <wtf/HashSet.h>
+#include <wtf/OwnPtr.h>
using namespace WebCore;
{
ASSERT(m_overlay);
- HDC hdc = ::CreateCompatibleDC(::GetDC(m_overlay));
+ HDC hdc = ::CreateCompatibleDC(HWndDC(m_overlay));
if (!hdc)
return;
dstPoint.x = webViewRect.left;
dstPoint.y = webViewRect.top;
- ::UpdateLayeredWindow(m_overlay, ::GetDC(0), &dstPoint, &size, hdc, &srcPoint, 0, &bf, ULW_ALPHA);
-
+ ::UpdateLayeredWindow(m_overlay, HWndDC(0), &dstPoint, &size, hdc, &srcPoint, 0, &bf, ULW_ALPHA);
::DeleteDC(hdc);
}
#include <WebCore/GraphicsContext.h>
#include <WebCore/HTMLMediaElement.h>
#include <WebCore/HTMLNames.h>
+#include <WebCore/HWndDC.h>
#include <WebCore/HistoryItem.h>
#include <WebCore/HitTestRequest.h>
#include <WebCore/HitTestResult.h>
HRGN updateRegion = ::CreateRectRgn(0, 0, 0, 0);
// Collect our device context info and select the bitmap to scroll.
- HDC windowDC = ::GetDC(m_viewWindow);
+ HWndDC windowDC(m_viewWindow);
HDC bitmapDC = ::CreateCompatibleDC(windowDC);
HGDIOBJ oldBitmap = ::SelectObject(bitmapDC, m_backingStoreBitmap->handle());
// Clean up.
::SelectObject(bitmapDC, oldBitmap);
::DeleteDC(bitmapDC);
- ::ReleaseDC(m_viewWindow, windowDC);
}
void WebView::sizeChanged(const IntSize& newSize)
LOCAL_GDI_COUNTER(0, __FUNCTION__);
- HDC windowDC = 0;
HDC bitmapDC = dc;
HGDIOBJ oldBitmap = 0;
if (!dc) {
- windowDC = ::GetDC(m_viewWindow);
+ HWndDC windowDC(m_viewWindow);
bitmapDC = ::CreateCompatibleDC(windowDC);
oldBitmap = ::SelectObject(bitmapDC, m_backingStoreBitmap->handle());
}
if (!dc) {
::SelectObject(bitmapDC, oldBitmap);
::DeleteDC(bitmapDC);
- ::ReleaseDC(m_viewWindow, windowDC);
}
GdiFlush();
if (!m_backingStoreBitmap)
return;
- HDC hdcScreen = ::GetDC(m_viewWindow);
+ HWndDC hdcScreen(m_viewWindow);
OwnPtr<HDC> hdcMem = adoptPtr(::CreateCompatibleDC(hdcScreen));
HBITMAP hbmOld = static_cast<HBITMAP>(::SelectObject(hdcMem.get(), m_backingStoreBitmap->handle()));
::UpdateLayeredWindow(m_viewWindow, hdcScreen, 0, &windowSize, hdcMem.get(), &layerPos, 0, &blendFunction, ULW_ALPHA);
::SelectObject(hdcMem.get(), hbmOld);
- ::ReleaseDC(0, hdcScreen);
}
void WebView::paint(HDC dc, LPARAM options)
RECT rect = dirtyRect;
#if FLASH_BACKING_STORE_REDRAW
- HDC dc = ::GetDC(m_viewWindow);
- OwnPtr<HBRUSH> yellowBrush(CreateSolidBrush(RGB(255, 255, 0)));
- FillRect(dc, &rect, yellowBrush.get());
- GdiFlush();
- Sleep(50);
- paintIntoWindow(bitmapDC, dc, dirtyRect);
- ::ReleaseDC(m_viewWindow, dc);
+ {
+ HWndDC dc(m_viewWindow);
+ OwnPtr<HBRUSH> yellowBrush(CreateSolidBrush(RGB(255, 255, 0)));
+ FillRect(dc, &rect, yellowBrush.get());
+ GdiFlush();
+ Sleep(50);
+ paintIntoWindow(bitmapDC, dc, dirtyRect);
+ }
#endif
GraphicsContext gc(bitmapDC, m_transparent);
2012-01-23 David Levin <levin@chromium.org>
+ [windows] Convert usages of GetDC to HWndDC Part 2.
+ https://bugs.webkit.org/show_bug.cgi?id=76750
+
+ Reviewed by Adam Roben.
+
+ * Shared/win/ShareableBitmapWin.cpp:
+ (WebKit::ShareableBitmap::windowsContext): Fix incorrect usage of OwnPtr<HDC> which
+ would do a DeleteDC instead of a ReleaseDC.
+
+2012-01-23 David Levin <levin@chromium.org>
+
[windows] Convert usages of GetDC to HWndDC Part 1.
https://bugs.webkit.org/show_bug.cgi?id=76744
#include <WebCore/BitmapInfo.h>
#include <WebCore/GraphicsContext.h>
+#include <WebCore/HWndDC.h>
using namespace WebCore;
if (m_windowsContext)
return m_windowsContext.get();
- OwnPtr<HDC> screenDC = adoptPtr(::GetDC(0));
+ HWndDC screenDC(0);
BitmapInfo bmInfo = BitmapInfo::createBottomUp(m_size);
- m_windowsContext = adoptPtr(::CreateCompatibleDC(screenDC.get()));
+ m_windowsContext = adoptPtr(::CreateCompatibleDC(screenDC));
m_windowsBitmap = adoptPtr(CreateDIBSection(m_windowsContext.get(), &bmInfo, DIB_RGB_COLORS, 0, m_sharedMemory->handle(), 0));
::SelectObject(m_windowsContext.get(), m_windowsBitmap.get());