X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fa378d369f620debdfe719cb4c1a1c577137fb26..beee38cb41aa2ce4fbe9052bf4f70e1be184b553:/src/generic/graphicc.cpp?ds=sidebyside diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index 1e6c1f6ac7..c8f2506cc4 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -301,7 +301,6 @@ private : cairo_font_weight_t weight); double m_size; - bool m_underlined; double m_red; double m_green; double m_blue; @@ -310,6 +309,7 @@ private : cairo_font_face_t *m_font; #elif defined(__WXGTK__) PangoFontDescription* m_font; + bool m_underlined; #endif // These members are used when the font is created from its face name and @@ -850,12 +850,12 @@ wxCairoFontData::wxCairoFontData( wxGraphicsRenderer* renderer, const wxFont &fo InitColour(col); m_size = font.GetPointSize(); - m_underlined = font.GetUnderlined(); #ifdef __WXMAC__ m_font = cairo_quartz_font_face_create_for_cgfont( font.OSXGetCGFont() ); #elif defined(__WXGTK__) m_font = pango_font_description_copy( font.GetNativeFontInfo()->description ); + m_underlined = font.GetUnderlined(); #else InitFontComponents ( @@ -886,7 +886,8 @@ wxCairoFontData::wxCairoFontData(wxGraphicsRenderer* renderer, m_font = NULL; #endif - m_underlined = (flags & wxFONTFLAG_UNDERLINED) != 0; + // There is no need to set m_underlined under wxGTK in this case, it can + // only be used if m_font != NULL. InitFontComponents ( @@ -1266,7 +1267,7 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm // Create a surface object and copy the bitmap pixel data to it. if the // image has alpha (or a mask represented as alpha) then we'll use a // different format and iterator than if it doesn't... - const cairo_format_t bufferFormat = bmp.GetDepth() == 32 + cairo_format_t bufferFormat = bmp.GetDepth() == 32 #ifdef __WXGTK__ || bmp.GetMask() #endif @@ -1275,23 +1276,22 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm int stride = InitBuffer(bmp.GetWidth(), bmp.GetHeight(), bufferFormat); - int bw = m_width; - int bh = m_height; wxBitmap bmpSource = bmp; // we need a non-const instance wxUint32* data = (wxUint32*)m_buffer; if ( bufferFormat == CAIRO_FORMAT_ARGB32 ) { // use the bitmap's alpha - wxAlphaPixelData pixData(bmpSource, wxPoint(0,0), wxSize(bw, bh)); + wxAlphaPixelData + pixData(bmpSource, wxPoint(0, 0), wxSize(m_width, m_height)); wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data.")); wxAlphaPixelData::Iterator p(pixData); - for (int y=0; y(GetGraphicsData()); - - return data ? data->ConvertToImage() : wxNullImage; -} - -#endif // wxUSE_IMAGE - //----------------------------------------------------------------------------- // wxCairoContext implementation //----------------------------------------------------------------------------- @@ -2290,6 +2276,7 @@ public : virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ); #if wxUSE_IMAGE virtual wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image); + virtual wxImage CreateImageFromBitmap(const wxGraphicsBitmap& bmp); #endif // wxUSE_IMAGE // create a graphics bitmap from a native bitmap @@ -2556,8 +2543,19 @@ wxGraphicsBitmap wxCairoRenderer::CreateBitmapFromImage(const wxImage& image) return bmp; } +wxImage wxCairoRenderer::CreateImageFromBitmap(const wxGraphicsBitmap& bmp) +{ + ENSURE_LOADED_OR_RETURN(wxNullImage); + + const wxCairoBitmapData* const + data = static_cast(bmp.GetGraphicsData()); + + return data ? data->ConvertToImage() : wxNullImage; +} + #endif // wxUSE_IMAGE + wxGraphicsBitmap wxCairoRenderer::CreateBitmapFromNativeBitmap( void* bitmap ) { ENSURE_LOADED_OR_RETURN(wxNullGraphicsBitmap);