source: trunk/src/platform/nacl/nacl-instance.h @ 1440

Last change on this file since 1440 was 1440, checked in by sam, 9 years ago

nacl: NaCl binaries no longer need a modified main() to work, the NaCl
instance object takes care of everything for us.

File size: 2.2 KB
Line 
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 <ppapi/cpp/instance.h>
9#include <ppapi/c/ppb_gamepad.h>
10
11#include "platform/nacl/opengl_context.h"
12#include "platform/nacl/opengl_context_ptrs.h"
13
14#include "input/input.h"
15
16namespace lol {
17
18class NaClInstance : public pp::Instance
19{
20public:
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    // Called to draw the contents of the module's browser area.
40    virtual bool HandleInputEvent(const pp::InputEvent& event);
41
42    void DrawSelf();
43
44    /* Communication with the application object */
45    static void MainSignal();
46
47private:
48    SharedOpenGLContext m_opengl_ctx;
49
50    ivec2 m_size;
51
52    static void TickCallback(void* data, int32_t result);
53    static void * MainRun(void *data);
54
55    /* Gamepad support */
56    PPB_Gamepad const *m_pad_interface;
57    Array<Stick *> m_sticks;
58
59    /* Communication with the application object */
60    struct Args
61    {
62        Args(int argc, char **argv, char **env)
63          : m_argc(argc), m_argv(argv), m_env(env) {}
64        Args() {}
65
66        int m_argc;
67        char **m_argv;
68        char **m_env;
69    };
70    static Mutex main_mutex;
71    static Queue<Args *, 1> main_queue;
72
73    Thread *m_main_thread;
74};
75
76}  // namespace lol
77
78#endif  // EXAMPLES_TUMBLER_TUMBLER_H_
Note: See TracBrowser for help on using the repository browser.