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,
|
|
|
|
};
|
|
|
|
|
2013-03-05 20:06:05 +00:00
|
|
|
struct AttachmentInfo {
|
|
|
|
int fSampleCount;
|
|
|
|
int fStencilBits;
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
protected:
|
2012-03-05 18:29:23 +00:00
|
|
|
// Overridden from from SkWindow:
|
2015-01-09 18:06:39 +00:00
|
|
|
void onSetTitle(const char title[]) SK_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();
|
|
|
|
|
2012-04-06 20:13:38 +00:00
|
|
|
void closeWindow();
|
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
|