Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
f6ba5119
Commit
f6ba5119
authored
Apr 04, 2013
by
Erwan Tulou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
skins2(win32): improve boundaries check
parent
bd1e5270
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
13 deletions
+51
-13
modules/gui/skins2/win32/win32_graphics.cpp
modules/gui/skins2/win32/win32_graphics.cpp
+46
-13
modules/gui/skins2/win32/win32_graphics.hpp
modules/gui/skins2/win32/win32_graphics.hpp
+5
-0
No files found.
modules/gui/skins2/win32/win32_graphics.cpp
View file @
f6ba5119
...
@@ -82,19 +82,20 @@ void Win32Graphics::drawBitmap( const GenericBitmap &rBitmap,
...
@@ -82,19 +82,20 @@ void Win32Graphics::drawBitmap( const GenericBitmap &rBitmap,
int
width
,
int
height
,
bool
blend
)
int
width
,
int
height
,
bool
blend
)
{
{
(
void
)
blend
;
(
void
)
blend
;
// Get the bitmap size if necessary
if
(
width
==
-
1
)
// check and adapt to source if needed
{
if
(
!
checkBoundaries
(
0
,
0
,
rBitmap
.
getWidth
(),
rBitmap
.
getHeight
(),
width
=
rBitmap
.
getWidth
();
xSrc
,
ySrc
,
width
,
height
)
)
}
if
(
height
==
-
1
)
{
{
height
=
rBitmap
.
getHeight
();
msg_Err
(
getIntf
(),
"empty source! pls, debug your skin"
);
return
;
}
}
if
(
xDest
+
width
>
m_width
||
yDest
+
height
>
m_height
)
// check destination
if
(
!
checkBoundaries
(
0
,
0
,
m_width
,
m_height
,
xDest
,
yDest
,
width
,
height
)
)
{
{
msg_Err
(
getIntf
(),
"
Bitmap too large !
"
);
msg_Err
(
getIntf
(),
"
out of reach destination! pls, debug your skin
"
);
return
;
return
;
}
}
...
@@ -212,13 +213,20 @@ void Win32Graphics::drawGraphics( const OSGraphics &rGraphics, int xSrc,
...
@@ -212,13 +213,20 @@ void Win32Graphics::drawGraphics( const OSGraphics &rGraphics, int xSrc,
int
ySrc
,
int
xDest
,
int
yDest
,
int
width
,
int
ySrc
,
int
xDest
,
int
yDest
,
int
width
,
int
height
)
int
height
)
{
{
if
(
width
==
-
1
)
// check and adapt to source if needed
if
(
!
checkBoundaries
(
0
,
0
,
rGraphics
.
getWidth
(),
rGraphics
.
getHeight
(),
xSrc
,
ySrc
,
width
,
height
)
)
{
{
width
=
rGraphics
.
getWidth
();
msg_Err
(
getIntf
(),
"nothing to draw from graphics source"
);
return
;
}
}
if
(
height
==
-
1
)
// check destination
if
(
!
checkBoundaries
(
0
,
0
,
m_width
,
m_height
,
xDest
,
yDest
,
width
,
height
)
)
{
{
height
=
rGraphics
.
getHeight
();
msg_Err
(
getIntf
(),
"out of reach destination! pls, debug your skin"
);
return
;
}
}
// Create the mask for transparency
// Create the mask for transparency
...
@@ -346,4 +354,29 @@ void Win32Graphics::addSegmentInRegion( HRGN &rMask, int start,
...
@@ -346,4 +354,29 @@ void Win32Graphics::addSegmentInRegion( HRGN &rMask, int start,
DeleteObject
(
buffer
);
DeleteObject
(
buffer
);
}
}
bool
Win32Graphics
::
checkBoundaries
(
int
x_src
,
int
y_src
,
int
w_src
,
int
h_src
,
int
&
x_target
,
int
&
y_target
,
int
&
w_target
,
int
&
h_target
)
{
// set valid width and height
w_target
=
(
w_target
>
0
)
?
w_target
:
w_src
;
h_target
=
(
h_target
>
0
)
?
h_target
:
h_src
;
// clip source if needed
rect
srcRegion
(
x_src
,
y_src
,
w_src
,
h_src
);
rect
targetRegion
(
x_target
,
y_target
,
w_target
,
h_target
);
rect
inter
;
if
(
rect
::
intersect
(
srcRegion
,
targetRegion
,
&
inter
)
)
{
x_target
=
inter
.
x
;
y_target
=
inter
.
y
;
w_target
=
inter
.
width
;
h_target
=
inter
.
height
;
return
true
;
}
return
false
;
}
#endif
#endif
modules/gui/skins2/win32/win32_graphics.hpp
View file @
f6ba5119
...
@@ -95,6 +95,11 @@ private:
...
@@ -95,6 +95,11 @@ private:
/// Add a segment in a region
/// Add a segment in a region
void
addSegmentInRegion
(
HRGN
&
rMask
,
int
start
,
int
end
,
int
line
);
void
addSegmentInRegion
(
HRGN
&
rMask
,
int
start
,
int
end
,
int
line
);
/// check boundaries for graphics and bitmaps
bool
checkBoundaries
(
int
x_src
,
int
y_src
,
int
w_src
,
int
h_src
,
int
&
x_target
,
int
&
y_target
,
int
&
w_target
,
int
&
h_target
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment