| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef SkOSWindow_Win_DEFINED |
| 18 | #define SkOSWindow_Win_DEFINED |
| 19 | |
| 20 | #include "SkWindow.h" |
| 21 | |
| 22 | class SkOSWindow : public SkWindow { |
| 23 | public: |
| 24 | SkOSWindow(void* hwnd); |
| reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame^] | 25 | virtual ~SkOSWindow(); |
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 26 | |
| 27 | void* getHWND() const { return fHWND; } |
| 28 | void setSize(int width, int height); |
| 29 | void updateSize(); |
| 30 | |
| 31 | static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay); |
| reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame^] | 32 | |
| 33 | bool attachGL(const SkBitmap* offscreen); |
| 34 | void detachGL(); |
| 35 | void presentGL(); |
| 36 | |
| 37 | bool attachD3D9(); |
| 38 | void detachD3D9(); |
| 39 | void presentD3D9(); |
| 40 | |
| 41 | void* d3d9Device() { return fD3D9Device; } |
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 42 | |
| reed@android.com | e191b16 | 2009-12-18 21:33:39 +0000 | [diff] [blame] | 43 | bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); |
| 44 | static bool QuitOnDeactivate(HWND hWnd); |
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 45 | |
| 46 | enum { |
| 47 | SK_WM_SkEvent = WM_APP + 1000, |
| 48 | SK_WM_SkTimerID = 0xFFFF // just need a non-zero value |
| 49 | }; |
| 50 | |
| 51 | protected: |
| 52 | virtual bool quitOnDeactivate() { return true; } |
| 53 | |
| 54 | // overrides from SkWindow |
| 55 | virtual void onHandleInval(const SkIRect&); |
| 56 | // overrides from SkView |
| 57 | virtual void onAddMenu(const SkOSMenu*); |
| 58 | |
| reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame^] | 59 | virtual void onSetTitle(const char title[]); |
| 60 | |
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 61 | private: |
| reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame^] | 62 | void* fHWND; |
| 63 | |
| 64 | void doPaint(void* ctx); |
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 65 | |
| reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame^] | 66 | void* fHGLRC; |
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 67 | |
| reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame^] | 68 | bool fGLAttached; |
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 69 | |
| reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame^] | 70 | void* fD3D9Device; |
| 71 | bool fD3D9Attached; |
| 72 | |
| 73 | HMENU fMBar; |
| 74 | |
| 75 | typedef SkWindow INHERITED; |
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | #endif |
| 79 | |