• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2006 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 #ifndef SkOSWindow_Win_DEFINED
11 #define SkOSWindow_Win_DEFINED
12 
13 #include "SkWindow.h"
14 
15 #if SK_ANGLE
16 #include "EGL/egl.h"
17 #endif
18 
19 class SkOSWindow : public SkWindow {
20 public:
21     SkOSWindow(void* hwnd);
22     virtual ~SkOSWindow();
23 
getHWND()24     void*   getHWND() const { return fHWND; }
25     void    setSize(int width, int height);
26     void    updateSize();
27 
28     static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
29 
30     enum SkBackEndTypes {
31         kNone_BackEndType,
32 #if SK_SUPPORT_GPU
33         kNativeGL_BackEndType,
34 #if SK_ANGLE
35         kANGLE_BackEndType,
36 #endif // SK_ANGLE
37 #endif // SK_SUPPORT_GPU
38     };
39 
40     bool attach(SkBackEndTypes attachType, int msaaSampleCount);
41     void detach();
42     void present();
43 
44     bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
45     static bool QuitOnDeactivate(HWND hWnd);
46 
47     enum {
48         SK_WM_SkEvent = WM_APP + 1000,
49         SK_WM_SkTimerID = 0xFFFF    // just need a non-zero value
50     };
51 
52 protected:
quitOnDeactivate()53     virtual bool quitOnDeactivate() { return true; }
54 
55     // overrides from SkWindow
56     virtual void onHandleInval(const SkIRect&);
57     // overrides from SkView
58     virtual void onAddMenu(const SkOSMenu*);
59 
60     virtual void onSetTitle(const char title[]);
61 
62 private:
63     void*               fHWND;
64 
65     void                doPaint(void* ctx);
66 
67 #if SK_SUPPORT_GPU
68     void*               fHGLRC;
69 #if SK_ANGLE
70     EGLDisplay          fDisplay;
71     EGLContext          fContext;
72     EGLSurface          fSurface;
73 #endif // SK_ANGLE
74 #endif // SK_SUPPORT_GPU
75 
76     HMENU               fMBar;
77 
78     SkBackEndTypes      fAttached;
79 
80 #if SK_SUPPORT_GPU
81     bool attachGL(int msaaSampleCount);
82     void detachGL();
83     void presentGL();
84 
85 #if SK_ANGLE
86     bool attachANGLE(int msaaSampleCount);
87     void detachANGLE();
88     void presentANGLE();
89 #endif // SK_ANGLE
90 #endif // SK_SUPPORT_GPU
91 
92     typedef SkWindow INHERITED;
93 };
94 
95 #endif
96