|
|
|
|
| 540 |
void ReleaseXShm(); |
540 |
void ReleaseXShm(); |
| 541 |
void NativeImageDraw(NPRect* invalidRect = nsnull); |
541 |
void NativeImageDraw(NPRect* invalidRect = nsnull); |
| 542 |
PRBool UpdateVisibility(PRBool aVisible); |
542 |
PRBool UpdateVisibility(PRBool aVisible); |
| 543 |
|
543 |
|
| 544 |
#endif |
544 |
#endif |
|
|
545 |
|
| 546 |
#ifdef MOZ_PLATFORM_MAEMO |
| 547 |
nsresult NativeDrawMemBuff(gfxContext *aContext, |
| 548 |
NPWindow* mWindow, |
| 549 |
const nsIntSize& mPluginSize, |
| 550 |
const nsIntRect& mDirtyRect); |
| 551 |
#endif |
| 545 |
}; |
552 |
}; |
| 546 |
|
553 |
|
| 547 |
// Mac specific code to fix up port position and clip |
554 |
// Mac specific code to fix up port position and clip |
| 548 |
#ifdef XP_MACOSX |
555 |
#ifdef XP_MACOSX |
| 549 |
|
556 |
|
|
Lines 5063-5072
void nsPluginInstanceOwner::Paint(gfxCon
|
Link Here
|
|---|
|
| 5063 |
|
5070 |
|
| 5064 |
// Renderer::Draw() draws a rectangle with top-left at the aContext origin. |
5071 |
// Renderer::Draw() draws a rectangle with top-left at the aContext origin. |
| 5065 |
gfxContextAutoSaveRestore autoSR(aContext); |
5072 |
gfxContextAutoSaveRestore autoSR(aContext); |
| 5066 |
aContext->Translate(pluginRect.pos); |
5073 |
aContext->Translate(pluginRect.pos); |
| 5067 |
|
5074 |
|
|
|
5075 |
#ifdef MOZ_PLATFORM_MAEMO |
| 5076 |
PRBool simpleImageRender = PR_FALSE; |
| 5077 |
mInstance->GetValueFromPlugin(NPPVpluginWindowlessLocalBool, |
| 5078 |
&simpleImageRender); |
| 5079 |
if (simpleImageRender && |
| 5080 |
aContext->OriginalSurface()->GetType() == gfxASurface::SurfaceTypeImage) { |
| 5081 |
NativeDrawMemBuff(aContext, window, pluginSize, pluginDirtyRect); |
| 5082 |
return; |
| 5083 |
} |
| 5084 |
#endif |
| 5085 |
|
| 5068 |
Renderer renderer(window, mInstance, pluginSize, pluginDirtyRect); |
5086 |
Renderer renderer(window, mInstance, pluginSize, pluginDirtyRect); |
| 5069 |
renderer.Draw(aContext, window->width, window->height, |
5087 |
renderer.Draw(aContext, window->width, window->height, |
| 5070 |
rendererFlags, nsnull); |
5088 |
rendererFlags, nsnull); |
| 5071 |
} |
5089 |
} |
| 5072 |
|
5090 |
|
|
Lines 5365-5374
nsPluginInstanceOwner::NativeImageDraw(N
|
Link Here
|
|---|
|
| 5365 |
XFlush(gdk_x11_get_default_xdisplay()); |
5383 |
XFlush(gdk_x11_get_default_xdisplay()); |
| 5366 |
return; |
5384 |
return; |
| 5367 |
} |
5385 |
} |
| 5368 |
#endif |
5386 |
#endif |
| 5369 |
|
5387 |
|
|
|
5388 |
#ifdef MOZ_PLATFORM_MAEMO |
| 5389 |
// NativeDrawMemBuff |
| 5390 |
nsresult |
| 5391 |
nsPluginInstanceOwner::NativeDrawMemBuff(gfxContext *aContext, |
| 5392 |
NPWindow* mWindow, |
| 5393 |
const nsIntSize& mPluginSize, |
| 5394 |
const nsIntRect& mDirtyRect) |
| 5395 |
{ |
| 5396 |
PRBool doupdatewindow = PR_FALSE; |
| 5397 |
|
| 5398 |
if (mWindow->x || mWindow->y) { |
| 5399 |
mWindow->x = 0; |
| 5400 |
mWindow->y = 0; |
| 5401 |
doupdatewindow = PR_TRUE; |
| 5402 |
} |
| 5403 |
|
| 5404 |
if (nsIntSize(mWindow->width, mWindow->height) != mPluginSize) { |
| 5405 |
mWindow->width = mPluginSize.width; |
| 5406 |
mWindow->height = mPluginSize.height; |
| 5407 |
doupdatewindow = PR_TRUE; |
| 5408 |
} |
| 5409 |
|
| 5410 |
// The clip rect is relative to drawable top-left. |
| 5411 |
nsIntRect clipRect; |
| 5412 |
clipRect.x = 0; |
| 5413 |
clipRect.y = 0; |
| 5414 |
clipRect.width = mWindow->width; |
| 5415 |
clipRect.height = mWindow->height; |
| 5416 |
|
| 5417 |
NPRect newClipRect; |
| 5418 |
newClipRect.left = clipRect.x; |
| 5419 |
newClipRect.top = clipRect.y; |
| 5420 |
newClipRect.right = clipRect.XMost(); |
| 5421 |
newClipRect.bottom = clipRect.YMost(); |
| 5422 |
if (mWindow->clipRect.left != newClipRect.left || |
| 5423 |
mWindow->clipRect.top != newClipRect.top || |
| 5424 |
mWindow->clipRect.right != newClipRect.right || |
| 5425 |
mWindow->clipRect.bottom != newClipRect.bottom) { |
| 5426 |
mWindow->clipRect = newClipRect; |
| 5427 |
doupdatewindow = PR_TRUE; |
| 5428 |
} |
| 5429 |
|
| 5430 |
nsRefPtr<gfxImageSurface> surface = static_cast<gfxImageSurface*>(aContext->OriginalSurface()); |
| 5431 |
NS_ENSURE_TRUE(surface, NS_ERROR_OUT_OF_MEMORY); |
| 5432 |
|
| 5433 |
PRUint32 surfaceDepth = 24; |
| 5434 |
if (surface->Format() == gfxASurface::ImageFormatRGB16) |
| 5435 |
surfaceDepth = 16; |
| 5436 |
if (surface->Format() == gfxASurface::ImageFormatARGB32) |
| 5437 |
surfaceDepth = 32; |
| 5438 |
|
| 5439 |
NPSetWindowCallbackStruct* ws_info = |
| 5440 |
static_cast<NPSetWindowCallbackStruct*>(mWindow->ws_info); |
| 5441 |
ws_info->visual = 0; |
| 5442 |
ws_info->colormap = 0; |
| 5443 |
if (ws_info->depth != surfaceDepth) { |
| 5444 |
ws_info->depth = surfaceDepth; |
| 5445 |
doupdatewindow = PR_TRUE; |
| 5446 |
} |
| 5447 |
|
| 5448 |
if (doupdatewindow) |
| 5449 |
mInstance->SetWindow(mWindow); |
| 5450 |
|
| 5451 |
// Until we don't have agreement about how to pass NPImageExpose structure to plugin |
| 5452 |
// it will be packed into XEvent.xgraphicsexpose.drawable member |
| 5453 |
// Probably we have to use something like HandleEvent2 API. see bug 477456 in BMO |
| 5454 |
// Translate the dirty rect to drawable coordinates. |
| 5455 |
nsIntRect dirtyRect = mDirtyRect; |
| 5456 |
// Intersect the dirty rect with the clip rect to ensure that it lies within |
| 5457 |
// the drawable. |
| 5458 |
if (!dirtyRect.IntersectRect(dirtyRect, clipRect)) |
| 5459 |
return NS_OK; |
| 5460 |
|
| 5461 |
NPEvent pluginEvent; |
| 5462 |
NPImageExpose imageExpose; |
| 5463 |
XGraphicsExposeEvent& exposeEvent = pluginEvent.xgraphicsexpose; |
| 5464 |
// set the drawing info |
| 5465 |
exposeEvent.type = GraphicsExpose; |
| 5466 |
exposeEvent.display = 0; |
| 5467 |
// Store imageExpose structure pointer as drawable member |
| 5468 |
exposeEvent.drawable = (Drawable)&imageExpose; |
| 5469 |
exposeEvent.x = mDirtyRect.x; |
| 5470 |
exposeEvent.y = mDirtyRect.y; |
| 5471 |
exposeEvent.width = mDirtyRect.width; |
| 5472 |
exposeEvent.height = mDirtyRect.height; |
| 5473 |
exposeEvent.count = 0; |
| 5474 |
// information not set: |
| 5475 |
exposeEvent.serial = 0; |
| 5476 |
exposeEvent.send_event = False; |
| 5477 |
exposeEvent.major_code = 0; |
| 5478 |
exposeEvent.minor_code = 0; |
| 5479 |
|
| 5480 |
// Calculate src buffer pointer according to translation |
| 5481 |
// and set it as drawable member |
| 5482 |
gfxMatrix matr = aContext->CurrentMatrix(); |
| 5483 |
gfxPoint pt = matr.GetTranslation(); |
| 5484 |
imageExpose.depth = surfaceDepth; |
| 5485 |
imageExpose.x = mDirtyRect.x; |
| 5486 |
imageExpose.y = mDirtyRect.y; |
| 5487 |
imageExpose.width = mDirtyRect.width; |
| 5488 |
imageExpose.height = mDirtyRect.height; |
| 5489 |
// Setup temporary context scaled size |
| 5490 |
imageExpose.stride = surface->Stride(); |
| 5491 |
imageExpose.data = (char *)surface->Data(); |
| 5492 |
imageExpose.dataSize.width = surface->Width(); |
| 5493 |
imageExpose.dataSize.height = surface->Height(); |
| 5494 |
imageExpose.translateX = pt.x; |
| 5495 |
imageExpose.translateY = pt.y; |
| 5496 |
imageExpose.scaleX = matr.xx; |
| 5497 |
imageExpose.scaleY = matr.yy; |
| 5498 |
PRBool eventHandled = PR_FALSE; |
| 5499 |
// Get Image surface from original context |
| 5500 |
// Draw plugin content to temp surface |
| 5501 |
mInstance->HandleEvent(&pluginEvent, &eventHandled); |
| 5502 |
return NS_OK; |
| 5503 |
} |
| 5504 |
#endif |
| 5505 |
|
| 5370 |
#if defined(MOZ_WIDGET_GTK2) |
5506 |
#if defined(MOZ_WIDGET_GTK2) |
| 5371 |
nsresult |
5507 |
nsresult |
| 5372 |
nsPluginInstanceOwner::Renderer::NativeDraw(GdkDrawable * drawable, |
5508 |
nsPluginInstanceOwner::Renderer::NativeDraw(GdkDrawable * drawable, |
| 5373 |
short offsetX, short offsetY, |
5509 |
short offsetX, short offsetY, |
| 5374 |
GdkRectangle * clipRects, |
5510 |
GdkRectangle * clipRects, |