Do nothing in wxMemoryDC::SelectObject() if the bitmap is already selected.
It doesn't make sense to make a copy of the bitmap in order to select it into wxMemoryDC if it's already selected into it. See #11640. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65913 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -81,13 +81,17 @@ public:
|
|||||||
should use when you select a bitmap because you want to modify it, e.g.
|
should use when you select a bitmap because you want to modify it, e.g.
|
||||||
drawing on this DC.
|
drawing on this DC.
|
||||||
|
|
||||||
Using SelectObjectAsSource() when modifying the bitmap may incurr some
|
Using SelectObjectAsSource() when modifying the bitmap may incur some
|
||||||
problems related to wxBitmap being a reference counted object (see
|
problems related to wxBitmap being a reference counted object (see
|
||||||
@ref overview_refcount).
|
@ref overview_refcount).
|
||||||
|
|
||||||
Also, before using the updated bitmap data, make sure to select it out
|
Before using the updated bitmap data, make sure to select it out of
|
||||||
of context first (for example by selecting ::wxNullBitmap into the device
|
context first either by selecting ::wxNullBitmap into the device
|
||||||
context).
|
context or destroying the device context entirely.
|
||||||
|
|
||||||
|
If the bitmap is already selected in this device context, nothing is
|
||||||
|
done. If it is selected in another context, the function asserts and
|
||||||
|
drawing on the bitmap won't work correctly.
|
||||||
|
|
||||||
@see wxDC::DrawBitmap()
|
@see wxDC::DrawBitmap()
|
||||||
*/
|
*/
|
||||||
|
@@ -236,6 +236,12 @@ wxMemoryDC::wxMemoryDC(wxDC *dc)
|
|||||||
|
|
||||||
void wxMemoryDC::SelectObject(wxBitmap& bmp)
|
void wxMemoryDC::SelectObject(wxBitmap& bmp)
|
||||||
{
|
{
|
||||||
|
if ( bmp.IsSameAs(GetSelectedBitmap()) )
|
||||||
|
{
|
||||||
|
// Nothing to do, this bitmap is already selected.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// make sure that the given wxBitmap is not sharing its data with other
|
// make sure that the given wxBitmap is not sharing its data with other
|
||||||
// wxBitmap instances as its contents will be modified by any drawing
|
// wxBitmap instances as its contents will be modified by any drawing
|
||||||
// operation done on this DC
|
// operation done on this DC
|
||||||
|
Reference in New Issue
Block a user