gfx/layers/basic/BasicLayersImpl.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: 2; 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 GFX_BASICLAYERSIMPL_H
     7 #define GFX_BASICLAYERSIMPL_H
     9 #include "BasicImplData.h"              // for BasicImplData
    10 #include "BasicLayers.h"                // for BasicLayerManager
    11 #include "ReadbackLayer.h"              // for ReadbackLayer
    12 #include "gfxContext.h"                 // for gfxContext, etc
    13 #include "mozilla/Attributes.h"         // for MOZ_DELETE, MOZ_STACK_CLASS
    14 #include "mozilla/Maybe.h"              // for Maybe
    15 #include "nsAutoPtr.h"                  // for nsRefPtr
    16 #include "nsDebug.h"                    // for NS_ASSERTION
    17 #include "nsISupportsImpl.h"            // for gfxContext::Release, etc
    18 #include "nsRegion.h"                   // for nsIntRegion
    20 namespace mozilla {
    21 namespace gfx {
    22 class DrawTarget;
    23 }
    25 namespace layers {
    27 class AutoMoz2DMaskData;
    28 class BasicContainerLayer;
    29 class Layer;
    31 class AutoSetOperator {
    32 public:
    33   AutoSetOperator(gfxContext* aContext, gfxContext::GraphicsOperator aOperator) {
    34     if (aOperator != gfxContext::OPERATOR_OVER) {
    35       aContext->SetOperator(aOperator);
    36       mContext = aContext;
    37     }
    38   }
    39   ~AutoSetOperator() {
    40     if (mContext) {
    41       mContext->SetOperator(gfxContext::OPERATOR_OVER);
    42     }
    43   }
    44 private:
    45   nsRefPtr<gfxContext> mContext;
    46 };
    48 class BasicReadbackLayer : public ReadbackLayer,
    49                            public BasicImplData
    50 {
    51 public:
    52   BasicReadbackLayer(BasicLayerManager* aLayerManager) :
    53     ReadbackLayer(aLayerManager,
    54                   static_cast<BasicImplData*>(MOZ_THIS_IN_INITIALIZER_LIST()))
    55   {
    56     MOZ_COUNT_CTOR(BasicReadbackLayer);
    57   }
    58   virtual ~BasicReadbackLayer()
    59   {
    60     MOZ_COUNT_DTOR(BasicReadbackLayer);
    61   }
    63   virtual void SetVisibleRegion(const nsIntRegion& aRegion)
    64   {
    65     NS_ASSERTION(BasicManager()->InConstruction(),
    66                  "Can only set properties in construction phase");
    67     ReadbackLayer::SetVisibleRegion(aRegion);
    68   }
    70 protected:
    71   BasicLayerManager* BasicManager()
    72   {
    73     return static_cast<BasicLayerManager*>(mManager);
    74   }
    75 };
    77 /*
    78  * Extract a mask surface for a mask layer
    79  * Returns true and through outparams a surface for the mask layer if
    80  * a mask layer is present and has a valid surface and transform;
    81  * false otherwise.
    82  * The transform for the layer will be put in aMaskData
    83  */
    84 bool
    85 GetMaskData(Layer* aMaskLayer,
    86             const gfx::Point& aDeviceOffset,
    87             AutoMoz2DMaskData* aMaskData);
    89 // Paint the current source to a context using a mask, if present
    90 void
    91 PaintWithMask(gfxContext* aContext, float aOpacity, Layer* aMaskLayer);
    93 // Fill the rect with the source, using a mask and opacity, if present
    94 void
    95 FillRectWithMask(gfx::DrawTarget* aDT,
    96                  const gfx::Rect& aRect,
    97                  const gfx::Color& aColor,
    98                  const gfx::DrawOptions& aOptions,
    99                  gfx::SourceSurface* aMaskSource = nullptr,
   100                  const gfx::Matrix* aMaskTransform = nullptr);
   101 void
   102 FillRectWithMask(gfx::DrawTarget* aDT,
   103                  const gfx::Rect& aRect,
   104                  gfx::SourceSurface* aSurface,
   105                  gfx::Filter aFilter,
   106                  const gfx::DrawOptions& aOptions,
   107                  gfx::ExtendMode aExtendMode,
   108                  gfx::SourceSurface* aMaskSource = nullptr,
   109                  const gfx::Matrix* aMaskTransform = nullptr,
   110                  const gfx::Matrix* aSurfaceTransform = nullptr);
   111 void
   112 FillRectWithMask(gfx::DrawTarget* aDT,
   113                  const gfx::Point& aDeviceOffset,
   114                  const gfx::Rect& aRect,
   115                  gfx::SourceSurface* aSurface,
   116                  gfx::Filter aFilter,
   117                  const gfx::DrawOptions& aOptions,
   118                  Layer* aMaskLayer);
   119 void
   120 FillRectWithMask(gfx::DrawTarget* aDT,
   121                  const gfx::Point& aDeviceOffset,
   122                  const gfx::Rect& aRect,
   123                  const gfx::Color& aColor,
   124                  const gfx::DrawOptions& aOptions,
   125                  Layer* aMaskLayer);
   127 BasicImplData*
   128 ToData(Layer* aLayer);
   130 /**
   131  * Returns the operator to be used when blending and compositing this layer.
   132  * Currently there is no way to specify both a blending and a compositing
   133  * operator other than normal and source over respectively.
   134  *
   135  * If the layer has
   136  * an effective blend mode operator other than normal, as returned by
   137  * GetEffectiveMixBlendMode, this operator is used for blending, and source
   138  * over is used for compositing.
   139  * If the blend mode for this layer is normal, the compositing operator
   140  * returned by GetOperator is used.
   141  */
   142 gfx::CompositionOp
   143 GetEffectiveOperator(Layer* aLayer);
   145 }
   146 }
   148 #endif

mercurial