blob: 0ebed28bdbac9d1f1992c7c2bb066e143435c9d5 [file] [log] [blame]
Grace Klobafbe47c02009-05-14 17:31:45 -07001/*
2 IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -04003 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 Klobafbe47c02009-05-14 17:31:45 -07006 redistribute this Apple software.
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -04007
8 In consideration of your agreement to abide by the following terms, and subject to these
Derek Sollenbergerd53b56d2010-01-11 12:31:49 -05009 terms, Apple grants you a personal, non-exclusive license, under Apple�s copyrights in
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040010 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 Klobafbe47c02009-05-14 17:31:45 -070016 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 Sollenbergerd7ebf272009-06-18 11:19:41 -040018 herein, including but not limited to any patent rights that may be infringed by your
Grace Klobafbe47c02009-05-14 17:31:45 -070019 derivative works or by other works in which the Apple Software may be incorporated.
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040020
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 Klobafbe47c02009-05-14 17:31:45 -070024 USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040025
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 Klobafbe47c02009-05-14 17:31:45 -070031 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 Sollenbergerd7ebf272009-06-18 11:19:41 -040037#include "main.h"
Derek Sollenberger08581f12009-09-08 18:36:29 -040038#include <jni.h>
Grace Klobafbe47c02009-05-14 17:31:45 -070039
Derek Sollenbergerd53b56d2010-01-11 12:31:49 -050040enum CustomEventTypes {
41 kSurfaceCreated_CustomEvent = 0,
42 kSurfaceChanged_CustomEvent = 1,
43 kSurfaceDestroyed_CustomEvent = 2,
44};
45typedef int32_t CustomEventType;
46
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040047class SubPlugin {
Grace Klobafbe47c02009-05-14 17:31:45 -070048public:
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040049 SubPlugin(NPP inst) : m_inst(inst) {}
50 virtual ~SubPlugin() {}
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040051 virtual int16 handleEvent(const ANPEvent* evt) = 0;
Derek Sollenberger21f39912009-07-09 09:19:39 -040052 virtual bool supportsDrawingModel(ANPDrawingModel) = 0;
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040053
Derek Sollenbergerbb660dd2009-10-13 11:43:48 -040054 int getPluginWidth();
55 int getPluginHeight();
56
Grace Klobafbe47c02009-05-14 17:31:45 -070057 NPP inst() const { return m_inst; }
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040058
Grace Klobafbe47c02009-05-14 17:31:45 -070059private:
60 NPP m_inst;
61};
62
Derek Sollenberger08581f12009-09-08 18:36:29 -040063class SurfaceSubPlugin : public SubPlugin {
64public:
Derek Sollenbergerd53b56d2010-01-11 12:31:49 -050065 SurfaceSubPlugin(NPP inst) : SubPlugin(inst) { m_context = NULL; }
Derek Sollenberger08581f12009-09-08 18:36:29 -040066 virtual ~SurfaceSubPlugin() {}
Derek Sollenbergerd53b56d2010-01-11 12:31:49 -050067 virtual jobject getSurface() = 0;
68 virtual bool supportsDrawingModel(ANPDrawingModel);
Derek Sollenberger51cce582009-12-01 08:26:20 -050069
Derek Sollenbergerd53b56d2010-01-11 12:31:49 -050070 void setContext(jobject context);
Derek Sollenberger51cce582009-12-01 08:26:20 -050071
Derek Sollenbergerd53b56d2010-01-11 12:31:49 -050072 jobject m_context;
Derek Sollenberger08581f12009-09-08 18:36:29 -040073};
74
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040075enum PluginTypes {
Derek Sollenbergerdb398a72009-06-29 13:53:04 -040076 kAnimation_PluginType = 1,
77 kAudio_PluginType = 2,
78 kBackground_PluginType = 3,
79 kForm_PluginType = 4,
80 kText_PluginType = 5,
Derek Sollenbergerc0f26572009-07-16 11:38:02 -040081 kPaint_PluginType = 6,
Derek Sollenbergerb8947ee2009-10-05 14:40:18 -040082 kVideo_PluginType = 7,
Derek Sollenberger1bc5ab62010-01-14 11:44:37 -050083 kNavigation_PluginType = 8,
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040084};
85typedef uint32_t PluginType;
86
Grace Klobafbe47c02009-05-14 17:31:45 -070087typedef struct PluginObject {
88 NPObject header;
89 NPP npp;
90 NPWindow* window;
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040091
92 PluginType pluginType;
93 SubPlugin* activePlugin;
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040094
Grace Klobafbe47c02009-05-14 17:31:45 -070095} PluginObject;
96
97NPClass *getPluginClass(void);
98
99#endif // PluginObject__DEFINED