michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "gfxQtNativeRenderer.h" michael@0: #include "gfxContext.h" michael@0: #include "gfxXlibSurface.h" michael@0: michael@0: nsresult michael@0: gfxQtNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, michael@0: uint32_t flags, Screen* screen, Visual* visual) michael@0: { michael@0: Display *dpy = DisplayOfScreen(screen); michael@0: bool isOpaque = (flags & DRAW_IS_OPAQUE) ? true : false; michael@0: int screenNumber = screen - ScreenOfDisplay(dpy, 0); michael@0: michael@0: if (!isOpaque) { michael@0: int depth = 32; michael@0: XVisualInfo vinfo; michael@0: int foundVisual = XMatchVisualInfo(dpy, screenNumber, michael@0: depth, TrueColor, michael@0: &vinfo); michael@0: if (!foundVisual) michael@0: return NS_ERROR_FAILURE; michael@0: michael@0: visual = vinfo.visual; michael@0: } michael@0: michael@0: nsRefPtr xsurf = michael@0: gfxXlibSurface::Create(screen, visual, michael@0: gfxIntSize(size.width, size.height)); michael@0: michael@0: if (!isOpaque) { michael@0: nsRefPtr tempCtx = new gfxContext(xsurf); michael@0: tempCtx->SetOperator(gfxContext::OPERATOR_CLEAR); michael@0: tempCtx->Paint(); michael@0: } michael@0: michael@0: nsresult rv = DrawWithXlib(xsurf->CairoSurface(), nsIntPoint(0, 0), nullptr, 0); michael@0: michael@0: if (NS_FAILED(rv)) michael@0: return rv; michael@0: michael@0: ctx->SetSource(xsurf); michael@0: ctx->Paint(); michael@0: michael@0: return rv; michael@0: }