2008-08-09 17:43:08 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 15:12:37 +04: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 17:43:08 +04:00
|
|
|
|
|
|
|
#include "gfxQtNativeRenderer.h"
|
|
|
|
#include "gfxContext.h"
|
2010-04-20 22:49:34 +04:00
|
|
|
#include "gfxXlibSurface.h"
|
2008-08-09 17:43:08 +04:00
|
|
|
|
|
|
|
nsresult
|
2010-07-02 08:04:09 +04:00
|
|
|
gfxQtNativeRenderer::Draw(gfxContext* ctx, nsIntSize size,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t flags, Screen* screen, Visual* visual,
|
2010-07-02 08:04:09 +04:00
|
|
|
DrawOutput* output)
|
2008-08-09 17:43:08 +04:00
|
|
|
{
|
2010-07-02 08:04:09 +04:00
|
|
|
Display *dpy = DisplayOfScreen(screen);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isOpaque = (flags & DRAW_IS_OPAQUE) ? true : false;
|
2010-07-02 08:04:09 +04:00
|
|
|
int screenNumber = screen - ScreenOfDisplay(dpy, 0);
|
2010-04-20 22:49:34 +04:00
|
|
|
|
|
|
|
if (!isOpaque) {
|
2010-07-02 07:55:24 +04:00
|
|
|
int depth = 32;
|
2010-04-20 22:49:34 +04:00
|
|
|
XVisualInfo vinfo;
|
2010-07-02 08:04:09 +04:00
|
|
|
int foundVisual = XMatchVisualInfo(dpy, screenNumber,
|
2010-04-20 22:49:34 +04:00
|
|
|
depth, TrueColor,
|
|
|
|
&vinfo);
|
|
|
|
if (!foundVisual)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2010-07-02 08:04:09 +04:00
|
|
|
visual = vinfo.visual;
|
2008-08-09 17:43:08 +04:00
|
|
|
}
|
|
|
|
|
2010-04-20 22:49:34 +04:00
|
|
|
nsRefPtr<gfxXlibSurface> xsurf =
|
2010-07-02 08:04:09 +04:00
|
|
|
gfxXlibSurface::Create(screen, visual,
|
|
|
|
gfxIntSize(size.width, size.height));
|
2008-08-09 17:43:08 +04:00
|
|
|
|
2010-04-20 22:49:34 +04:00
|
|
|
if (!isOpaque) {
|
|
|
|
nsRefPtr<gfxContext> tempCtx = new gfxContext(xsurf);
|
|
|
|
tempCtx->SetOperator(gfxContext::OPERATOR_CLEAR);
|
|
|
|
tempCtx->Paint();
|
2008-08-09 17:43:08 +04:00
|
|
|
}
|
|
|
|
|
2010-07-02 08:04:09 +04:00
|
|
|
nsresult rv = DrawWithXlib(xsurf.get(), nsIntPoint(0, 0), NULL, 0);
|
2008-08-09 17:43:08 +04:00
|
|
|
|
2010-04-20 22:49:34 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2008-08-09 17:43:08 +04:00
|
|
|
|
2010-04-20 22:49:34 +04:00
|
|
|
ctx->SetSource(xsurf);
|
|
|
|
ctx->Paint();
|
2008-08-09 17:43:08 +04:00
|
|
|
|
2010-04-20 22:49:34 +04:00
|
|
|
return rv;
|
2008-08-09 17:43:08 +04:00
|
|
|
}
|