The browser plug-in of Android2.1 has two rendering modes. The definitions in android_npapi.h are as follows:
KBitmap_ANPDrawingModel = 0;
KSurface_ANPDrawingModel = 1;
(Bitmap mode and surface mode ).
During instance initialization (when newp of the Plugin function list is called), Plug-in needs to inform the browser of the rendering method.
The following describes the two rendering methods:
1. bitmap mode
KBitmap_ANPDrawingMode is a traditional rendering method. in this mode, the bottom layer of the browser calls the NPP_HandleEvent function provided by Plug-in to trigger the rendering event, and pass the bitmap address to be rendered as part of the parameter to plug-in. plug-in only needs to be drawn using the related ANPInterface obtained during initialization. In this mode, plug-in does not need to consider the scaling problem, and the screen scaling will be handled by webkit.
// ============================================
2. surface mode
KSurface_ANPDrawingMode has the special features of the Android platform, because this mode requires Java-side cooperation. In this mode, Plug-in will inform webkit of its PluginStub class name during initialization. webkit will, based on this class name, combine the npp parameter, obtain the corresponding view on the Java side and add it to the layout. To use this mode, plug-in must implement a class inherited from PluginStub, which is similar to SurfaceView and must be scaled by itself.
According to the description in android_npapi.h, the performance of the Surface mode is better than that of the bitmap mode, but I found that the surface mode will flash during scaling on the simulator. However, flash10.1 on nexus one of android2.2 seems to be in the surface mode, but it does not Flash. In order to support Flash, google has made many modifications to webkit on Android versions recently.
Link