dom/plugins/ipc/PluginUtilsOSX.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial