Bug 835381 - Update libnestegg to 38c83d9d4c0c5c84373aa285bd30094a12d6b6f6. r=kinetik
[gecko.git] / gfx / thebes / gfxQtNativeRenderer.cpp
blobc08f388be0e1a8abff31cc7330e4e0679f8b5696
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "gfxQtNativeRenderer.h"
7 #include "gfxContext.h"
8 #include "gfxXlibSurface.h"
10 nsresult
11 gfxQtNativeRenderer::Draw(gfxContext* ctx, nsIntSize size,
12 uint32_t flags, Screen* screen, Visual* visual,
13 DrawOutput* output)
15 Display *dpy = DisplayOfScreen(screen);
16 bool isOpaque = (flags & DRAW_IS_OPAQUE) ? true : false;
17 int screenNumber = screen - ScreenOfDisplay(dpy, 0);
19 if (!isOpaque) {
20 int depth = 32;
21 XVisualInfo vinfo;
22 int foundVisual = XMatchVisualInfo(dpy, screenNumber,
23 depth, TrueColor,
24 &vinfo);
25 if (!foundVisual)
26 return NS_ERROR_FAILURE;
28 visual = vinfo.visual;
31 nsRefPtr<gfxXlibSurface> xsurf =
32 gfxXlibSurface::Create(screen, visual,
33 gfxIntSize(size.width, size.height));
35 if (!isOpaque) {
36 nsRefPtr<gfxContext> tempCtx = new gfxContext(xsurf);
37 tempCtx->SetOperator(gfxContext::OPERATOR_CLEAR);
38 tempCtx->Paint();
41 nsresult rv = DrawWithXlib(xsurf.get(), nsIntPoint(0, 0), NULL, 0);
43 if (NS_FAILED(rv))
44 return rv;
46 ctx->SetSource(xsurf);
47 ctx->Paint();
49 return rv;