Get rid of unnecessary variables

We can pass NULL argument directly to CGBitmapContextCreate()
and using a temporary variable holding NULL is not necessary.
This commit is contained in:
Artur Wieczorek 2019-09-30 23:17:33 +02:00
parent 19d567a29b
commit 2bba863937

View File

@ -236,16 +236,15 @@ bool wxBitmapRefData::Create(CGImageRef image, double scale)
m_scaleFactor = scale;
size_t m_bytesPerRow = GetBestBytesPerRow(m_width * 4);
void* data = NULL;
CGImageAlphaInfo alpha = CGImageGetAlphaInfo(image);
if (alpha == kCGImageAlphaNone || alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)
{
m_hBitmap = CGBitmapContextCreate((char*)data, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst);
m_hBitmap = CGBitmapContextCreate(NULL, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst);
}
else
{
m_hBitmap = CGBitmapContextCreate((char*)data, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaPremultipliedFirst);
m_hBitmap = CGBitmapContextCreate(NULL, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaPremultipliedFirst);
}
CGRect rect = CGRectMake(0, 0, m_width, m_height);
CGContextDrawImage(m_hBitmap, rect, image);
@ -283,8 +282,7 @@ bool wxBitmapRefData::Create(int w, int h, int WXUNUSED(d), double logicalscale)
m_hBitmap = NULL;
size_t m_bytesPerRow = GetBestBytesPerRow(m_width * 4);
void* data = NULL;
m_hBitmap = CGBitmapContextCreate((char*)data, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst);
m_hBitmap = CGBitmapContextCreate(NULL, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst);
wxASSERT_MSG(m_hBitmap, wxT("Unable to create CGBitmapContext context"));
CGContextTranslateCTM(m_hBitmap, 0, m_height);
CGContextScaleCTM(m_hBitmap, 1 * GetScaleFactor(), -1 * GetScaleFactor());