2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkOSWindow_Unix_DEFINED
|
|
|
|
#define SkOSWindow_Unix_DEFINED
|
|
|
|
|
2011-04-15 14:48:08 +00:00
|
|
|
#include <GL/glx.h>
|
2012-03-05 18:29:23 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
|
|
|
#include "SkWindow.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-03-15 15:15:15 +00:00
|
|
|
class SkEvent;
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
struct SkUnixWindow {
|
|
|
|
Display* fDisplay;
|
|
|
|
Window fWin;
|
|
|
|
size_t fOSWin;
|
2011-03-15 15:15:15 +00:00
|
|
|
GC fGc;
|
2011-04-15 14:48:08 +00:00
|
|
|
GLXContext fGLContext;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SkOSWindow : public SkWindow {
|
|
|
|
public:
|
2011-03-15 15:15:15 +00:00
|
|
|
SkOSWindow(void*);
|
|
|
|
~SkOSWindow();
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-03-15 15:15:15 +00:00
|
|
|
void* getHWND() const { return (void*)fUnixWindow.fWin; }
|
|
|
|
void* getDisplay() const { return (void*)fUnixWindow.fDisplay; }
|
|
|
|
void* getUnixWindow() const { return (void*)&fUnixWindow; }
|
2011-04-15 14:48:08 +00:00
|
|
|
void loop();
|
2012-04-02 19:24:21 +00:00
|
|
|
|
|
|
|
enum SkBackEndTypes {
|
|
|
|
kNone_BackEndType,
|
|
|
|
kNativeGL_BackEndType,
|
2015-09-23 18:35:55 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
kANGLE_BackEndType,
|
|
|
|
#endif // SK_ANGLE
|
2015-10-02 01:29:34 +00:00
|
|
|
#if SK_COMMAND_BUFFER
|
|
|
|
kCommandBuffer_BackEndType,
|
|
|
|
#endif // SK_COMMAND_BUFFER
|
2012-04-02 19:24:21 +00:00
|
|
|
};
|
|
|
|
|
2013-03-05 20:06:05 +00:00
|
|
|
bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
|
2012-04-02 19:24:21 +00:00
|
|
|
void detach();
|
|
|
|
void present();
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2012-04-06 20:13:38 +00:00
|
|
|
int getMSAASampleCount() const { return fMSAASampleCount; }
|
|
|
|
|
2011-03-15 15:15:15 +00:00
|
|
|
//static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2015-06-16 19:47:25 +00:00
|
|
|
bool makeFullscreen();
|
|
|
|
void setVsync(bool);
|
|
|
|
void closeWindow();
|
2015-05-27 16:19:03 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
protected:
|
2012-03-05 18:29:23 +00:00
|
|
|
// Overridden from from SkWindow:
|
2015-03-26 01:17:31 +00:00
|
|
|
void onSetTitle(const char title[]) override;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
private:
|
2013-06-17 13:42:43 +00:00
|
|
|
enum NextXEventResult {
|
|
|
|
kContinue_NextXEventResult,
|
|
|
|
kQuitRequest_NextXEventResult,
|
|
|
|
kPaintRequest_NextXEventResult
|
|
|
|
};
|
|
|
|
|
|
|
|
NextXEventResult nextXEvent();
|
2012-03-05 18:29:23 +00:00
|
|
|
void doPaint();
|
|
|
|
void mapWindowAndWait();
|
|
|
|
|
2015-06-01 17:03:54 +00:00
|
|
|
// Forcefully closes the window. If a graceful shutdown is desired then call the public
|
|
|
|
// closeWindow method
|
|
|
|
void internalCloseWindow();
|
2013-03-05 20:06:05 +00:00
|
|
|
void initWindow(int newMSAASampleCount, AttachmentInfo* info);
|
2012-04-06 20:13:38 +00:00
|
|
|
|
2012-03-05 18:29:23 +00:00
|
|
|
SkUnixWindow fUnixWindow;
|
2011-04-15 14:48:08 +00:00
|
|
|
|
|
|
|
// Needed for GL
|
|
|
|
XVisualInfo* fVi;
|
2012-04-06 20:13:38 +00:00
|
|
|
// we recreate the underlying xwindow if this changes
|
|
|
|
int fMSAASampleCount;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
typedef SkWindow INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|