2008-08-09 13:43:08 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-08-09 13:43:08 +00:00
|
|
|
|
|
|
|
#include "gfxQtNativeRenderer.h"
|
|
|
|
#include "gfxContext.h"
|
2010-04-20 18:49:34 +00:00
|
|
|
#include "gfxXlibSurface.h"
|
2008-08-09 13:43:08 +00:00
|
|
|
|
|
|
|
nsresult
|
2010-07-02 04:04:09 +00:00
|
|
|
gfxQtNativeRenderer::Draw(gfxContext* ctx, nsIntSize size,
|
|
|
|
PRUint32 flags, Screen* screen, Visual* visual,
|
|
|
|
DrawOutput* output)
|
2008-08-09 13:43:08 +00:00
|
|
|
{
|
2010-07-02 04:04:09 +00:00
|
|
|
Display *dpy = DisplayOfScreen(screen);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isOpaque = (flags & DRAW_IS_OPAQUE) ? true : false;
|
2010-07-02 04:04:09 +00:00
|
|
|
int screenNumber = screen - ScreenOfDisplay(dpy, 0);
|
2010-04-20 18:49:34 +00:00
|
|
|
|
|
|
|
if (!isOpaque) {
|
2010-07-02 03:55:24 +00:00
|
|
|
int depth = 32;
|
2010-04-20 18:49:34 +00:00
|
|
|
XVisualInfo vinfo;
|
2010-07-02 04:04:09 +00:00
|
|
|
int foundVisual = XMatchVisualInfo(dpy, screenNumber,
|
2010-04-20 18:49:34 +00:00
|
|
|
depth, TrueColor,
|
|
|
|
&vinfo);
|
|
|
|
if (!foundVisual)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2010-07-02 04:04:09 +00:00
|
|
|
visual = vinfo.visual;
|
2008-08-09 13:43:08 +00:00
|
|
|
}
|
|
|
|
|
2010-04-20 18:49:34 +00:00
|
|
|
nsRefPtr<gfxXlibSurface> xsurf =
|
2010-07-02 04:04:09 +00:00
|
|
|
gfxXlibSurface::Create(screen, visual,
|
|
|
|
gfxIntSize(size.width, size.height));
|
2008-08-09 13:43:08 +00:00
|
|
|
|
2010-04-20 18:49:34 +00:00
|
|
|
if (!isOpaque) {
|
|
|
|
nsRefPtr<gfxContext> tempCtx = new gfxContext(xsurf);
|
|
|
|
tempCtx->SetOperator(gfxContext::OPERATOR_CLEAR);
|
|
|
|
tempCtx->Paint();
|
2008-08-09 13:43:08 +00:00
|
|
|
}
|
|
|
|
|
2010-07-02 04:04:09 +00:00
|
|
|
nsresult rv = DrawWithXlib(xsurf.get(), nsIntPoint(0, 0), NULL, 0);
|
2008-08-09 13:43:08 +00:00
|
|
|
|
2010-04-20 18:49:34 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2008-08-09 13:43:08 +00:00
|
|
|
|
2010-04-20 18:49:34 +00:00
|
|
|
ctx->SetSource(xsurf);
|
|
|
|
ctx->Paint();
|
2008-08-09 13:43:08 +00:00
|
|
|
|
2010-04-20 18:49:34 +00:00
|
|
|
return rv;
|
2008-08-09 13:43:08 +00:00
|
|
|
}
|