Commit 688b0ad4 by Nicolas Capens Committed by Nicolas Capens

Treat all X8R8G8B8 and A8R8G8B8 formats as fast EGL configs.

The display format does not have to match the framebuffer image format, so we only care about the latter. Bug 18510357 Change-Id: Ie3382b7b006a5007e56ff9e2ae572e8a60f500d8 Reviewed-on: https://swiftshader-review.googlesource.com/1572Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 839d9e67
......@@ -17,7 +17,8 @@
#include <sys/ipc.h>
#include <sys/shm.h>
#include <string.h>
#include <string.h>
#include <assert.h>
namespace sw
{
......@@ -47,14 +48,17 @@ namespace sw
int screen = DefaultScreen(x_display);
x_gc = XDefaultGC(x_display, screen);
Visual *x_visual = XDefaultVisual(x_display, screen);
int depth = XDefaultDepth(x_display, screen);
int depth = XDefaultDepth(x_display, screen);
Status status = XMatchVisualInfo(x_display, screen, 32, TrueColor, &x_visual);
assert(status != 0 && x_visual.blue_mask == 0xFF); // Only X8R8G8B8 implemented
Visual *visual = x_visual.visual;
mit_shm = (XShmQueryExtension(x_display) == True);
if(mit_shm)
{
x_image = XShmCreateImage(x_display, x_visual, depth, ZPixmap, 0, &shminfo, width, height);
x_image = XShmCreateImage(x_display, visual, depth, ZPixmap, 0, &shminfo, width, height);
shminfo.shmid = shmget(IPC_PRIVATE, x_image->bytes_per_line * x_image->height, IPC_CREAT | SHM_R | SHM_W);
shminfo.shmaddr = x_image->data = buffer = (char*)shmat(shminfo.shmid, 0, 0);
......@@ -80,17 +84,17 @@ namespace sw
if(!mit_shm)
{
buffer = new char[width * height * 4];
x_image = XCreateImage(x_display, x_visual, depth, ZPixmap, 0, buffer, width, height, 32, width * 4);
x_image = XCreateImage(x_display, visual, depth, ZPixmap, 0, buffer, width, height, 32, width * 4);
}
}
FrameBufferX11::~FrameBufferX11()
{
if(!mit_shm)
{
x_image->data = 0;
XDestroyImage(x_image);
delete[] buffer;
buffer = 0;
}
......@@ -101,30 +105,30 @@ namespace sw
shmdt(shminfo.shmaddr);
shmctl(shminfo.shmid, IPC_RMID, 0);
}
if(ownX11)
{
XCloseDisplay(x_display);
}
}
void *FrameBufferX11::lock()
{
stride = x_image->bytes_per_line;
locked = buffer;
return locked;
}
void FrameBufferX11::unlock()
{
locked = 0;
}
void FrameBufferX11::blit(void *source, const Rect *sourceRect, const Rect *destRect, Format format)
{
copy(source, format);
if(!mit_shm)
{
XPutImage(x_display, x_window, x_gc, x_image, 0, 0, 0, 0, width, height);
......@@ -133,7 +137,7 @@ namespace sw
{
XShmPutImage(x_display, x_window, x_gc, x_image, 0, 0, 0, 0, width, height, False);
}
XSync(x_display, False);
}
}
......
......@@ -29,12 +29,12 @@ namespace sw
{
public:
FrameBufferX11(Display *display, Window window, int width, int height);
~FrameBufferX11();
virtual void flip(void *source, Format format) {blit(source, 0, 0, format);};
virtual void blit(void *source, const Rect *sourceRect, const Rect *destRect, Format format);
virtual void *lock();
virtual void unlock();
......@@ -43,11 +43,12 @@ namespace sw
Display *x_display;
Window x_window;
XImage *x_image;
GC x_gc;
GC x_gc;
XVisualInfo x_visual;
bool mit_shm;
XShmSegmentInfo shminfo;
char *buffer;
};
}
......
......@@ -156,12 +156,7 @@ EGLConfig Config::getHandle() const
bool Config::isSlowConfig() const
{
if(mDisplayMode.format == sw::FORMAT_X8R8G8B8 && mRenderTargetFormat == sw::FORMAT_A8R8G8B8)
{
return false;
}
return mDisplayMode.format != mRenderTargetFormat;
return mRenderTargetFormat != sw::FORMAT_X8R8G8B8 && mRenderTargetFormat != sw::FORMAT_A8R8G8B8;
}
SortConfig::SortConfig(const EGLint *attribList)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment