2008-12-17 15:59:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkOSWindow_Unix_DEFINED
|
|
|
|
#define SkOSWindow_Unix_DEFINED
|
|
|
|
|
|
|
|
#include "SkWindow.h"
|
|
|
|
#include <X11/Xlib.h>
|
2011-04-15 14:48:08 +00:00
|
|
|
#include <GL/glx.h>
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-03-15 15:15:15 +00:00
|
|
|
class SkBitmap;
|
|
|
|
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;
|
|
|
|
bool fGLCreated;
|
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();
|
|
|
|
void post_linuxevent();
|
2011-03-18 14:29:44 +00:00
|
|
|
bool attachGL();
|
2011-03-15 15:15:15 +00:00
|
|
|
void detachGL();
|
|
|
|
void presentGL();
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-03-15 15:15:15 +00:00
|
|
|
//static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-03-15 15:15:15 +00:00
|
|
|
//static bool WndProc(SkUnixWindow* w, XEvent &e);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// overrides from SkWindow
|
2011-03-15 15:15:15 +00:00
|
|
|
virtual bool onEvent(const SkEvent&);
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void onHandleInval(const SkIRect&);
|
2011-03-15 15:15:15 +00:00
|
|
|
virtual bool onHandleChar(SkUnichar);
|
|
|
|
virtual bool onHandleKey(SkKey);
|
|
|
|
virtual bool onHandleKeyUp(SkKey);
|
|
|
|
virtual void onSetTitle(const char title[]);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SkUnixWindow fUnixWindow;
|
2011-04-15 14:48:08 +00:00
|
|
|
bool fGLAttached;
|
|
|
|
bool fRestart;
|
|
|
|
|
|
|
|
// Needed for GL
|
|
|
|
XVisualInfo* fVi;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
void doPaint();
|
2011-04-15 14:48:08 +00:00
|
|
|
void restartLoop();
|
|
|
|
void mapWindowAndWait();
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
typedef SkWindow INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|