| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EXAMPLES_GAMEPAD_GAMEPAD_H_ | 5 #ifndef EXAMPLES_GAMEPAD_GAMEPAD_H_ |
| 6 #define EXAMPLES_GAMEPAD_GAMEPAD_H_ | 6 #define EXAMPLES_GAMEPAD_GAMEPAD_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include "ppapi/c/ppb_gamepad.h" | 10 #include "ppapi/c/ppb_gamepad.h" |
| 11 #include "ppapi/cpp/graphics_2d.h" | 11 #include "ppapi/cpp/graphics_2d.h" |
| 12 #include "ppapi/cpp/image_data.h" | 12 #include "ppapi/cpp/image_data.h" |
| 13 #include "ppapi/cpp/instance.h" | 13 #include "ppapi/cpp/instance.h" |
| 14 #include "ppapi/cpp/rect.h" | 14 #include "ppapi/cpp/rect.h" |
| 15 #include "ppapi/cpp/size.h" | 15 #include "ppapi/cpp/size.h" |
| 16 | 16 |
| 17 namespace gamepad { | 17 class GamepadInstance : public pp::Instance { |
| 18 | |
| 19 // The Instance class. One of these exists for each instance of your NaCl | |
| 20 // module on the web page. The browser will ask the Module object to create | |
| 21 // a new Instance for each occurrence of the <embed> tag that has these | |
| 22 // attributes: | |
| 23 // type="application/x-nacl" | |
| 24 // nacl="pi_generator.nmf" | |
| 25 class Gamepad : public pp::Instance { | |
| 26 public: | 18 public: |
| 27 explicit Gamepad(PP_Instance instance); | 19 explicit GamepadInstance(PP_Instance instance); |
| 28 virtual ~Gamepad(); | 20 virtual ~GamepadInstance(); |
| 29 | 21 |
| 30 // Update the graphics context to the new size, and regenerate |pixel_buffer_| | 22 // Update the graphics context to the new size, and regenerate |pixel_buffer_| |
| 31 // to fit the new size as well. | 23 // to fit the new size as well. |
| 32 virtual void DidChangeView(const pp::View& view); | 24 virtual void DidChangeView(const pp::View& view); |
| 33 | 25 |
| 34 // Flushes its contents of |pixel_buffer_| to the 2D graphics context. | 26 // Flushes its contents of |pixel_buffer_| to the 2D graphics context. |
| 35 void Paint(); | 27 void Paint(); |
| 36 | 28 |
| 37 bool quit() const { return quit_; } | 29 bool quit() const { return quit_; } |
| 38 | 30 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 60 | 52 |
| 61 bool IsContextValid() const { return graphics_2d_context_ != NULL; } | 53 bool IsContextValid() const { return graphics_2d_context_ != NULL; } |
| 62 | 54 |
| 63 pp::Graphics2D* graphics_2d_context_; | 55 pp::Graphics2D* graphics_2d_context_; |
| 64 pp::ImageData* pixel_buffer_; | 56 pp::ImageData* pixel_buffer_; |
| 65 const PPB_Gamepad* gamepad_; | 57 const PPB_Gamepad* gamepad_; |
| 66 bool flush_pending_; | 58 bool flush_pending_; |
| 67 bool quit_; | 59 bool quit_; |
| 68 }; | 60 }; |
| 69 | 61 |
| 70 } // namespace gamepad | |
| 71 | |
| 72 #endif // EXAMPLES_GAMEPAD_GAMEPAD_H_ | 62 #endif // EXAMPLES_GAMEPAD_GAMEPAD_H_ |
| OLD | NEW |