Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
1 /*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
8 #ifndef SkOSWindow_Unix_DEFINED
9 #define SkOSWindow_Unix_DEFINED
11 #include <GL/glx.h>
12 #include <X11/Xlib.h>
14 #include "SkWindow.h"
16 class SkEvent;
18 struct SkUnixWindow {
19 Display* fDisplay;
20 Window fWin;
21 size_t fOSWin;
22 GC fGc;
23 GLXContext fGLContext;
24 };
26 class SkOSWindow : public SkWindow {
27 public:
28 SkOSWindow(void*);
29 ~SkOSWindow();
31 void* getHWND() const { return (void*)fUnixWindow.fWin; }
32 void* getDisplay() const { return (void*)fUnixWindow.fDisplay; }
33 void* getUnixWindow() const { return (void*)&fUnixWindow; }
34 void loop();
36 enum SkBackEndTypes {
37 kNone_BackEndType,
38 kNativeGL_BackEndType,
39 };
41 struct AttachmentInfo {
42 int fSampleCount;
43 int fStencilBits;
44 };
46 bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
47 void detach();
48 void present();
50 int getMSAASampleCount() const { return fMSAASampleCount; }
52 //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
54 protected:
55 // Overridden from from SkWindow:
56 virtual void onSetTitle(const char title[]) SK_OVERRIDE;
58 private:
59 enum NextXEventResult {
60 kContinue_NextXEventResult,
61 kQuitRequest_NextXEventResult,
62 kPaintRequest_NextXEventResult
63 };
65 NextXEventResult nextXEvent();
66 void doPaint();
67 void mapWindowAndWait();
69 void closeWindow();
70 void initWindow(int newMSAASampleCount, AttachmentInfo* info);
72 SkUnixWindow fUnixWindow;
74 // Needed for GL
75 XVisualInfo* fVi;
76 // we recreate the underlying xwindow if this changes
77 int fMSAASampleCount;
79 typedef SkWindow INHERITED;
80 };
82 #endif