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"
|
2014-06-24 13:02:10 +04:00
|
|
|
#include "gfxUtils.h"
|
2010-04-20 22:49:34 +04:00
|
|
|
#include "gfxXlibSurface.h"
|
2008-08-09 17:43:08 +04:00
|
|
|
|
|
|
|
nsresult
|
2015-05-28 16:00:17 +03:00
|
|
|
gfxQtNativeRenderer::Draw(gfxContext* ctx, mozilla::gfx::IntSize size,
|
2013-10-26 01:25:40 +04:00
|
|
|
uint32_t flags, Screen* screen, Visual* visual)
|
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,
|
2015-06-01 11:26:19 +03:00
|
|
|
mozilla::gfx::IntSize(size.width, size.height));
|
2008-08-09 17:43:08 +04:00
|
|
|
|
2010-04-20 22:49:34 +04:00
|
|
|
if (!isOpaque) {
|
2014-06-24 13:02:10 +04:00
|
|
|
gfxUtils::ClearThebesSurface(xsurf);
|
2008-08-09 17:43:08 +04:00
|
|
|
}
|
|
|
|
|
2014-02-21 06:09:02 +04:00
|
|
|
nsresult rv = DrawWithXlib(xsurf->CairoSurface(), nsIntPoint(0, 0), nullptr, 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
|
|
|
}
|