blob: 09f0c5ce4c1fff99ac04e0376674561017a78658 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
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
22class SkOSWindow : public SkWindow {
23public:
24 SkOSWindow(void* hwnd);
reed@android.comf2b98d62010-12-20 18:26:13 +000025 virtual ~SkOSWindow();
reed@android.com8a1c16f2008-12-17 15:59:43 +000026
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.comf2b98d62010-12-20 18:26:13 +000032
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.com8a1c16f2008-12-17 15:59:43 +000042
reed@android.come191b162009-12-18 21:33:39 +000043 bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
44 static bool QuitOnDeactivate(HWND hWnd);
reed@android.com8a1c16f2008-12-17 15:59:43 +000045
46 enum {
47 SK_WM_SkEvent = WM_APP + 1000,
48 SK_WM_SkTimerID = 0xFFFF // just need a non-zero value
49 };
50
51protected:
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.comf2b98d62010-12-20 18:26:13 +000059 virtual void onSetTitle(const char title[]);
60
reed@android.com8a1c16f2008-12-17 15:59:43 +000061private:
reed@android.comf2b98d62010-12-20 18:26:13 +000062 void* fHWND;
63
64 void doPaint(void* ctx);
reed@android.com8a1c16f2008-12-17 15:59:43 +000065
reed@android.comf2b98d62010-12-20 18:26:13 +000066 void* fHGLRC;
reed@android.com8a1c16f2008-12-17 15:59:43 +000067
reed@android.comf2b98d62010-12-20 18:26:13 +000068 bool fGLAttached;
reed@android.com8a1c16f2008-12-17 15:59:43 +000069
reed@android.comf2b98d62010-12-20 18:26:13 +000070 void* fD3D9Device;
71 bool fD3D9Attached;
72
73 HMENU fMBar;
74
75 typedef SkWindow INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +000076};
77
78#endif
79