epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2006 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 4 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #ifndef SkOSWindow_Unix_DEFINED |
| 11 | #define SkOSWindow_Unix_DEFINED |
| 12 | |
| 13 | #include "SkWindow.h" |
| 14 | #include <X11/Xlib.h> |
Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 15 | #include <GL/glx.h> |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 16 | |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 17 | class SkBitmap; |
| 18 | class SkEvent; |
| 19 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 20 | struct SkUnixWindow { |
| 21 | Display* fDisplay; |
| 22 | Window fWin; |
| 23 | size_t fOSWin; |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 24 | GC fGc; |
Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 25 | GLXContext fGLContext; |
| 26 | bool fGLCreated; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | class SkOSWindow : public SkWindow { |
| 30 | public: |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 31 | SkOSWindow(void*); |
| 32 | ~SkOSWindow(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 33 | |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 34 | void* getHWND() const { return (void*)fUnixWindow.fWin; } |
| 35 | void* getDisplay() const { return (void*)fUnixWindow.fDisplay; } |
| 36 | void* getUnixWindow() const { return (void*)&fUnixWindow; } |
Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 37 | void loop(); |
| 38 | void post_linuxevent(); |
bsalomon@google.com | c8ad63e | 2011-03-18 14:29:44 +0000 | [diff] [blame] | 39 | bool attachGL(); |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 40 | void detachGL(); |
| 41 | void presentGL(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 42 | |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 43 | //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 44 | |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 45 | //static bool WndProc(SkUnixWindow* w, XEvent &e); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 46 | |
| 47 | protected: |
| 48 | // overrides from SkWindow |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 49 | virtual bool onEvent(const SkEvent&); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 50 | virtual void onHandleInval(const SkIRect&); |
scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 51 | virtual bool onHandleChar(SkUnichar); |
| 52 | virtual bool onHandleKey(SkKey); |
| 53 | virtual bool onHandleKeyUp(SkKey); |
| 54 | virtual void onSetTitle(const char title[]); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 55 | |
| 56 | private: |
| 57 | SkUnixWindow fUnixWindow; |
Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 58 | bool fGLAttached; |
Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 59 | |
| 60 | // Needed for GL |
| 61 | XVisualInfo* fVi; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 62 | |
| 63 | void doPaint(); |
Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 64 | void mapWindowAndWait(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 65 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 66 | typedef SkWindow INHERITED; |
| 67 | }; |
| 68 | |
| 69 | #endif |
| 70 | |