| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <algorithm> | 5 #include <algorithm> |
| 6 #include <cmath> | 6 #include <cmath> |
| 7 #include <stdarg.h> | 7 #include <stdarg.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 | 9 |
| 10 #include "ppapi/c/ppb_gamepad.h" | 10 #include "ppapi/c/ppb_gamepad.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 height_ = rect.size().height(); | 62 height_ = rect.size().height(); |
| 63 | 63 |
| 64 device_context_ = pp::Graphics2D(this, pp::Size(width_, height_), false); | 64 device_context_ = pp::Graphics2D(this, pp::Size(width_, height_), false); |
| 65 if (!BindGraphics(device_context_)) | 65 if (!BindGraphics(device_context_)) |
| 66 return; | 66 return; |
| 67 | 67 |
| 68 Paint(); | 68 Paint(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void OnFlush(int32_t) { | 71 void OnFlush(int32_t) { |
| 72 // This plugin continuously paints because it continously samples the |
| 73 // gamepad and paints its updated state. |
| 72 Paint(); | 74 Paint(); |
| 73 } | 75 } |
| 74 | 76 |
| 75 private: | 77 private: |
| 76 void Paint() { | 78 void Paint() { |
| 77 pp::ImageData image = PaintImage(device_context_.size()); | 79 pp::ImageData image = PaintImage(device_context_.size()); |
| 78 if (!image.is_null()) { | 80 if (!image.is_null()) { |
| 79 device_context_.ReplaceContents(&image); | 81 device_context_.ReplaceContents(&image); |
| 80 device_context_.Flush( | 82 device_context_.Flush( |
| 81 callback_factory_.NewCallback(&MyInstance::OnFlush)); | 83 callback_factory_.NewCallback(&MyInstance::OnFlush)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 }; | 140 }; |
| 139 | 141 |
| 140 namespace pp { | 142 namespace pp { |
| 141 | 143 |
| 142 // Factory function for your specialization of the Module object. | 144 // Factory function for your specialization of the Module object. |
| 143 Module* CreateModule() { | 145 Module* CreateModule() { |
| 144 return new MyModule(); | 146 return new MyModule(); |
| 145 } | 147 } |
| 146 | 148 |
| 147 } // namespace pp | 149 } // namespace pp |
| 148 | |
| OLD | NEW |