Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1084)

Unified Diff: src/views/unix/SkOSWindow_Unix.cpp

Issue 1410593002: Use common display initialization logic for Unix (Closed) Base URL: https://skia.googlesource.com/skia.git@vbnvpr
Patch Set: minor tidy Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/views/unix/SkOSWindow_Unix.cpp
diff --git a/src/views/unix/SkOSWindow_Unix.cpp b/src/views/unix/SkOSWindow_Unix.cpp
index 4d4b628bfb61e50e79d3f27253e1e6feadaae392..0c8850674e0235d8a1cd25a1757b43b9f02e3a38 100644
--- a/src/views/unix/SkOSWindow_Unix.cpp
+++ b/src/views/unix/SkOSWindow_Unix.cpp
@@ -14,6 +14,8 @@
#include "SkWindow.h"
+#include "gl/glx/GrNativeDisplay_glx.h"
+
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkColor.h"
@@ -82,42 +84,46 @@ void SkOSWindow::initWindow(int requestedMSAASampleCount, AttachmentInfo* info)
SkDebugf("Could not open an X Display");
return;
}
- // Attempt to create a window that supports GL
- GLint att[] = {
- GLX_RGBA,
+
robertphillips 2015/10/16 14:54:40 static const int attrs[] ?
+ int att[] = {
GLX_DEPTH_SIZE, 24,
- GLX_DOUBLEBUFFER,
+ GLX_DOUBLEBUFFER, true,
robertphillips 2015/10/16 14:54:40 Don't we need these stencil settings in the other
GLX_STENCIL_SIZE, 8,
None
};
- SkASSERT(nullptr == fVi);
- if (requestedMSAASampleCount > 0) {
- static const GLint kAttCount = SK_ARRAY_COUNT(att);
- GLint msaaAtt[kAttCount + 4];
- memcpy(msaaAtt, att, sizeof(att));
- SkASSERT(None == msaaAtt[kAttCount - 1]);
- msaaAtt[kAttCount - 1] = GLX_SAMPLE_BUFFERS_ARB;
- msaaAtt[kAttCount + 0] = 1;
- msaaAtt[kAttCount + 1] = GLX_SAMPLES_ARB;
- msaaAtt[kAttCount + 2] = requestedMSAASampleCount;
- msaaAtt[kAttCount + 3] = None;
- fVi = glXChooseVisual(dsp, DefaultScreen(dsp), msaaAtt);
- fMSAASampleCount = requestedMSAASampleCount;
- }
- if (nullptr == fVi) {
- fVi = glXChooseVisual(dsp, DefaultScreen(dsp), att);
- fMSAASampleCount = 0;
- }
- if (fVi) {
+ GLXFBConfig bestFbConfig;
+ if (!GrNativeDisplay::Initialize(att, fUnixWindow.fDisplay, &bestFbConfig)) {
+ if (info) {
+ info->fSampleCount = 0;
+ info->fStencilBits = 0;
+ }
+ // Create a simple window instead. We will not be able to show GL
+ fUnixWindow.fWin = XCreateSimpleWindow(dsp,
+ DefaultRootWindow(dsp),
+ 0, 0, // x, y
+ WIDTH, HEIGHT,
+ 0, // border width
+ 0, // border value
+ 0); // background value
+ } else {
+ glXGetConfig(dsp, fVi, GLX_SAMPLES_ARB, &fMSAASampleCount);
+ if (fMSAASampleCount < requestedMSAASampleCount) {
+ SkDebugf("Requested samples exceeds the maximum allowed on this platform\n");
+ }
+
if (info) {
robertphillips 2015/10/16 14:54:40 Shouldn't this be requestedMSAASampleCount ?
- glXGetConfig(dsp, fVi, GLX_SAMPLES_ARB, &info->fSampleCount);
+ info->fSampleCount = fMSAASampleCount;
glXGetConfig(dsp, fVi, GLX_STENCIL_SIZE, &info->fStencilBits);
}
+
+ fVi = glXGetVisualFromFBConfig(fUnixWindow.fDisplay, bestFbConfig);
+ SkASSERT(fVi);
+
Colormap colorMap = XCreateColormap(dsp,
RootWindow(dsp, fVi->screen),
fVi->visual,
- AllocNone);
+ AllocNone);
XSetWindowAttributes swa;
swa.colormap = colorMap;
swa.event_mask = EVENT_MASK;
@@ -131,20 +137,9 @@ void SkOSWindow::initWindow(int requestedMSAASampleCount, AttachmentInfo* info)
fVi->visual,
CWEventMask | CWColormap,
&swa);
- } else {
- if (info) {
- info->fSampleCount = 0;
- info->fStencilBits = 0;
- }
- // Create a simple window instead. We will not be able to show GL
- fUnixWindow.fWin = XCreateSimpleWindow(dsp,
- DefaultRootWindow(dsp),
- 0, 0, // x, y
- WIDTH, HEIGHT,
- 0, // border width
- 0, // border value
- 0); // background value
+
}
+
this->mapWindowAndWait();
fUnixWindow.fGc = XCreateGC(dsp, fUnixWindow.fWin, 0, nullptr);
}

Powered by Google App Engine
This is Rietveld 408576698