1 | // Copyright (c) 2011 The Native Client Authors. All rights reserved. |
---|
2 | // Use of this source code is governed by a BSD-style license that can be |
---|
3 | // found in the LICENSE file. |
---|
4 | |
---|
5 | #ifndef EXAMPLES_TUMBLER_TUMBLER_H_ |
---|
6 | #define EXAMPLES_TUMBLER_TUMBLER_H_ |
---|
7 | |
---|
8 | #include <pthread.h> |
---|
9 | #include <map> |
---|
10 | #include <vector> |
---|
11 | |
---|
12 | #include <ppapi/cpp/instance.h> |
---|
13 | |
---|
14 | #include "platform/nacl/opengl_context.h" |
---|
15 | #include "platform/nacl/opengl_context_ptrs.h" |
---|
16 | |
---|
17 | namespace lol { |
---|
18 | |
---|
19 | class NaClInstance : public pp::Instance { |
---|
20 | public: |
---|
21 | explicit NaClInstance(PP_Instance instance); |
---|
22 | |
---|
23 | // The dtor makes the 3D context current before deleting the cube view, then |
---|
24 | // destroys the 3D context both in the module and in the browser. |
---|
25 | virtual ~NaClInstance(); |
---|
26 | |
---|
27 | // Called by the browser when the NaCl module is loaded and all ready to go. |
---|
28 | virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); |
---|
29 | |
---|
30 | // Called whenever the in-browser window changes size. |
---|
31 | virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip); |
---|
32 | |
---|
33 | // Called by the browser to handle the postMessage() call in Javascript. |
---|
34 | virtual void HandleMessage(const pp::Var& message); |
---|
35 | |
---|
36 | // Bind and publish the module's methods to JavaScript. |
---|
37 | //void InitializeMethods(ScriptingBridge* bridge); |
---|
38 | |
---|
39 | |
---|
40 | // Called to draw the contents of the module's browser area. |
---|
41 | virtual bool HandleInputEvent(const pp::InputEvent& event); |
---|
42 | |
---|
43 | void DrawSelf(); |
---|
44 | |
---|
45 | SharedOpenGLContext opengl_context_; |
---|
46 | |
---|
47 | ivec2 m_size; |
---|
48 | }; |
---|
49 | |
---|
50 | } // namespace lol |
---|
51 | |
---|
52 | #endif // EXAMPLES_TUMBLER_TUMBLER_H_ |
---|