gfx/layers/d3d9/CompositorD3D9.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef MOZILLA_GFX_COMPOSITORD3D9_H
     7 #define MOZILLA_GFX_COMPOSITORD3D9_H
     9 #include "mozilla/gfx/2D.h"
    10 #include "gfx2DGlue.h"
    11 #include "mozilla/layers/Compositor.h"
    12 #include "mozilla/layers/TextureD3D9.h"
    13 #include "DeviceManagerD3D9.h"
    15 class nsWidget;
    17 namespace mozilla {
    18 namespace layers {
    20 class CompositorD3D9 : public Compositor
    21 {
    22 public:
    23   CompositorD3D9(PCompositorParent* aParent, nsIWidget *aWidget);
    24   ~CompositorD3D9();
    26   virtual bool Initialize() MOZ_OVERRIDE;
    27   virtual void Destroy() MOZ_OVERRIDE {}
    29   virtual TextureFactoryIdentifier
    30     GetTextureFactoryIdentifier() MOZ_OVERRIDE;
    32   virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE;
    33   virtual int32_t GetMaxTextureSize() const MOZ_FINAL;
    35   virtual void SetTargetContext(gfx::DrawTarget *aTarget) MOZ_OVERRIDE
    36   {
    37     mTarget = aTarget;
    38   }
    40   virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE {}
    42   virtual TemporaryRef<CompositingRenderTarget>
    43     CreateRenderTarget(const gfx::IntRect &aRect,
    44                        SurfaceInitMode aInit) MOZ_OVERRIDE;
    46   virtual TemporaryRef<CompositingRenderTarget>
    47     CreateRenderTargetFromSource(const gfx::IntRect &aRect,
    48                                  const CompositingRenderTarget *aSource,
    49                                  const gfx::IntPoint &aSourcePoint) MOZ_OVERRIDE;
    51   virtual void SetRenderTarget(CompositingRenderTarget *aSurface);
    52   virtual CompositingRenderTarget* GetCurrentRenderTarget() const MOZ_OVERRIDE
    53   {
    54     return mCurrentRT;
    55   }
    57   virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) MOZ_OVERRIDE {}
    59   virtual void ClearRect(const gfx::Rect& aRect) MOZ_OVERRIDE;
    61   virtual void DrawQuad(const gfx::Rect &aRect,
    62                         const gfx::Rect &aClipRect,
    63                         const EffectChain &aEffectChain,
    64                         gfx::Float aOpacity,
    65                         const gfx::Matrix4x4 &aTransform) MOZ_OVERRIDE;
    67   virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
    68                           const gfx::Rect *aClipRectIn,
    69                           const gfx::Matrix& aTransform,
    70                           const gfx::Rect& aRenderBounds,
    71                           gfx::Rect *aClipRectOut = nullptr,
    72                           gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;
    74   virtual void EndFrame() MOZ_OVERRIDE;
    76   virtual void EndFrameForExternalComposition(const gfx::Matrix& aTransform) MOZ_OVERRIDE {}
    78   virtual void AbortFrame() MOZ_OVERRIDE {}
    80   virtual void PrepareViewport(const gfx::IntSize& aSize,
    81                                const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE;
    83   virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE{ return true; }
    85 #ifdef MOZ_DUMP_PAINTING
    86   virtual const char* Name() const MOZ_OVERRIDE { return "Direct3D9"; }
    87 #endif
    89   virtual LayersBackend GetBackendType() const MOZ_OVERRIDE {
    90     return LayersBackend::LAYERS_D3D9;
    91   }
    93   virtual nsIWidget* GetWidget() const MOZ_OVERRIDE { return mWidget; }
    95   IDirect3DDevice9* device() const
    96   {
    97     return mDeviceManager
    98            ? mDeviceManager->device()
    99            : nullptr;
   100   }
   102   /**
   103    * Returns true if the Compositor is ready to go.
   104    * D3D9 devices can be awkward and there is a bunch of logic around
   105    * resetting/recreating devices and swap chains. That is handled by this method.
   106    * If we don't have a device and swap chain ready for rendering, we will return
   107    * false and if necessary destroy the device and/or swap chain. We will also
   108    * schedule another composite so we get another go at rendering, thus we shouldn't
   109    * miss a composite due to re-creating a device.
   110    */
   111   virtual bool Ready() MOZ_OVERRIDE;
   113   /**
   114    * Declare an offset to use when rendering layers. This will be ignored when
   115    * rendering to a target instead of the screen.
   116    */
   117   virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) MOZ_OVERRIDE
   118   {
   119     if (aOffset.x || aOffset.y) {
   120       NS_RUNTIMEABORT("SetScreenRenderOffset not supported by CompositorD3D9.");
   121     }
   122     // If the offset is 0, 0 that's okay.
   123   }
   125   virtual TemporaryRef<DataTextureSource>
   126     CreateDataTextureSource(TextureFlags aFlags = 0) MOZ_OVERRIDE;
   127 private:
   128   // ensure mSize is up to date with respect to mWidget
   129   void EnsureSize();
   130   void SetSamplerForFilter(gfx::Filter aFilter);
   131   void PaintToTarget();
   132   void SetMask(const EffectChain &aEffectChain, uint32_t aMaskTexture);
   133   /**
   134    * Ensure we have a swap chain and it is ready for rendering.
   135    * Requires mDeviceManger to be non-null.
   136    * Returns true if we have a working swap chain; false otherwise.
   137    * If we cannot create or validate the swap chain due to a bad device manager,
   138    * then the device will be destroyed and set mDeviceManager to null. We will
   139    * schedule another composite if it is a good idea to try again or we need to
   140    * recreate the device.
   141    */
   142   bool EnsureSwapChain();
   144   /**
   145    * DeviceManagerD3D9 keeps a count of the number of times its device is
   146    * reset or recreated. We keep a parallel count (mDeviceResetCount). It
   147    * is possible that we miss a reset if it is 'caused' by another
   148    * compositor (for another window). In which case we need to invalidate
   149    * everything and render it all. This method checks the reset counts
   150    * match and if not invalidates everything (a long comment on that in
   151    * the cpp file).
   152    */
   153   void CheckResetCount();
   155   void ReportFailure(const nsACString &aMsg, HRESULT aCode);
   157   virtual gfx::IntSize GetWidgetSize() const MOZ_OVERRIDE
   158   {
   159     return gfx::ToIntSize(mSize);
   160   }
   162   /* Device manager instance for this compositor */
   163   nsRefPtr<DeviceManagerD3D9> mDeviceManager;
   165   /* Swap chain associated with this compositor */
   166   nsRefPtr<SwapChainD3D9> mSwapChain;
   168   /* Widget associated with this layer manager */
   169   nsIWidget *mWidget;
   171   /*
   172    * Context target, nullptr when drawing directly to our swap chain.
   173    */
   174   RefPtr<gfx::DrawTarget> mTarget;
   176   RefPtr<CompositingRenderTargetD3D9> mDefaultRT;
   177   RefPtr<CompositingRenderTargetD3D9> mCurrentRT;
   179   nsIntSize mSize;
   181   uint32_t mDeviceResetCount;
   182 };
   184 }
   185 }
   187 #endif

mercurial