• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2015 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // X11Pixmap.cpp: Implementation of OSPixmap for X11
8 
9 #include "util/x11/X11Pixmap.h"
10 
X11Pixmap()11 X11Pixmap::X11Pixmap() : mPixmap(0), mDisplay(nullptr) {}
12 
~X11Pixmap()13 X11Pixmap::~X11Pixmap()
14 {
15     if (mPixmap)
16     {
17         XFreePixmap(mDisplay, mPixmap);
18     }
19 }
20 
initialize(EGLNativeDisplayType display,size_t width,size_t height,int depth)21 bool X11Pixmap::initialize(EGLNativeDisplayType display, size_t width, size_t height, int depth)
22 {
23     mDisplay = display;
24 
25     int screen  = DefaultScreen(mDisplay);
26     Window root = RootWindow(mDisplay, screen);
27 
28     mPixmap = XCreatePixmap(mDisplay, root, static_cast<unsigned int>(width),
29                             static_cast<unsigned int>(height), depth);
30 
31     return mPixmap != 0;
32 }
33 
getNativePixmap() const34 EGLNativePixmapType X11Pixmap::getNativePixmap() const
35 {
36     return mPixmap;
37 }
38 
CreateOSPixmap()39 OSPixmap *CreateOSPixmap()
40 {
41     return new X11Pixmap();
42 }
43