1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* 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/.
*
* Some of this code is based on Skia source code, covered by the following
* license notice (see readlicense_oo for the full license):
*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
*/
#include <skia/x11/gdiimpl.hxx>
X11SkiaSalGraphicsImpl::X11SkiaSalGraphicsImpl(X11SalGraphics& rParent)
: SkiaSalGraphicsImpl(rParent, rParent.GetGeometryProvider())
, mParent(rParent)
, mCopyGc(None)
{
}
X11SkiaSalGraphicsImpl::~X11SkiaSalGraphicsImpl() {}
void X11SkiaSalGraphicsImpl::Init()
{
// The m_pFrame and m_pVDev pointers are updated late in X11
setProvider(mParent.GetGeometryProvider());
SkiaSalGraphicsImpl::Init();
}
GC X11SkiaSalGraphicsImpl::getGC()
{
if (mCopyGc == None)
{
XGCValues values;
values.graphics_exposures = False;
values.subwindow_mode = ClipByChildren;
mCopyGc = XCreateGC(mParent.GetXDisplay(), mParent.GetDrawable(),
GCGraphicsExposures | GCSubwindowMode, &values);
}
return mCopyGc;
}
void X11SkiaSalGraphicsImpl::freeResources()
{
if (mCopyGc != None)
{
XFreeGC(mParent.GetXDisplay(), mCopyGc);
mCopyGc = None;
}
}
void X11SkiaSalGraphicsImpl::performFlush()
{
Display* dpy = mParent.GetXDisplay();
Drawable drawable = mParent.GetDrawable();
GC gc = getGC();
SkPixmap pm;
if (!mSurface->peekPixels(&pm))
abort();
int bitsPerPixel = pm.info().bytesPerPixel() * 8;
XImage image;
memset(&image, 0, sizeof(image));
image.width = pm.width();
image.height = pm.height();
image.format = ZPixmap;
image.data = (char*)pm.addr();
image.byte_order = LSBFirst;
image.bitmap_unit = bitsPerPixel;
image.bitmap_bit_order = LSBFirst;
image.bitmap_pad = bitsPerPixel;
image.depth = 24;
image.bytes_per_line = pm.rowBytes() - pm.width() * pm.info().bytesPerPixel();
image.bits_per_pixel = bitsPerPixel;
if (!XInitImage(&image))
abort();
// TODO XPutImage() is somewhat inefficient, XShmPutImage() should be preferred.
XPutImage(dpy, drawable, gc, &image, 0, 0, 0, 0, pm.width(), pm.height());
}
void X11SkiaSalGraphicsImpl::FillPixmapFromScreen(X11Pixmap* pPixmap, int nX, int nY)
{
(void)pPixmap;
(void)nX;
(void)nY;
}
bool X11SkiaSalGraphicsImpl::RenderPixmapToScreen(X11Pixmap* pPixmap, X11Pixmap* pMask, int nX,
int nY)
{
(void)pPixmap;
(void)pMask;
(void)nX;
(void)nY;
return false;
}
bool X11SkiaSalGraphicsImpl::RenderAndCacheNativeControl(X11Pixmap* pPixmap, X11Pixmap* pMask,
int nX, int nY,
ControlCacheKey& aControlCacheKey)
{
(void)pPixmap;
(void)pMask;
(void)nX;
(void)nY;
(void)aControlCacheKey;
return false;
}
bool X11SkiaSalGraphicsImpl::TryRenderCachedNativeControl(ControlCacheKey& rControlCacheKey, int nX,
int nY)
{
(void)rControlCacheKey;
(void)nX;
(void)nY;
return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|