Attachment #443364: Here is small patch which is implementing old maemo 5 ImageExpose API by using new gfxSharedImageSurface structure... for bug #554270

View | Details | Raw Unified | Return to bug 554270
Collapse All | Expand All

(-)a/dom/plugins/Makefile.in (-1 / +3 lines)
Line     Link Here 
 Lines 57-72   EXPORTS_NAMESPACES = mozilla mozilla/plu Link Here 
57
EXPORTS_mozilla/plugins = \
57
EXPORTS_mozilla/plugins = \
58
  BrowserStreamChild.h \
58
  BrowserStreamChild.h \
59
  BrowserStreamParent.h \
59
  BrowserStreamParent.h \
60
  ChildAsyncCall.h \
60
  ChildAsyncCall.h \
61
  ChildTimer.h \
61
  ChildTimer.h \
62
  NPEventOSX.h \
62
  NPEventOSX.h \
63
  NPEventWindows.h \
63
  NPEventWindows.h \
64
  NPEventX11.h \
64
  NPEventX11.h \
65
  NPImageExpose.h \
66
  NPEventMem.h \
65
  PluginIdentifierChild.h \
67
  PluginIdentifierChild.h \
66
  PluginIdentifierParent.h \
68
  PluginIdentifierParent.h \
67
  PluginInstanceChild.h \
69
  PluginInstanceChild.h \
68
  PluginInstanceParent.h \
70
  PluginInstanceParent.h \
69
  PluginMessageUtils.h \
71
  PluginMessageUtils.h \
70
  PluginModuleChild.h \
72
  PluginModuleChild.h \
71
  PluginModuleParent.h \
73
  PluginModuleParent.h \
72
  PluginProcessParent.h \
74
  PluginProcessParent.h \
 Lines 119-129   LOCAL_INCLUDES = \ Link Here 
119
  $(NULL)
121
  $(NULL)
120
122
121
include $(topsrcdir)/config/config.mk
123
include $(topsrcdir)/config/config.mk
122
include $(topsrcdir)/ipc/chromium/chromium-config.mk
124
include $(topsrcdir)/ipc/chromium/chromium-config.mk
123
endif
125
endif
124
126
125
include $(topsrcdir)/config/rules.mk
127
include $(topsrcdir)/config/rules.mk
126
128
127
CXXFLAGS += $(TK_CFLAGS)
129
CXXFLAGS += $(TK_CFLAGS) $(MOZ_CAIRO_CFLAGS)
128
130
129
DEFINES += -DFORCE_PR_LOG
131
DEFINES += -DFORCE_PR_LOG
(-)70b5c9d044cb (+92 lines)
Added Link Here 
Added Link Here 
1
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */
2
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
3
/* ***** BEGIN LICENSE BLOCK *****
4
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version
7
 * 1.1 (the "License"); you may not use this file except in compliance with
8
 * the License. You may obtain a copy of the License at
9
 * http://www.mozilla.org/MPL/
10
 *
11
 * Software distributed under the License is distributed on an "AS IS" basis,
12
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
 * for the specific language governing rights and limitations under the
14
 * License.
15
 *
16
 * The Original Code is Mozilla Plugin App.
17
 *
18
 * The Initial Developer of the Original Code is
19
 *   The Mozilla Foundation.
20
 * Portions created by the Initial Developer are Copyright (C) 2010
21
 * the Initial Developer. All Rights Reserved.
22
 *
23
 * Contributor(s):
24
 *   Oleg Romashin <romaxa@gmail.com>
25
 *
26
 * Alternatively, the contents of this file may be used under the terms of
27
 * either the GNU General Public License Version 2 or later (the "GPL"), or
28
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
 * in which case the provisions of the GPL or the LGPL are applicable instead
30
 * of those above. If you wish to allow use of your version of this file only
31
 * under the terms of either the GPL or the LGPL, and not to allow others to
32
 * use your version of this file under the terms of the MPL, indicate your
33
 * decision by deleting the provisions above and replace them with the notice
34
 * and other provisions required by the GPL or the LGPL. If you do not delete
35
 * the provisions above, a recipient may use your version of this file under
36
 * the terms of any one of the MPL, the GPL or the LGPL.
37
 *
38
 * ***** END LICENSE BLOCK ***** */
39
40
#ifndef mozilla_dom_plugins_NPEventMem_h
41
#define mozilla_dom_plugins_NPEventMem_h 1
42
43
#include "npapi.h"
44
45
namespace mozilla {
46
47
namespace plugins {
48
49
struct NPRemoteMemEvent {
50
    NPImageData image;
51
};
52
53
}
54
55
}
56
57
namespace IPC {
58
59
template <>
60
struct ParamTraits<mozilla::plugins::NPRemoteMemEvent>     // synonym for XEvent
61
{
62
    typedef mozilla::plugins::NPRemoteMemEvent paramType;
63
64
    static void Write(Message* aMsg, const paramType& aParam)
65
    {
66
        aMsg->WriteBytes(&aParam, sizeof(paramType));
67
    }
68
69
    static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
70
    {
71
        const char* bytes = 0;
72
73
        if (!aMsg->ReadBytes(aIter, &bytes, sizeof(paramType))) {
74
            return false;
75
        }
76
77
        memcpy(aResult, bytes, sizeof(paramType));
78
        return true;
79
    }
80
81
    static void Log(const paramType& aParam, std::wstring* aLog)
82
    {
83
        // TODO
84
        aLog->append(L"(MemEvent)");
85
    }
86
87
};
88
89
} // namespace IPC
90
91
92
#endif // ifndef mozilla_dom_plugins_NPEventMem_h
(-)70b5c9d044cb (+92 lines)
Added Link Here 
Added Link Here 
1
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */
2
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
3
/* ***** BEGIN LICENSE BLOCK *****
4
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version
7
 * 1.1 (the "License"); you may not use this file except in compliance with
8
 * the License. You may obtain a copy of the License at
9
 * http://www.mozilla.org/MPL/
10
 *
11
 * Software distributed under the License is distributed on an "AS IS" basis,
12
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
 * for the specific language governing rights and limitations under the
14
 * License.
15
 *
16
 * The Original Code is Mozilla Plugin App.
17
 *
18
 * The Initial Developer of the Original Code is
19
 *   The Mozilla Foundation.
20
 * Portions created by the Initial Developer are Copyright (C) 2010
21
 * the Initial Developer. All Rights Reserved.
22
 *
23
 * Contributor(s):
24
 *   Oleg Romashin <romaxa@gmail.com>
25
 *
26
 * Alternatively, the contents of this file may be used under the terms of
27
 * either the GNU General Public License Version 2 or later (the "GPL"), or
28
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
 * in which case the provisions of the GPL or the LGPL are applicable instead
30
 * of those above. If you wish to allow use of your version of this file only
31
 * under the terms of either the GPL or the LGPL, and not to allow others to
32
 * use your version of this file under the terms of the MPL, indicate your
33
 * decision by deleting the provisions above and replace them with the notice
34
 * and other provisions required by the GPL or the LGPL. If you do not delete
35
 * the provisions above, a recipient may use your version of this file under
36
 * the terms of any one of the MPL, the GPL or the LGPL.
37
 *
38
 * ***** END LICENSE BLOCK ***** */
39
40
#ifndef mozilla_dom_plugins_NPImageExpose_h
41
#define mozilla_dom_plugins_NPImageExpose_h 1
42
43
#include "npapi.h"
44
45
namespace mozilla {
46
47
namespace plugins {
48
49
struct NPRemoteImageExpose {
50
    NPImageExpose image;
51
};
52
53
}
54
55
}
56
57
namespace IPC {
58
59
template <>
60
struct ParamTraits<mozilla::plugins::NPRemoteImageExpose>     // synonym for XEvent
61
{
62
    typedef mozilla::plugins::NPRemoteImageExpose paramType;
63
64
    static void Write(Message* aMsg, const paramType& aParam)
65
    {
66
        aMsg->WriteBytes(&aParam, sizeof(paramType));
67
    }
68
69
    static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
70
    {
71
        const char* bytes = 0;
72
73
        if (!aMsg->ReadBytes(aIter, &bytes, sizeof(paramType))) {
74
            return false;
75
        }
76
77
        memcpy(aResult, bytes, sizeof(paramType));
78
        return true;
79
    }
80
81
    static void Log(const paramType& aParam, std::wstring* aLog)
82
    {
83
        // TODO
84
        aLog->append(L"(MemEvent)");
85
    }
86
87
};
88
89
} // namespace IPC
90
91
92
#endif // ifndef mozilla_dom_plugins_NPImageExpose_h
(-)a/dom/plugins/PPluginInstance.ipdl (+7 lines)
Line     Link Here 
 Lines 43-58   include protocol PBrowserStream; Link Here 
43
include protocol PPluginStream;
43
include protocol PPluginStream;
44
include protocol PStreamNotify;
44
include protocol PStreamNotify;
45
45
46
include "mozilla/plugins/PluginMessageUtils.h";
46
include "mozilla/plugins/PluginMessageUtils.h";
47
47
48
using NPError;
48
using NPError;
49
using NPRemoteWindow;
49
using NPRemoteWindow;
50
using NPRemoteEvent;
50
using NPRemoteEvent;
51
using NPRemoteImageExpose;
52
using NPRemoteMemEvent;
51
using NPRect;
53
using NPRect;
52
using NPNURLVariable;
54
using NPNURLVariable;
53
using NPCoordinateSpace;
55
using NPCoordinateSpace;
54
using mozilla::plugins::NativeWindowHandle;
56
using mozilla::plugins::NativeWindowHandle;
55
57
56
namespace mozilla {
58
namespace mozilla {
57
namespace plugins {
59
namespace plugins {
58
60
 Lines 68-93   rpc protocol PPluginInstance Link Here 
68
child:
70
child:
69
  rpc __delete__();
71
  rpc __delete__();
70
72
71
  rpc NPP_SetWindow(NPRemoteWindow window);
73
  rpc NPP_SetWindow(NPRemoteWindow window);
72
74
73
  // this message is not used on non-X platforms
75
  // this message is not used on non-X platforms
74
  rpc NPP_GetValue_NPPVpluginNeedsXEmbed()
76
  rpc NPP_GetValue_NPPVpluginNeedsXEmbed()
75
    returns (bool value, NPError result);
77
    returns (bool value, NPError result);
78
  rpc NPP_GetValue_NPPVpluginWindowlessLocalBool()
79
    returns (bool value, NPError result);
76
  rpc NPP_GetValue_NPPVpluginScriptableNPObject()
80
  rpc NPP_GetValue_NPPVpluginScriptableNPObject()
77
    returns (nullable PPluginScriptableObject value, NPError result);
81
    returns (nullable PPluginScriptableObject value, NPError result);
78
82
79
  rpc NPP_SetValue_NPNVprivateModeBool(bool value) returns (NPError result);
83
  rpc NPP_SetValue_NPNVprivateModeBool(bool value) returns (NPError result);
80
84
81
  rpc NPP_HandleEvent(NPRemoteEvent event)
85
  rpc NPP_HandleEvent(NPRemoteEvent event)
82
    returns (int16_t handled);
86
    returns (int16_t handled);
83
  // special cases where we need to a shared memory buffer
87
  // special cases where we need to a shared memory buffer
84
  rpc NPP_HandleEvent_Shmem(NPRemoteEvent event, Shmem buffer)
88
  rpc NPP_HandleEvent_Shmem(NPRemoteEvent event, Shmem buffer)
85
    returns (int16_t handled, Shmem rtnbuffer);
89
    returns (int16_t handled, Shmem rtnbuffer);
90
  // special cases where we need to a shared memory buffer maemo
91
  rpc NPP_ImageExpose_Shmem(NPRemoteImageExpose imageExpose, Shmem buffer)
92
    returns (int16_t handled);
86
  // special cases where we need an iosurface
93
  // special cases where we need an iosurface
87
  rpc NPP_HandleEvent_IOSurface(NPRemoteEvent event, uint32_t surfaceid)
94
  rpc NPP_HandleEvent_IOSurface(NPRemoteEvent event, uint32_t surfaceid)
88
    returns (int16_t handled);
95
    returns (int16_t handled);
89
  // special cases of HandleEvent to make mediating races simpler
96
  // special cases of HandleEvent to make mediating races simpler
90
  rpc Paint(NPRemoteEvent event)
97
  rpc Paint(NPRemoteEvent event)
91
    returns (int16_t handled);
98
    returns (int16_t handled);
92
  // this is only used on windows to forward WM_WINDOWPOSCHANGE
99
  // this is only used on windows to forward WM_WINDOWPOSCHANGE
93
  async WindowPosChanged(NPRemoteEvent event);
100
  async WindowPosChanged(NPRemoteEvent event);
(-)a/dom/plugins/PluginInstanceChild.cpp (+53 lines)
Line     Link Here 
 Lines 470-485   PluginInstanceChild::AnswerNPP_GetValue_ Link Here 
470
470
471
    NS_RUNTIMEABORT("shouldn't be called on non-X11 platforms");
471
    NS_RUNTIMEABORT("shouldn't be called on non-X11 platforms");
472
    return false;               // not reached
472
    return false;               // not reached
473
473
474
#endif
474
#endif
475
}
475
}
476
476
477
bool
477
bool
478
PluginInstanceChild::AnswerNPP_GetValue_NPPVpluginWindowlessLocalBool(
479
    bool* needs, NPError* rv)
480
{
481
    AssertPluginThread();
482
483
    PRBool winlessLocal = 0;
484
    if (!mPluginIface->getvalue) {
485
        *rv = NPERR_GENERIC_ERROR;
486
    }
487
    else {
488
        *rv = mPluginIface->getvalue(GetNPP(), NPPVpluginWindowlessLocalBool,
489
                                     &winlessLocal);
490
    }
491
    *needs = winlessLocal;
492
    return true;
493
}
494
495
bool
478
PluginInstanceChild::AnswerNPP_GetValue_NPPVpluginScriptableNPObject(
496
PluginInstanceChild::AnswerNPP_GetValue_NPPVpluginScriptableNPObject(
479
                                          PPluginScriptableObjectChild** aValue,
497
                                          PPluginScriptableObjectChild** aValue,
480
                                          NPError* aResult)
498
                                          NPError* aResult)
481
{
499
{
482
    AssertPluginThread();
500
    AssertPluginThread();
483
501
484
    NPObject* object = nsnull;
502
    NPObject* object = nsnull;
485
    NPError result = NPERR_GENERIC_ERROR;
503
    NPError result = NPERR_GENERIC_ERROR;
 Lines 665-680   PluginInstanceChild::AnswerNPP_HandleEve Link Here 
665
                                                 Shmem* rtnmem)
683
                                                 Shmem* rtnmem)
666
{
684
{
667
    NS_RUNTIMEABORT("not reached.");
685
    NS_RUNTIMEABORT("not reached.");
668
    *rtnmem = mem;
686
    *rtnmem = mem;
669
    return true;
687
    return true;
670
}
688
}
671
#endif
689
#endif
672
690
691
bool
692
PluginInstanceChild::AnswerNPP_ImageExpose_Shmem(const NPRemoteImageExpose& imageExposeMem,
693
                                                 Shmem& mem,
694
                                                 int16_t* handled)
695
{
696
    PLUGIN_LOG_DEBUG_FUNCTION;
697
    AssertPluginThread();
698
699
    NPImageExpose imageExpose = imageExposeMem.image;
700
    imageExpose.data = (char*)mem.get<char>();
701
702
    NPEvent pluginEvent;
703
    XGraphicsExposeEvent& exposeEvent = pluginEvent.xgraphicsexpose;
704
    exposeEvent.type = GraphicsExpose;
705
    exposeEvent.display = 0;
706
    // Store imageExpose structure pointer as drawable member
707
    exposeEvent.drawable = (Drawable)&imageExpose;
708
    exposeEvent.x = imageExpose.x;
709
    exposeEvent.y = imageExpose.y;
710
    exposeEvent.width = imageExpose.width;
711
    exposeEvent.height = imageExpose.height;
712
    exposeEvent.count = 0;
713
    // information not set:
714
    exposeEvent.serial = 0;
715
    exposeEvent.send_event = False;
716
    exposeEvent.major_code = 0;
717
    exposeEvent.minor_code = 0;
718
    if (!mPluginIface->event) {
719
        *handled = false;
720
    } else {
721
        *handled = mPluginIface->event(&mData, reinterpret_cast<void*>(&exposeEvent));
722
    }
723
    return true;
724
}
725
673
#ifdef XP_MACOSX
726
#ifdef XP_MACOSX
674
bool
727
bool
675
PluginInstanceChild::AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event,
728
PluginInstanceChild::AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event,
676
                                                     const uint32_t &surfaceid,
729
                                                     const uint32_t &surfaceid,
677
                                                     int16_t* handled)
730
                                                     int16_t* handled)
678
{
731
{
679
    PLUGIN_LOG_DEBUG_FUNCTION;
732
    PLUGIN_LOG_DEBUG_FUNCTION;
680
    AssertPluginThread();
733
    AssertPluginThread();
(-)a/dom/plugins/PluginInstanceChild.h (+7 lines)
Line     Link Here 
 Lines 77-104   class PluginInstanceChild : public PPlug Link Here 
77
                                             LPARAM lParam);
77
                                             LPARAM lParam);
78
#endif
78
#endif
79
79
80
protected:
80
protected:
81
    virtual bool AnswerNPP_SetWindow(const NPRemoteWindow& window);
81
    virtual bool AnswerNPP_SetWindow(const NPRemoteWindow& window);
82
82
83
    virtual bool
83
    virtual bool
84
    AnswerNPP_GetValue_NPPVpluginNeedsXEmbed(bool* needs, NPError* rv);
84
    AnswerNPP_GetValue_NPPVpluginNeedsXEmbed(bool* needs, NPError* rv);
85
86
    virtual bool
87
    AnswerNPP_GetValue_NPPVpluginWindowlessLocalBool(bool* needs, NPError* rv);
88
85
    virtual bool
89
    virtual bool
86
    AnswerNPP_GetValue_NPPVpluginScriptableNPObject(PPluginScriptableObjectChild** value,
90
    AnswerNPP_GetValue_NPPVpluginScriptableNPObject(PPluginScriptableObjectChild** value,
87
                                                    NPError* result);
91
                                                    NPError* result);
88
92
89
    virtual bool
93
    virtual bool
90
    AnswerNPP_SetValue_NPNVprivateModeBool(const bool& value, NPError* result);
94
    AnswerNPP_SetValue_NPNVprivateModeBool(const bool& value, NPError* result);
91
95
92
    virtual bool
96
    virtual bool
93
    AnswerNPP_HandleEvent(const NPRemoteEvent& event, int16_t* handled);
97
    AnswerNPP_HandleEvent(const NPRemoteEvent& event, int16_t* handled);
94
    virtual bool
98
    virtual bool
95
    AnswerNPP_HandleEvent_Shmem(const NPRemoteEvent& event, Shmem& mem, int16_t* handled, Shmem* rtnmem);
99
    AnswerNPP_HandleEvent_Shmem(const NPRemoteEvent& event, Shmem& mem, int16_t* handled, Shmem* rtnmem);
96
    virtual bool
100
    virtual bool
101
    AnswerNPP_ImageExpose_Shmem(const NPRemoteImageExpose& imageExpose, Shmem& mem,
102
                                int16_t* handled);
103
    virtual bool
97
    AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event, const uint32_t& surface, int16_t* handled);
104
    AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event, const uint32_t& surface, int16_t* handled);
98
105
99
    NS_OVERRIDE
106
    NS_OVERRIDE
100
    virtual bool
107
    virtual bool
101
    AnswerPaint(const NPRemoteEvent& event, int16_t* handled)
108
    AnswerPaint(const NPRemoteEvent& event, int16_t* handled)
102
    {
109
    {
103
        return AnswerNPP_HandleEvent(event, handled);
110
        return AnswerNPP_HandleEvent(event, handled);
104
    }
111
    }
(-)a/dom/plugins/PluginInstanceParent.cpp (-1 / +110 lines)
Line     Link Here 
 Lines 41-56    Link Here 
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
(-)a/dom/plugins/PluginInstanceParent.h (+6 lines)
Line     Link Here 
 Lines 48-63    Link Here 
48
#endif
48
#endif
49
49
50
#include "npfunctions.h"
50
#include "npfunctions.h"
51
#include "nsAutoPtr.h"
51
#include "nsAutoPtr.h"
52
#include "nsDataHashtable.h"
52
#include "nsDataHashtable.h"
53
#include "nsHashKeys.h"
53
#include "nsHashKeys.h"
54
#include "nsRect.h"
54
#include "nsRect.h"
55
55
56
class gfxSharedImageSurface;
57
56
namespace mozilla {
58
namespace mozilla {
57
namespace plugins {
59
namespace plugins {
58
60
59
class PBrowserStreamParent;
61
class PBrowserStreamParent;
60
class PluginModuleParent;
62
class PluginModuleParent;
61
63
62
class PluginInstanceParent : public PPluginInstanceParent
64
class PluginInstanceParent : public PPluginInstanceParent
63
{
65
{
 Lines 302-316   private: Link Here 
302
private:
304
private:
303
    Shmem              mShSurface; 
305
    Shmem              mShSurface; 
304
    size_t             mShWidth;
306
    size_t             mShWidth;
305
    size_t             mShHeight;
307
    size_t             mShHeight;
306
    CGColorSpaceRef    mShColorSpace;
308
    CGColorSpaceRef    mShColorSpace;
307
    int16_t            mDrawingModel;
309
    int16_t            mDrawingModel;
308
    nsIOSurface       *mIOSurface;
310
    nsIOSurface       *mIOSurface;
309
#endif // definied(OS_MACOSX)
311
#endif // definied(OS_MACOSX)
312
313
    gfxIntSize         mWinSize;
314
    gfxSharedImageSurface *mSharedImage;
315
    bool               mIsTransparent;
310
};
316
};
311
317
312
318
313
} // namespace plugins
319
} // namespace plugins
314
} // namespace mozilla
320
} // namespace mozilla
315
321
316
#endif // ifndef dom_plugins_PluginInstanceParent_h
322
#endif // ifndef dom_plugins_PluginInstanceParent_h
(-)a/dom/plugins/PluginMessageUtils.cpp (+1 lines)
Line     Link Here 
 Lines 82-97   namespace plugins { Link Here 
82
82
83
RPCChannel::RacyRPCPolicy
83
RPCChannel::RacyRPCPolicy
84
MediateRace(const RPCChannel::Message& parent,
84
MediateRace(const RPCChannel::Message& parent,
85
            const RPCChannel::Message& child)
85
            const RPCChannel::Message& child)
86
{
86
{
87
  switch (parent.type()) {
87
  switch (parent.type()) {
88
  case PPluginInstance::Msg_Paint__ID:
88
  case PPluginInstance::Msg_Paint__ID:
89
  case PPluginInstance::Msg_NPP_SetWindow__ID:
89
  case PPluginInstance::Msg_NPP_SetWindow__ID:
90
  case PPluginInstance::Msg_NPP_ImageExpose_Shmem__ID:
90
  case PPluginInstance::Msg_NPP_HandleEvent_Shmem__ID:
91
  case PPluginInstance::Msg_NPP_HandleEvent_Shmem__ID:
91
  case PPluginInstance::Msg_NPP_HandleEvent_IOSurface__ID:
92
  case PPluginInstance::Msg_NPP_HandleEvent_IOSurface__ID:
92
    // our code relies on the frame list not changing during paints and
93
    // our code relies on the frame list not changing during paints and
93
    // reflows
94
    // reflows
94
    return RPCChannel::RRPParentWins;
95
    return RPCChannel::RRPParentWins;
95
96
96
  default:
97
  default:
97
    return RPCChannel::RRPChildWins;
98
    return RPCChannel::RRPChildWins;
(-)a/dom/plugins/PluginMessageUtils.h (+4 lines)
Line     Link Here 
 Lines 174-189   NPPVariableToString(NPPVariable aVar) Link Here 
174
  
174
  
175
        VARSTR(NPPVpluginWantsAllNetworkStreams);
175
        VARSTR(NPPVpluginWantsAllNetworkStreams);
176
176
177
#ifdef XP_MACOSX
177
#ifdef XP_MACOSX
178
        VARSTR(NPPVpluginDrawingModel);
178
        VARSTR(NPPVpluginDrawingModel);
179
        VARSTR(NPPVpluginEventModel);
179
        VARSTR(NPPVpluginEventModel);
180
#endif
180
#endif
181
181
182
        VARSTR(NPPVpluginWindowlessLocalBool);
183
182
    default: return "???";
184
    default: return "???";
183
    }
185
    }
184
}
186
}
185
187
186
inline const char*
188
inline const char*
187
NPNVariableToString(NPNVariable aVar)
189
NPNVariableToString(NPNVariable aVar)
188
{
190
{
189
    switch(aVar) {
191
    switch(aVar) {
 Lines 781-796   struct ParamTraits<NPCoordinateSpace> Link Here 
781
783
782
784
783
// Serializing NPEvents is completely platform-specific and can be rather
785
// Serializing NPEvents is completely platform-specific and can be rather
784
// intricate depending on the platform.  So for readability we split it
786
// intricate depending on the platform.  So for readability we split it
785
// into separate files and have the only macro crud live here.
787
// into separate files and have the only macro crud live here.
786
// 
788
// 
787
// NB: these guards are based on those where struct NPEvent is defined
789
// NB: these guards are based on those where struct NPEvent is defined
788
// in npapi.h.  They should be kept in sync.
790
// in npapi.h.  They should be kept in sync.
791
#  include "mozilla/plugins/NPImageExpose.h"
792
#  include "mozilla/plugins/NPEventMem.h"
789
#if defined(XP_MACOSX)
793
#if defined(XP_MACOSX)
790
#  include "mozilla/plugins/NPEventOSX.h"
794
#  include "mozilla/plugins/NPEventOSX.h"
791
#elif defined(XP_WIN)
795
#elif defined(XP_WIN)
792
#  include "mozilla/plugins/NPEventWindows.h"
796
#  include "mozilla/plugins/NPEventWindows.h"
793
#elif defined(XP_OS2)
797
#elif defined(XP_OS2)
794
#  error Sorry, OS/2 is not supported
798
#  error Sorry, OS/2 is not supported
795
#elif defined(XP_UNIX) && defined(MOZ_X11)
799
#elif defined(XP_UNIX) && defined(MOZ_X11)
796
#  include "mozilla/plugins/NPEventX11.h"
800
#  include "mozilla/plugins/NPEventX11.h"

Return to bug 554270