diff options
author | nyamatongwe <unknown> | 2009-05-19 13:40:35 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2009-05-19 13:40:35 +0000 |
commit | 5570f6b4d62cb52fb4b5a3c3c6d71a8f628896d9 (patch) | |
tree | 2e85207aa21f75e9c5a2b70ff50039476b10a680 | |
parent | f773e851298361dc03be5f9ba8bb88803cf72e55 (diff) | |
download | scintilla-mirror-5570f6b4d62cb52fb4b5a3c3c6d71a8f628896d9.tar.gz |
Fix for bug #2793806 warnings for typpe punned pointer from g++.
Still type punning but g++ lets this through.
-rw-r--r-- | gtk/PlatGTK.cxx | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 2109c4d62..588d067a2 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -1057,6 +1057,19 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int , ColourAllocated , int , Co } } #else + +static guint32 u32FromRGBA(guint8 r, guint8 g, guint8 b, guint8 a) { + union { + guint8 pixVal[4]; + guint32 val; + } converter; + converter.pixVal[0] = r; + converter.pixVal[1] = g; + converter.pixVal[2] = b; + converter.pixVal[3] = a; + return converter.val; +} + void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int flags) { if (gc && drawable && rc.Width() > 0) { @@ -1067,18 +1080,11 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated // Make a 32 bit deep pixbuf with alpha GdkPixbuf *pixalpha = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); - guint8 pixVal[4] = {0}; - guint32 valEmpty = *(reinterpret_cast<guint32 *>(pixVal)); - pixVal[0] = GetRValue(fill.AsLong()); - pixVal[1] = GetGValue(fill.AsLong()); - pixVal[2] = GetBValue(fill.AsLong()); - pixVal[3] = alphaFill; - guint32 valFill = *(reinterpret_cast<guint32 *>(pixVal)); - pixVal[0] = GetRValue(outline.AsLong()); - pixVal[1] = GetGValue(outline.AsLong()); - pixVal[2] = GetBValue(outline.AsLong()); - pixVal[3] = alphaOutline; - guint32 valOutline = *(reinterpret_cast<guint32 *>(pixVal)); + guint32 valEmpty = u32FromRGBA(0,0,0,0); + guint32 valFill = u32FromRGBA(GetRValue(fill.AsLong()), + GetGValue(fill.AsLong()), GetBValue(fill.AsLong()), alphaFill); + guint32 valOutline = u32FromRGBA(GetRValue(outline.AsLong()), + GetGValue(outline.AsLong()), GetBValue(outline.AsLong()), alphaOutline); guint32 *pixels = reinterpret_cast<guint32 *>(gdk_pixbuf_get_pixels(pixalpha)); int stride = gdk_pixbuf_get_rowstride(pixalpha) / 4; for (int yr=0; yr<height; yr++) { @@ -1106,6 +1112,7 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated g_object_unref(pixalpha); } } + #endif void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) { |