dom/plugins/ipc/PluginUtilsOSX.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:fbb356b5825d
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 // vim:set ts=2 sts=2 sw=2 et cin:
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef dom_plugins_PluginUtilsOSX_h
8 #define dom_plugins_PluginUtilsOSX_h 1
9
10 #include "npapi.h"
11 #include "mozilla/gfx/QuartzSupport.h"
12
13 struct nsIntRect;
14
15 namespace mozilla {
16 namespace plugins {
17 namespace PluginUtilsOSX {
18
19 // Need to call back into the browser's message loop to process event.
20 typedef void (*RemoteProcessEvents) (void*);
21
22 NPError ShowCocoaContextMenu(void* aMenu, int aX, int aY, void* pluginModule, RemoteProcessEvents remoteEvent);
23
24 void InvokeNativeEventLoop();
25
26 // Need to call back and send a cocoa draw event to the plugin.
27 typedef void (*DrawPluginFunc) (CGContextRef, void*, nsIntRect aUpdateRect);
28
29 void* GetCGLayer(DrawPluginFunc aFunc, void* aPluginInstance,
30 bool aAvoidCGCrashes, double aContentsScaleFactor);
31 void ReleaseCGLayer(void* cgLayer);
32 void Repaint(void* cgLayer, nsIntRect aRect);
33
34 bool SetProcessName(const char* aProcessName);
35
36 /*
37 * Provides a wrapper around nsCARenderer to manage double buffering
38 * without having to unbind nsCARenderer on every surface swaps.
39 *
40 * The double buffer renderer begins with no initialize surfaces.
41 * The buffers can be initialized and cleared individually.
42 * Swapping still occurs regardless if the buffers are initialized.
43 */
44 class nsDoubleBufferCARenderer {
45 public:
46 nsDoubleBufferCARenderer() : mCALayer(nullptr), mContentsScaleFactor(1.0) {}
47 // Returns width in "display pixels". A "display pixel" is the smallest
48 // fully addressable part of a display. But in HiDPI modes each "display
49 // pixel" corresponds to more than one device pixel. Multiply display pixels
50 // by mContentsScaleFactor to get device pixels.
51 size_t GetFrontSurfaceWidth();
52 // Returns height in "display pixels". Multiply by
53 // mContentsScaleFactor to get device pixels.
54 size_t GetFrontSurfaceHeight();
55 double GetFrontSurfaceContentsScaleFactor();
56 // Returns width in "display pixels". Multiply by
57 // mContentsScaleFactor to get device pixels.
58 size_t GetBackSurfaceWidth();
59 // Returns height in "display pixels". Multiply by
60 // mContentsScaleFactor to get device pixels.
61 size_t GetBackSurfaceHeight();
62 double GetBackSurfaceContentsScaleFactor();
63 IOSurfaceID GetFrontSurfaceID();
64
65 bool HasBackSurface();
66 bool HasFrontSurface();
67 bool HasCALayer();
68
69 void SetCALayer(void *aCALayer);
70 // aWidth and aHeight are in "display pixels". Multiply by
71 // aContentsScaleFactor to get device pixels.
72 bool InitFrontSurface(size_t aWidth, size_t aHeight,
73 double aContentsScaleFactor,
74 AllowOfflineRendererEnum aAllowOfflineRenderer);
75 void Render();
76 void SwapSurfaces();
77 void ClearFrontSurface();
78 void ClearBackSurface();
79
80 double GetContentsScaleFactor() { return mContentsScaleFactor; }
81
82 private:
83 void *mCALayer;
84 RefPtr<nsCARenderer> mCARenderer;
85 RefPtr<MacIOSurface> mFrontSurface;
86 RefPtr<MacIOSurface> mBackSurface;
87 double mContentsScaleFactor;
88 };
89
90 } // namespace PluginUtilsOSX
91 } // namespace plugins
92 } // namespace mozilla
93
94 #endif //dom_plugins_PluginUtilsOSX_h

mercurial