diff options
Diffstat (limited to 'gtk/PlatGTK.cxx')
-rw-r--r-- | gtk/PlatGTK.cxx | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index d4572a912..0b8eeaf92 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -549,20 +549,9 @@ bool SurfaceImpl::Initialised() { void SurfaceImpl::Init(WindowID wid) { Release(); PLATFORM_ASSERT(wid); -#if GTK_CHECK_VERSION(3,0,0) - GdkWindow *drawable_ = gtk_widget_get_window(PWidget(wid)); -#else - GdkDrawable *drawable_ = GDK_DRAWABLE(PWidget(wid)->window); -#endif - if (drawable_) { - context = gdk_cairo_create(drawable_); - PLATFORM_ASSERT(context); - } else { - // Shouldn't happen with valid window but may when calls made before - // window completely allocated and mapped. - psurf = cairo_image_surface_create(CAIRO_FORMAT_RGB24, 1, 1); - context = cairo_create(psurf); - } + // if we are only created from a window ID, we can't perform drawing + psurf = 0; + context = 0; createdGC = true; pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); @@ -681,6 +670,7 @@ void SurfaceImpl::LineTo(int x_, int y_) { void SurfaceImpl::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) { + PLATFORM_ASSERT(context); PenColour(back); cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5); for (int i = 1; i < npts; i++) { @@ -718,6 +708,7 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfacePattern); bool canDraw = surfi.psurf; if (canDraw) { + PLATFORM_ASSERT(context); // Tile pattern over rectangle // Currently assumes 8x8 pattern int widthPat = 8; @@ -803,6 +794,7 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fi } void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { + PLATFORM_ASSERT(context); if (rc.Width() > width) rc.left += (rc.Width() - width) / 2; rc.right = rc.left + width; @@ -837,6 +829,7 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi } void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { + PLATFORM_ASSERT(context); PenColour(back); cairo_arc(context, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2, Platform::Minimum(rc.Width(), rc.Height()) / 2, 0, 2*kPi); @@ -849,6 +842,7 @@ void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) { SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfaceSource); bool canDraw = surfi.psurf; if (canDraw) { + PLATFORM_ASSERT(context); cairo_set_source_surface(context, surfi.psurf, rc.left - from.x, rc.top - from.y); cairo_rectangle(context, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top); @@ -1201,6 +1195,7 @@ XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) { } void SurfaceImpl::SetClip(PRectangle rc) { + PLATFORM_ASSERT(context); cairo_rectangle(context, rc.left, rc.top, rc.right, rc.bottom); cairo_clip(context); } |