Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 3 | consideration of your agreement to the following terms, and your use, installation, |
| 4 | modification or redistribution of this Apple software constitutes acceptance of these |
| 5 | terms. If you do not agree with these terms, please do not use, install, modify or |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 6 | redistribute this Apple software. |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 7 | |
| 8 | In consideration of your agreement to abide by the following terms, and subject to these |
Derek Sollenberger | d53b56d | 2010-01-11 12:31:49 -0500 | [diff] [blame] | 9 | terms, Apple grants you a personal, non-exclusive license, under Apple�s copyrights in |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 10 | this original Apple software (the "Apple Software"), to use, reproduce, modify and |
| 11 | redistribute the Apple Software, with or without modifications, in source and/or binary |
| 12 | forms; provided that if you redistribute the Apple Software in its entirety and without |
| 13 | modifications, you must retain this notice and the following text and disclaimers in all |
| 14 | such redistributions of the Apple Software. Neither the name, trademarks, service marks |
| 15 | or logos of Apple Computer, Inc. may be used to endorse or promote products derived from |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 16 | the Apple Software without specific prior written permission from Apple. Except as expressly |
| 17 | stated in this notice, no other rights or licenses, express or implied, are granted by Apple |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 18 | herein, including but not limited to any patent rights that may be infringed by your |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 19 | derivative works or by other works in which the Apple Software may be incorporated. |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 20 | |
| 21 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, |
| 22 | EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, |
| 23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 24 | USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 25 | |
| 26 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL |
| 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 28 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, |
| 29 | REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND |
| 30 | WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 31 | OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | */ |
| 33 | |
| 34 | #ifndef PluginObject__DEFINED |
| 35 | #define PluginObject__DEFINED |
| 36 | |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 37 | #include "main.h" |
Derek Sollenberger | 08581f1 | 2009-09-08 18:36:29 -0400 | [diff] [blame] | 38 | #include <jni.h> |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 39 | |
Derek Sollenberger | d53b56d | 2010-01-11 12:31:49 -0500 | [diff] [blame] | 40 | enum CustomEventTypes { |
| 41 | kSurfaceCreated_CustomEvent = 0, |
| 42 | kSurfaceChanged_CustomEvent = 1, |
| 43 | kSurfaceDestroyed_CustomEvent = 2, |
| 44 | }; |
| 45 | typedef int32_t CustomEventType; |
| 46 | |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 47 | class SubPlugin { |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 48 | public: |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 49 | SubPlugin(NPP inst) : m_inst(inst) {} |
| 50 | virtual ~SubPlugin() {} |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 51 | virtual int16 handleEvent(const ANPEvent* evt) = 0; |
Derek Sollenberger | 21f3991 | 2009-07-09 09:19:39 -0400 | [diff] [blame] | 52 | virtual bool supportsDrawingModel(ANPDrawingModel) = 0; |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 53 | |
Derek Sollenberger | bb660dd | 2009-10-13 11:43:48 -0400 | [diff] [blame] | 54 | int getPluginWidth(); |
| 55 | int getPluginHeight(); |
| 56 | |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 57 | NPP inst() const { return m_inst; } |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 58 | |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 59 | private: |
| 60 | NPP m_inst; |
| 61 | }; |
| 62 | |
Derek Sollenberger | 08581f1 | 2009-09-08 18:36:29 -0400 | [diff] [blame] | 63 | class SurfaceSubPlugin : public SubPlugin { |
| 64 | public: |
Derek Sollenberger | d53b56d | 2010-01-11 12:31:49 -0500 | [diff] [blame] | 65 | SurfaceSubPlugin(NPP inst) : SubPlugin(inst) { m_context = NULL; } |
Derek Sollenberger | 08581f1 | 2009-09-08 18:36:29 -0400 | [diff] [blame] | 66 | virtual ~SurfaceSubPlugin() {} |
Derek Sollenberger | d53b56d | 2010-01-11 12:31:49 -0500 | [diff] [blame] | 67 | virtual jobject getSurface() = 0; |
| 68 | virtual bool supportsDrawingModel(ANPDrawingModel); |
Derek Sollenberger | 51cce58 | 2009-12-01 08:26:20 -0500 | [diff] [blame] | 69 | |
Derek Sollenberger | d53b56d | 2010-01-11 12:31:49 -0500 | [diff] [blame] | 70 | void setContext(jobject context); |
Derek Sollenberger | 51cce58 | 2009-12-01 08:26:20 -0500 | [diff] [blame] | 71 | |
Derek Sollenberger | d53b56d | 2010-01-11 12:31:49 -0500 | [diff] [blame] | 72 | jobject m_context; |
Derek Sollenberger | 08581f1 | 2009-09-08 18:36:29 -0400 | [diff] [blame] | 73 | }; |
| 74 | |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 75 | enum PluginTypes { |
Derek Sollenberger | db398a7 | 2009-06-29 13:53:04 -0400 | [diff] [blame] | 76 | kAnimation_PluginType = 1, |
| 77 | kAudio_PluginType = 2, |
| 78 | kBackground_PluginType = 3, |
| 79 | kForm_PluginType = 4, |
| 80 | kText_PluginType = 5, |
Derek Sollenberger | c0f2657 | 2009-07-16 11:38:02 -0400 | [diff] [blame] | 81 | kPaint_PluginType = 6, |
Derek Sollenberger | b8947ee | 2009-10-05 14:40:18 -0400 | [diff] [blame] | 82 | kVideo_PluginType = 7, |
Derek Sollenberger | 1bc5ab6 | 2010-01-14 11:44:37 -0500 | [diff] [blame] | 83 | kNavigation_PluginType = 8, |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 84 | }; |
| 85 | typedef uint32_t PluginType; |
| 86 | |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 87 | typedef struct PluginObject { |
| 88 | NPObject header; |
| 89 | NPP npp; |
| 90 | NPWindow* window; |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 91 | |
| 92 | PluginType pluginType; |
| 93 | SubPlugin* activePlugin; |
Derek Sollenberger | d7ebf27 | 2009-06-18 11:19:41 -0400 | [diff] [blame] | 94 | |
Grace Kloba | fbe47c0 | 2009-05-14 17:31:45 -0700 | [diff] [blame] | 95 | } PluginObject; |
| 96 | |
| 97 | NPClass *getPluginClass(void); |
| 98 | |
| 99 | #endif // PluginObject__DEFINED |