1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxQtNativeRenderer.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "gfxQtNativeRenderer.h" 1.10 +#include "gfxContext.h" 1.11 +#include "gfxXlibSurface.h" 1.12 + 1.13 +nsresult 1.14 +gfxQtNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, 1.15 + uint32_t flags, Screen* screen, Visual* visual) 1.16 +{ 1.17 + Display *dpy = DisplayOfScreen(screen); 1.18 + bool isOpaque = (flags & DRAW_IS_OPAQUE) ? true : false; 1.19 + int screenNumber = screen - ScreenOfDisplay(dpy, 0); 1.20 + 1.21 + if (!isOpaque) { 1.22 + int depth = 32; 1.23 + XVisualInfo vinfo; 1.24 + int foundVisual = XMatchVisualInfo(dpy, screenNumber, 1.25 + depth, TrueColor, 1.26 + &vinfo); 1.27 + if (!foundVisual) 1.28 + return NS_ERROR_FAILURE; 1.29 + 1.30 + visual = vinfo.visual; 1.31 + } 1.32 + 1.33 + nsRefPtr<gfxXlibSurface> xsurf = 1.34 + gfxXlibSurface::Create(screen, visual, 1.35 + gfxIntSize(size.width, size.height)); 1.36 + 1.37 + if (!isOpaque) { 1.38 + nsRefPtr<gfxContext> tempCtx = new gfxContext(xsurf); 1.39 + tempCtx->SetOperator(gfxContext::OPERATOR_CLEAR); 1.40 + tempCtx->Paint(); 1.41 + } 1.42 + 1.43 + nsresult rv = DrawWithXlib(xsurf->CairoSurface(), nsIntPoint(0, 0), nullptr, 0); 1.44 + 1.45 + if (NS_FAILED(rv)) 1.46 + return rv; 1.47 + 1.48 + ctx->SetSource(xsurf); 1.49 + ctx->Paint(); 1.50 + 1.51 + return rv; 1.52 +}