1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/views/SkOSWindow_Unix.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,82 @@ 1.4 +/* 1.5 + * Copyright 2006 The Android Open Source Project 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#ifndef SkOSWindow_Unix_DEFINED 1.12 +#define SkOSWindow_Unix_DEFINED 1.13 + 1.14 +#include <GL/glx.h> 1.15 +#include <X11/Xlib.h> 1.16 + 1.17 +#include "SkWindow.h" 1.18 + 1.19 +class SkEvent; 1.20 + 1.21 +struct SkUnixWindow { 1.22 + Display* fDisplay; 1.23 + Window fWin; 1.24 + size_t fOSWin; 1.25 + GC fGc; 1.26 + GLXContext fGLContext; 1.27 +}; 1.28 + 1.29 +class SkOSWindow : public SkWindow { 1.30 +public: 1.31 + SkOSWindow(void*); 1.32 + ~SkOSWindow(); 1.33 + 1.34 + void* getHWND() const { return (void*)fUnixWindow.fWin; } 1.35 + void* getDisplay() const { return (void*)fUnixWindow.fDisplay; } 1.36 + void* getUnixWindow() const { return (void*)&fUnixWindow; } 1.37 + void loop(); 1.38 + 1.39 + enum SkBackEndTypes { 1.40 + kNone_BackEndType, 1.41 + kNativeGL_BackEndType, 1.42 + }; 1.43 + 1.44 + struct AttachmentInfo { 1.45 + int fSampleCount; 1.46 + int fStencilBits; 1.47 + }; 1.48 + 1.49 + bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); 1.50 + void detach(); 1.51 + void present(); 1.52 + 1.53 + int getMSAASampleCount() const { return fMSAASampleCount; } 1.54 + 1.55 + //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay); 1.56 + 1.57 +protected: 1.58 + // Overridden from from SkWindow: 1.59 + virtual void onSetTitle(const char title[]) SK_OVERRIDE; 1.60 + 1.61 +private: 1.62 + enum NextXEventResult { 1.63 + kContinue_NextXEventResult, 1.64 + kQuitRequest_NextXEventResult, 1.65 + kPaintRequest_NextXEventResult 1.66 + }; 1.67 + 1.68 + NextXEventResult nextXEvent(); 1.69 + void doPaint(); 1.70 + void mapWindowAndWait(); 1.71 + 1.72 + void closeWindow(); 1.73 + void initWindow(int newMSAASampleCount, AttachmentInfo* info); 1.74 + 1.75 + SkUnixWindow fUnixWindow; 1.76 + 1.77 + // Needed for GL 1.78 + XVisualInfo* fVi; 1.79 + // we recreate the underlying xwindow if this changes 1.80 + int fMSAASampleCount; 1.81 + 1.82 + typedef SkWindow INHERITED; 1.83 +}; 1.84 + 1.85 +#endif