Bug 564991. Part 37: Add test plugin API to make the plugin invalidate itself during each paint. r=josh
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 16 Jul 2010 09:08:11 +1200
changeset 47770 813dd6f10747d29090c4f1bcb78df2727ae4986c
parent 47769 626c70cb1db56e22c77465202d9d716a32867836
child 47771 8183174f552762a030ae52ab36a6255ea1f2fc23
push id14413
push userrocallahan@mozilla.com
push dateThu, 15 Jul 2010 21:12:02 +0000
treeherderautoland@e1d7fd5255fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh
bugs564991
milestone2.0b2pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 564991. Part 37: Add test plugin API to make the plugin invalidate itself during each paint. r=josh
modules/plugin/test/testplugin/README
modules/plugin/test/testplugin/nptest.cpp
modules/plugin/test/testplugin/nptest.h
--- a/modules/plugin/test/testplugin/README
+++ b/modules/plugin/test/testplugin/README
@@ -166,16 +166,20 @@ for windowed plugins too (Silverlight de
 * getPaintCount()
 Returns the number of times this plugin instance has processed a paint request.
 This can be used to detect whether painting has happened in a plugin's
 window.
 
 * getWidthAtLastPaint()
 Returns the window width that was current when the plugin last painted.
 
+* setInvalidateDuringPaint(value)
+When value is true, every time the plugin paints, it will invalidate
+itself *during the paint* using NPN_Invalidate.
+
 == Plugin geometry ==
 
 The test plugin supports the following scriptable methods:
 
 * getEdge(edge)
 Returns the integer screen pixel coordinate of an edge of the plugin's
 area:
 -- edge=0: returns left edge coordinate
--- a/modules/plugin/test/testplugin/nptest.cpp
+++ b/modules/plugin/test/testplugin/nptest.cpp
@@ -137,16 +137,17 @@ static bool getClipRegionRectCount(NPObj
 static bool getClipRegionRectEdge(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool startWatchingInstanceCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getInstanceCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool stopWatchingInstanceCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getLastMouseX(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getLastMouseY(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getPaintCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getWidthAtLastPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
+static bool setInvalidateDuringPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getError(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool doInternalConsistencyCheck(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool setColor(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool throwExceptionNextInvoke(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool convertPointX(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool convertPointY(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool streamTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool crashPlugin(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
@@ -187,16 +188,17 @@ static const NPUTF8* sPluginMethodIdenti
   "getClipRegionRectEdge",
   "startWatchingInstanceCount",
   "getInstanceCount",
   "stopWatchingInstanceCount",
   "getLastMouseX",
   "getLastMouseY",
   "getPaintCount",
   "getWidthAtLastPaint",
+  "setInvalidateDuringPaint",
   "getError",
   "doInternalConsistencyCheck",
   "setColor",
   "throwExceptionNextInvoke",
   "convertPointX",
   "convertPointY",
   "streamTest",
   "crash",
@@ -238,16 +240,17 @@ static const ScriptableFunction sPluginM
   getClipRegionRectEdge,
   startWatchingInstanceCount,
   getInstanceCount,
   stopWatchingInstanceCount,
   getLastMouseX,
   getLastMouseY,
   getPaintCount,
   getWidthAtLastPaint,
+  setInvalidateDuringPaint,
   getError,
   doInternalConsistencyCheck,
   setColor,
   throwExceptionNextInvoke,
   convertPointX,
   convertPointY,
   streamTest,
   crashPlugin,
@@ -684,16 +687,17 @@ NPP_New(NPMIMEType pluginType, NPP insta
   instanceData->streamBuf = NULL;
   instanceData->streamBufSize = 0;
   instanceData->fileBuf = NULL;
   instanceData->fileBufSize = 0;
   instanceData->throwOnNextInvoke = false;
   instanceData->testrange = NULL;
   instanceData->hasWidget = false;
   instanceData->npnNewStream = false;
+  instanceData->invalidateDuringPaint = false;
   instanceData->writeCount = 0;
   instanceData->writeReadyCount = 0;
   memset(&instanceData->window, 0, sizeof(instanceData->window));
   instanceData->crashOnDestroy = false;
   instanceData->cleanupWidget = true; // only used by nptest_gtk
   instanceData->topLevelWindowActivationState = ACTIVATION_STATE_UNKNOWN;
   instanceData->topLevelWindowActivationEventCount = 0;
   instanceData->focusState = ACTIVATION_STATE_UNKNOWN;
@@ -2123,16 +2127,32 @@ getWidthAtLastPaint(NPObject* npobj, con
 
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
   InstanceData* id = static_cast<InstanceData*>(npp->pdata);
   INT32_TO_NPVARIANT(id->widthAtLastPaint, *result);
   return true;
 }
 
 static bool
+setInvalidateDuringPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+  if (argCount != 1)
+    return false;
+
+  if (!NPVARIANT_IS_BOOLEAN(args[0]))
+    return false;
+  bool doInvalidate = NPVARIANT_TO_BOOLEAN(args[0]);
+
+  NPP npp = static_cast<TestNPObject*>(npobj)->npp;
+  InstanceData* id = static_cast<InstanceData*>(npp->pdata);
+  id->invalidateDuringPaint = doInvalidate;
+  return true;
+}
+
+static bool
 getError(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   if (argCount != 0)
     return false;
 
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
   InstanceData* id = static_cast<InstanceData*>(npp->pdata);
   if (id->err.str().length() == 0)
@@ -2333,16 +2353,25 @@ setColor(NPObject* npobj, const NPVarian
   VOID_TO_NPVARIANT(*result);
   return true;
 }
 
 void notifyDidPaint(InstanceData* instanceData)
 {
   ++instanceData->paintCount;
   instanceData->widthAtLastPaint = instanceData->window.width;
+
+  if (instanceData->invalidateDuringPaint) {
+    NPRect r;
+    r.left = 0;
+    r.top = 0;
+    r.right = instanceData->window.width;
+    r.bottom = instanceData->window.height;
+    NPN_InvalidateRect(instanceData->npp, &r);
+  }
 }
 
 static const NPClass kTestSharedNPClass = {
   NP_CLASS_STRUCT_VERSION,
   // Everything else is NULL
 };
 
 static bool getObjectValue(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
--- a/modules/plugin/test/testplugin/nptest.h
+++ b/modules/plugin/test/testplugin/nptest.h
@@ -97,16 +97,17 @@ typedef struct InstanceData {
   int32_t instanceCountWatchGeneration;
   bool lastReportedPrivateModeState;
   bool hasWidget;
   bool npnNewStream;
   bool throwOnNextInvoke;
   uint32_t timerID[2];
   bool timerTestResult;
   bool asyncCallbackResult;
+  bool invalidateDuringPaint;
   int32_t winX;
   int32_t winY;
   int32_t lastMouseX;
   int32_t lastMouseY;
   int32_t widthAtLastPaint;
   int32_t paintCount;
   int32_t writeCount;
   int32_t writeReadyCount;