|
|
|
|
| 41 |
|
41 |
|
| 42 |
#include "BrowserStreamParent.h" |
42 |
#include "BrowserStreamParent.h" |
| 43 |
#include "PluginModuleParent.h" |
43 |
#include "PluginModuleParent.h" |
| 44 |
#include "PluginStreamParent.h" |
44 |
#include "PluginStreamParent.h" |
| 45 |
#include "StreamNotifyParent.h" |
45 |
#include "StreamNotifyParent.h" |
| 46 |
#include "npfunctions.h" |
46 |
#include "npfunctions.h" |
| 47 |
#include "nsAutoPtr.h" |
47 |
#include "nsAutoPtr.h" |
| 48 |
#include "mozilla/unused.h" |
48 |
#include "mozilla/unused.h" |
|
|
49 |
#include "gfxContext.h" |
| 50 |
#include "gfxImageSurface.h" |
| 51 |
#include "gfxSharedImageSurface.h" |
| 52 |
|
| 53 |
static bool sNoClearTransPluginBuffer = getenv("MOZ_NO_CLEAR_PLUGIN_BUFFER") ? PR_TRUE : PR_FALSE; |
| 49 |
|
54 |
|
| 50 |
#if defined(OS_WIN) |
55 |
#if defined(OS_WIN) |
| 51 |
#include <windowsx.h> |
56 |
#include <windowsx.h> |
| 52 |
|
57 |
|
| 53 |
// Plugin focus event for widget. |
58 |
// Plugin focus event for widget. |
| 54 |
extern const PRUnichar* kOOPPPluginFocusEventId; |
59 |
extern const PRUnichar* kOOPPPluginFocusEventId; |
| 55 |
UINT gOOPPPluginFocusEvent = |
60 |
UINT gOOPPPluginFocusEvent = |
| 56 |
RegisterWindowMessage(kOOPPPluginFocusEventId); |
61 |
RegisterWindowMessage(kOOPPPluginFocusEventId); |
|
Lines 82-97
PluginInstanceParent::PluginInstancePare
|
Link Here
|
|---|
|
| 82 |
, mQuirks(0) |
87 |
, mQuirks(0) |
| 83 |
#if defined(XP_MACOSX) |
88 |
#if defined(XP_MACOSX) |
| 84 |
, mShWidth(0) |
89 |
, mShWidth(0) |
| 85 |
, mShHeight(0) |
90 |
, mShHeight(0) |
| 86 |
, mShColorSpace(nsnull) |
91 |
, mShColorSpace(nsnull) |
| 87 |
, mDrawingModel(NPDrawingModelCoreGraphics) |
92 |
, mDrawingModel(NPDrawingModelCoreGraphics) |
| 88 |
, mIOSurface(nsnull) |
93 |
, mIOSurface(nsnull) |
| 89 |
#endif |
94 |
#endif |
|
|
95 |
, mWinSize(0, 0) |
| 96 |
, mSharedImage(nsnull) |
| 97 |
, mIsTransparent(false) |
| 90 |
{ |
98 |
{ |
| 91 |
InitQuirksModes(aMimeType); |
99 |
InitQuirksModes(aMimeType); |
| 92 |
} |
100 |
} |
| 93 |
|
101 |
|
| 94 |
void |
102 |
void |
| 95 |
PluginInstanceParent::InitQuirksModes(const nsCString& aMimeType) |
103 |
PluginInstanceParent::InitQuirksModes(const nsCString& aMimeType) |
| 96 |
{ |
104 |
{ |
| 97 |
#ifdef OS_MACOSX |
105 |
#ifdef OS_MACOSX |
|
Lines 324-339
PluginInstanceParent::AnswerNPN_SetValue
|
Link Here
|
|---|
|
| 324 |
return true; |
332 |
return true; |
| 325 |
} |
333 |
} |
| 326 |
|
334 |
|
| 327 |
bool |
335 |
bool |
| 328 |
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginTransparent( |
336 |
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginTransparent( |
| 329 |
const bool& transparent, NPError* result) |
337 |
const bool& transparent, NPError* result) |
| 330 |
{ |
338 |
{ |
| 331 |
NPBool isTransparent = transparent; |
339 |
NPBool isTransparent = transparent; |
|
|
340 |
mIsTransparent = transparent; |
| 332 |
*result = mNPNIface->setvalue(mNPP, NPPVpluginTransparentBool, |
341 |
*result = mNPNIface->setvalue(mNPP, NPPVpluginTransparentBool, |
| 333 |
(void*)isTransparent); |
342 |
(void*)isTransparent); |
| 334 |
return true; |
343 |
return true; |
| 335 |
} |
344 |
} |
| 336 |
|
345 |
|
| 337 |
bool |
346 |
bool |
| 338 |
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel( |
347 |
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel( |
| 339 |
const int& drawingModel, NPError* result) |
348 |
const int& drawingModel, NPError* result) |
|
Lines 524-539
PluginInstanceParent::NPP_SetWindow(cons
|
Link Here
|
|---|
|
| 524 |
} |
533 |
} |
| 525 |
#endif |
534 |
#endif |
| 526 |
|
535 |
|
| 527 |
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX) |
536 |
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX) |
| 528 |
const NPSetWindowCallbackStruct* ws_info = |
537 |
const NPSetWindowCallbackStruct* ws_info = |
| 529 |
static_cast<NPSetWindowCallbackStruct*>(aWindow->ws_info); |
538 |
static_cast<NPSetWindowCallbackStruct*>(aWindow->ws_info); |
| 530 |
window.visualID = ws_info->visual ? ws_info->visual->visualid : None; |
539 |
window.visualID = ws_info->visual ? ws_info->visual->visualid : None; |
| 531 |
window.colormap = ws_info->colormap; |
540 |
window.colormap = ws_info->colormap; |
|
|
541 |
mWinSize.width = window.width; |
| 542 |
mWinSize.height = window.height; |
| 532 |
#endif |
543 |
#endif |
| 533 |
|
544 |
|
| 534 |
if (!CallNPP_SetWindow(window)) |
545 |
if (!CallNPP_SetWindow(window)) |
| 535 |
return NPERR_GENERIC_ERROR; |
546 |
return NPERR_GENERIC_ERROR; |
| 536 |
|
547 |
|
| 537 |
return NPERR_NO_ERROR; |
548 |
return NPERR_NO_ERROR; |
| 538 |
} |
549 |
} |
| 539 |
|
550 |
|
|
Lines 554-569
PluginInstanceParent::NPP_GetValue(NPPVa
|
Link Here
|
|---|
|
| 554 |
|
565 |
|
| 555 |
if (NPERR_NO_ERROR != rv) { |
566 |
if (NPERR_NO_ERROR != rv) { |
| 556 |
return rv; |
567 |
return rv; |
| 557 |
} |
568 |
} |
| 558 |
|
569 |
|
| 559 |
(*(NPBool*)_retval) = needsXEmbed; |
570 |
(*(NPBool*)_retval) = needsXEmbed; |
| 560 |
return NPERR_NO_ERROR; |
571 |
return NPERR_NO_ERROR; |
| 561 |
} |
572 |
} |
|
|
573 |
|
| 574 |
case NPPVpluginWindowlessLocalBool: { |
| 575 |
bool winlessLocal; |
| 576 |
NPError rv; |
| 577 |
|
| 578 |
if (!CallNPP_GetValue_NPPVpluginWindowlessLocalBool(&winlessLocal, &rv)) { |
| 579 |
return NPERR_GENERIC_ERROR; |
| 580 |
} |
| 581 |
|
| 582 |
if (NPERR_NO_ERROR != rv) { |
| 583 |
return rv; |
| 584 |
} |
| 585 |
|
| 586 |
(*(NPBool*)_retval) = winlessLocal; |
| 587 |
return NPERR_NO_ERROR; |
| 588 |
} |
| 589 |
|
| 562 |
#endif |
590 |
#endif |
| 563 |
|
591 |
|
| 564 |
case NPPVpluginScriptableNPObject: { |
592 |
case NPPVpluginScriptableNPObject: { |
| 565 |
PPluginScriptableObjectParent* actor; |
593 |
PPluginScriptableObjectParent* actor; |
| 566 |
NPError rv; |
594 |
NPError rv; |
| 567 |
if (!CallNPP_GetValue_NPPVpluginScriptableNPObject(&actor, &rv)) { |
595 |
if (!CallNPP_GetValue_NPPVpluginScriptableNPObject(&actor, &rv)) { |
| 568 |
return NPERR_GENERIC_ERROR; |
596 |
return NPERR_GENERIC_ERROR; |
| 569 |
} |
597 |
} |
|
Lines 615-630
PluginInstanceParent::NPP_SetValue(NPNVa
|
Link Here
|
|---|
|
| 615 |
NS_ERROR("Unhandled NPNVariable in NPP_SetValue"); |
643 |
NS_ERROR("Unhandled NPNVariable in NPP_SetValue"); |
| 616 |
PR_LOG(gPluginLog, PR_LOG_WARNING, |
644 |
PR_LOG(gPluginLog, PR_LOG_WARNING, |
| 617 |
("In PluginInstanceParent::NPP_SetValue: Unhandled NPNVariable %i (%s)", |
645 |
("In PluginInstanceParent::NPP_SetValue: Unhandled NPNVariable %i (%s)", |
| 618 |
(int) variable, NPNVariableToString(variable))); |
646 |
(int) variable, NPNVariableToString(variable))); |
| 619 |
return NPERR_GENERIC_ERROR; |
647 |
return NPERR_GENERIC_ERROR; |
| 620 |
} |
648 |
} |
| 621 |
} |
649 |
} |
| 622 |
|
650 |
|
|
|
651 |
static inline gfxASurface::gfxImageFormat |
| 652 |
_depth_to_gfxFormat(int depth) |
| 653 |
{ |
| 654 |
switch (depth) { |
| 655 |
case 32: |
| 656 |
return gfxASurface::ImageFormatARGB32; |
| 657 |
case 24: |
| 658 |
return gfxASurface::ImageFormatRGB24; |
| 659 |
case 16: |
| 660 |
return gfxASurface::ImageFormatRGB16_565; |
| 661 |
default: |
| 662 |
return gfxASurface::ImageFormatUnknown; |
| 663 |
} |
| 664 |
} |
| 665 |
|
| 623 |
int16_t |
666 |
int16_t |
| 624 |
PluginInstanceParent::NPP_HandleEvent(void* event) |
667 |
PluginInstanceParent::NPP_HandleEvent(void* event) |
| 625 |
{ |
668 |
{ |
| 626 |
PLUGIN_LOG_DEBUG_FUNCTION; |
669 |
PLUGIN_LOG_DEBUG_FUNCTION; |
| 627 |
|
670 |
|
| 628 |
#if defined(XP_MACOSX) |
671 |
#if defined(XP_MACOSX) |
| 629 |
NPCocoaEvent* npevent = reinterpret_cast<NPCocoaEvent*>(event); |
672 |
NPCocoaEvent* npevent = reinterpret_cast<NPCocoaEvent*>(event); |
| 630 |
#else |
673 |
#else |
|
Lines 674-690
PluginInstanceParent::NPP_HandleEvent(vo
|
Link Here
|
|---|
|
| 674 |
// or not, just returning 1 for good hygiene |
717 |
// or not, just returning 1 for good hygiene |
| 675 |
return 1; |
718 |
return 1; |
| 676 |
} |
719 |
} |
| 677 |
break; |
720 |
break; |
| 678 |
} |
721 |
} |
| 679 |
} |
722 |
} |
| 680 |
#endif |
723 |
#endif |
| 681 |
|
724 |
|
| 682 |
#if defined(MOZ_X11) |
725 |
#if defined(MOZ_PLATFORM_MAEMO) |
|
|
726 |
if (npevent->type == GraphicsExpose && !npevent->xgraphicsexpose.display) { |
| 727 |
NPRemoteImageExpose npremoteimageexpose; |
| 728 |
// Take NPImageData structure from hacked XEvent drawable |
| 729 |
NPImageExpose *imgExp = (NPImageExpose*)npevent->xgraphicsexpose.drawable; |
| 730 |
npremoteimageexpose.image = *imgExp; |
| 731 |
// Plugin render stuff by using temporary surface |
| 732 |
NPRemoteImageExpose tempimgexpose; |
| 733 |
tempimgexpose.image = *imgExp; |
| 734 |
|
| 735 |
if (mIsTransparent) |
| 736 |
tempimgexpose.image.depth = 32; |
| 737 |
|
| 738 |
gfxASurface::gfxImageFormat fmt = _depth_to_gfxFormat(tempimgexpose.image.depth); |
| 739 |
|
| 740 |
if (!mSharedImage |
| 741 |
|| mSharedImage->Width() != mWinSize.width |
| 742 |
|| mSharedImage->Height() != mWinSize.height |
| 743 |
|| mSharedImage->Format() != fmt) { |
| 744 |
delete mSharedImage; |
| 745 |
mSharedImage = new gfxSharedImageSurface(this, mWinSize, fmt); |
| 746 |
} |
| 747 |
if (mIsTransparent && !sNoClearTransPluginBuffer) { |
| 748 |
// Fill transparent plugins surface |
| 749 |
nsRefPtr<gfxContext> ctx = new gfxContext(mSharedImage); |
| 750 |
ctx->SetOperator(gfxContext::OPERATOR_CLEAR); |
| 751 |
ctx->Rectangle(gfxRect(imgExp->x, imgExp->y, imgExp->width, imgExp->height)); |
| 752 |
ctx->Clip(); |
| 753 |
ctx->Fill(); |
| 754 |
} |
| 755 |
|
| 756 |
tempimgexpose.image.stride = mSharedImage->Stride(); |
| 757 |
tempimgexpose.image.dataSize.width = mSharedImage->Width(); |
| 758 |
tempimgexpose.image.dataSize.height = mSharedImage->Height(); |
| 759 |
tempimgexpose.image.translateX = 0; |
| 760 |
tempimgexpose.image.translateY = 0; |
| 761 |
tempimgexpose.image.scaleX = 1; |
| 762 |
tempimgexpose.image.scaleY = 1; |
| 763 |
Shmem imagemem = mSharedImage->GetShmem(); |
| 764 |
if (!CallNPP_ImageExpose_Shmem(tempimgexpose, imagemem, &handled)) { |
| 765 |
return false; // no good way to handle errors here... |
| 766 |
} |
| 767 |
// Get target gfx Context |
| 768 |
nsRefPtr<gfxImageSurface> surface = |
| 769 |
new gfxImageSurface((unsigned char*)imgExp->data, |
| 770 |
gfxIntSize(imgExp->dataSize.width, |
| 771 |
imgExp->dataSize.height), |
| 772 |
imgExp->stride, |
| 773 |
_depth_to_gfxFormat(imgExp->depth)); |
| 774 |
nsRefPtr<gfxContext> ctx = new gfxContext(surface); |
| 775 |
// Paint shm buffer to target surface |
| 776 |
ctx->SetOperator(mIsTransparent ? gfxContext::OPERATOR_OVER : gfxContext::OPERATOR_SOURCE); |
| 777 |
ctx->Translate(gfxPoint(imgExp->translateX, imgExp->translateY)); |
| 778 |
ctx->Scale(imgExp->scaleX, imgExp->scaleY); |
| 779 |
ctx->SetSource(mSharedImage); |
| 780 |
nsRefPtr<gfxPattern> pat = ctx->GetPattern(); |
| 781 |
pat->SetFilter(gfxPattern::FILTER_NEAREST); |
| 782 |
pat->SetExtend(gfxPattern::EXTEND_NONE); |
| 783 |
ctx->SetPattern(pat); |
| 784 |
ctx->Rectangle(gfxRect(imgExp->x, imgExp->y, imgExp->width, imgExp->height), PR_TRUE); |
| 785 |
ctx->Clip(); |
| 786 |
ctx->Paint(); |
| 787 |
return handled; |
| 788 |
} |
| 789 |
#endif |
| 790 |
|
| 791 |
#ifdef MOZ_X11 |
| 683 |
switch (npevent->type) { |
792 |
switch (npevent->type) { |
| 684 |
case GraphicsExpose: |
793 |
case GraphicsExpose: |
| 685 |
PLUGIN_LOG_DEBUG((" schlepping drawable 0x%lx across the pipe\n", |
794 |
PLUGIN_LOG_DEBUG((" schlepping drawable 0x%lx across the pipe\n", |
| 686 |
npevent->xgraphicsexpose.drawable)); |
795 |
npevent->xgraphicsexpose.drawable)); |
| 687 |
// Make sure the X server has created the Drawable and completes any |
796 |
// Make sure the X server has created the Drawable and completes any |
| 688 |
// drawing before the plugin draws on top. |
797 |
// drawing before the plugin draws on top. |
| 689 |
// |
798 |
// |
| 690 |
// XSync() waits for the X server to complete. Really this parent |
799 |
// XSync() waits for the X server to complete. Really this parent |