dom/plugins/ipc/PluginUtilsOSX.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/ipc/PluginUtilsOSX.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +// vim:set ts=2 sts=2 sw=2 et cin:
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef dom_plugins_PluginUtilsOSX_h
    1.11 +#define dom_plugins_PluginUtilsOSX_h 1
    1.12 +
    1.13 +#include "npapi.h"
    1.14 +#include "mozilla/gfx/QuartzSupport.h"
    1.15 +
    1.16 +struct nsIntRect;
    1.17 +
    1.18 +namespace mozilla {
    1.19 +namespace plugins {
    1.20 +namespace PluginUtilsOSX {
    1.21 +
    1.22 +// Need to call back into the browser's message loop to process event.
    1.23 +typedef void (*RemoteProcessEvents) (void*);
    1.24 +
    1.25 +NPError ShowCocoaContextMenu(void* aMenu, int aX, int aY, void* pluginModule, RemoteProcessEvents remoteEvent);
    1.26 +
    1.27 +void InvokeNativeEventLoop();
    1.28 +
    1.29 +// Need to call back and send a cocoa draw event to the plugin.
    1.30 +typedef void (*DrawPluginFunc) (CGContextRef, void*, nsIntRect aUpdateRect);
    1.31 +
    1.32 +void* GetCGLayer(DrawPluginFunc aFunc, void* aPluginInstance,
    1.33 +                 bool aAvoidCGCrashes, double aContentsScaleFactor);
    1.34 +void ReleaseCGLayer(void* cgLayer);
    1.35 +void Repaint(void* cgLayer, nsIntRect aRect);
    1.36 +
    1.37 +bool SetProcessName(const char* aProcessName);
    1.38 +
    1.39 +/*
    1.40 + * Provides a wrapper around nsCARenderer to manage double buffering
    1.41 + * without having to unbind nsCARenderer on every surface swaps.
    1.42 + *
    1.43 + * The double buffer renderer begins with no initialize surfaces.
    1.44 + * The buffers can be initialized and cleared individually.
    1.45 + * Swapping still occurs regardless if the buffers are initialized.
    1.46 + */
    1.47 +class nsDoubleBufferCARenderer {
    1.48 +public:
    1.49 +  nsDoubleBufferCARenderer() : mCALayer(nullptr), mContentsScaleFactor(1.0) {}
    1.50 +  // Returns width in "display pixels".  A "display pixel" is the smallest
    1.51 +  // fully addressable part of a display.  But in HiDPI modes each "display
    1.52 +  // pixel" corresponds to more than one device pixel.  Multiply display pixels
    1.53 +  // by mContentsScaleFactor to get device pixels.
    1.54 +  size_t GetFrontSurfaceWidth();
    1.55 +  // Returns height in "display pixels".  Multiply by
    1.56 +  // mContentsScaleFactor to get device pixels.
    1.57 +  size_t GetFrontSurfaceHeight();
    1.58 +  double GetFrontSurfaceContentsScaleFactor();
    1.59 +  // Returns width in "display pixels".  Multiply by
    1.60 +  // mContentsScaleFactor to get device pixels.
    1.61 +  size_t GetBackSurfaceWidth();
    1.62 +  // Returns height in "display pixels".  Multiply by
    1.63 +  // mContentsScaleFactor to get device pixels.
    1.64 +  size_t GetBackSurfaceHeight();
    1.65 +  double GetBackSurfaceContentsScaleFactor();
    1.66 +  IOSurfaceID GetFrontSurfaceID();
    1.67 +
    1.68 +  bool HasBackSurface();
    1.69 +  bool HasFrontSurface();
    1.70 +  bool HasCALayer();
    1.71 +
    1.72 +  void SetCALayer(void *aCALayer);
    1.73 +  // aWidth and aHeight are in "display pixels".  Multiply by
    1.74 +  // aContentsScaleFactor to get device pixels.
    1.75 +  bool InitFrontSurface(size_t aWidth, size_t aHeight,
    1.76 +                        double aContentsScaleFactor,
    1.77 +                        AllowOfflineRendererEnum aAllowOfflineRenderer);
    1.78 +  void Render();
    1.79 +  void SwapSurfaces();
    1.80 +  void ClearFrontSurface();
    1.81 +  void ClearBackSurface();
    1.82 +
    1.83 +  double GetContentsScaleFactor() { return mContentsScaleFactor; }
    1.84 +
    1.85 +private:
    1.86 +  void *mCALayer;
    1.87 +  RefPtr<nsCARenderer> mCARenderer;
    1.88 +  RefPtr<MacIOSurface> mFrontSurface;
    1.89 +  RefPtr<MacIOSurface> mBackSurface;
    1.90 +  double mContentsScaleFactor;
    1.91 +};
    1.92 +
    1.93 +} // namespace PluginUtilsOSX
    1.94 +} // namespace plugins
    1.95 +} // namespace mozilla
    1.96 +
    1.97 +#endif //dom_plugins_PluginUtilsOSX_h

mercurial