Commit 98ed6370 authored by Olivier Teulière's avatar Olivier Teulière

* skins2/win32/win32_graphics.cpp: fixed a bunch of memory leaks and

   fixed a bug in drawRect()
parent 119858b2
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* win32_graphics.cpp * win32_graphics.cpp
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: win32_graphics.cpp,v 1.4 2004/01/28 15:51:16 gbazin Exp $ * $Id$
* *
* Authors: Cyril Deguet <asmax@via.ecp.fr> * Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr> * Olivier Teulire <ipkiss@via.ecp.fr>
...@@ -241,6 +241,7 @@ void Win32Graphics::fillRect( int left, int top, int width, int height, ...@@ -241,6 +241,7 @@ void Win32Graphics::fillRect( int left, int top, int width, int height,
HRGN newMask = CreateRectRgn( left, top, left + width, top + height ); HRGN newMask = CreateRectRgn( left, top, left + width, top + height );
CombineRgn( m_mask, m_mask, newMask, RGN_OR ); CombineRgn( m_mask, m_mask, newMask, RGN_OR );
SelectClipRgn( m_hDC, m_mask ); SelectClipRgn( m_hDC, m_mask );
DeleteObject( newMask );
// Create a brush with the color // Create a brush with the color
int red = (color & 0xff0000) >> 16; int red = (color & 0xff0000) >> 16;
...@@ -255,6 +256,7 @@ void Win32Graphics::fillRect( int left, int top, int width, int height, ...@@ -255,6 +256,7 @@ void Win32Graphics::fillRect( int left, int top, int width, int height,
r.right = left + width; r.right = left + width;
r.bottom = top + height; r.bottom = top + height;
FillRect( m_hDC, &r, hBrush ); FillRect( m_hDC, &r, hBrush );
DeleteObject( hBrush );
} }
...@@ -262,14 +264,21 @@ void Win32Graphics::drawRect( int left, int top, int width, int height, ...@@ -262,14 +264,21 @@ void Win32Graphics::drawRect( int left, int top, int width, int height,
uint32_t color ) uint32_t color )
{ {
// Update the mask with the rectangle // Update the mask with the rectangle
HRGN l1 = CreateRectRgn( left, top, left + width, top ); HRGN l1 = CreateRectRgn( left, top, left + width, top + 1 );
HRGN l2 = CreateRectRgn( left + width, top, left + width, top + height ); HRGN l2 = CreateRectRgn( left + width - 1, top,
HRGN l3 = CreateRectRgn( left + width, top + height, left, top + height ); left + width, top + height );
HRGN l4 = CreateRectRgn( left, top + height, left, top ); HRGN l3 = CreateRectRgn( left, top + height - 1,
left + width, top + height );
HRGN l4 = CreateRectRgn( left, top, left + 1, top + height );
CombineRgn( m_mask, m_mask, l1, RGN_OR ); CombineRgn( m_mask, m_mask, l1, RGN_OR );
CombineRgn( m_mask, m_mask, l2, RGN_OR ); CombineRgn( m_mask, m_mask, l2, RGN_OR );
CombineRgn( m_mask, m_mask, l3, RGN_OR ); CombineRgn( m_mask, m_mask, l3, RGN_OR );
CombineRgn( m_mask, m_mask, l4, RGN_OR ); CombineRgn( m_mask, m_mask, l4, RGN_OR );
DeleteObject( l1 );
DeleteObject( l2 );
DeleteObject( l3 );
DeleteObject( l4 );
SelectClipRgn( m_hDC, m_mask ); SelectClipRgn( m_hDC, m_mask );
// Create a pen with the color // Create a pen with the color
...@@ -329,8 +338,7 @@ bool Win32Graphics::hit( int x, int y ) const ...@@ -329,8 +338,7 @@ bool Win32Graphics::hit( int x, int y ) const
void Win32Graphics::addSegmentInRegion( HRGN &rMask, int start, void Win32Graphics::addSegmentInRegion( HRGN &rMask, int start,
int end, int line ) int end, int line )
{ {
HRGN buffer; HRGN buffer = CreateRectRgn( start, line, end, line + 1 );
buffer = CreateRectRgn( start, line, end, line + 1 );
CombineRgn( rMask, buffer, rMask, RGN_OR ); CombineRgn( rMask, buffer, rMask, RGN_OR );
DeleteObject( buffer ); DeleteObject( buffer );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment