gfx/layers/basic/BasicLayersImpl.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/layers/basic/BasicLayersImpl.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,148 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef GFX_BASICLAYERSIMPL_H
    1.10 +#define GFX_BASICLAYERSIMPL_H
    1.11 +
    1.12 +#include "BasicImplData.h"              // for BasicImplData
    1.13 +#include "BasicLayers.h"                // for BasicLayerManager
    1.14 +#include "ReadbackLayer.h"              // for ReadbackLayer
    1.15 +#include "gfxContext.h"                 // for gfxContext, etc
    1.16 +#include "mozilla/Attributes.h"         // for MOZ_DELETE, MOZ_STACK_CLASS
    1.17 +#include "mozilla/Maybe.h"              // for Maybe
    1.18 +#include "nsAutoPtr.h"                  // for nsRefPtr
    1.19 +#include "nsDebug.h"                    // for NS_ASSERTION
    1.20 +#include "nsISupportsImpl.h"            // for gfxContext::Release, etc
    1.21 +#include "nsRegion.h"                   // for nsIntRegion
    1.22 +
    1.23 +namespace mozilla {
    1.24 +namespace gfx {
    1.25 +class DrawTarget;
    1.26 +}
    1.27 +
    1.28 +namespace layers {
    1.29 +
    1.30 +class AutoMoz2DMaskData;
    1.31 +class BasicContainerLayer;
    1.32 +class Layer;
    1.33 +
    1.34 +class AutoSetOperator {
    1.35 +public:
    1.36 +  AutoSetOperator(gfxContext* aContext, gfxContext::GraphicsOperator aOperator) {
    1.37 +    if (aOperator != gfxContext::OPERATOR_OVER) {
    1.38 +      aContext->SetOperator(aOperator);
    1.39 +      mContext = aContext;
    1.40 +    }
    1.41 +  }
    1.42 +  ~AutoSetOperator() {
    1.43 +    if (mContext) {
    1.44 +      mContext->SetOperator(gfxContext::OPERATOR_OVER);
    1.45 +    }
    1.46 +  }
    1.47 +private:
    1.48 +  nsRefPtr<gfxContext> mContext;
    1.49 +};
    1.50 +
    1.51 +class BasicReadbackLayer : public ReadbackLayer,
    1.52 +                           public BasicImplData
    1.53 +{
    1.54 +public:
    1.55 +  BasicReadbackLayer(BasicLayerManager* aLayerManager) :
    1.56 +    ReadbackLayer(aLayerManager,
    1.57 +                  static_cast<BasicImplData*>(MOZ_THIS_IN_INITIALIZER_LIST()))
    1.58 +  {
    1.59 +    MOZ_COUNT_CTOR(BasicReadbackLayer);
    1.60 +  }
    1.61 +  virtual ~BasicReadbackLayer()
    1.62 +  {
    1.63 +    MOZ_COUNT_DTOR(BasicReadbackLayer);
    1.64 +  }
    1.65 +
    1.66 +  virtual void SetVisibleRegion(const nsIntRegion& aRegion)
    1.67 +  {
    1.68 +    NS_ASSERTION(BasicManager()->InConstruction(),
    1.69 +                 "Can only set properties in construction phase");
    1.70 +    ReadbackLayer::SetVisibleRegion(aRegion);
    1.71 +  }
    1.72 +
    1.73 +protected:
    1.74 +  BasicLayerManager* BasicManager()
    1.75 +  {
    1.76 +    return static_cast<BasicLayerManager*>(mManager);
    1.77 +  }
    1.78 +};
    1.79 +
    1.80 +/*
    1.81 + * Extract a mask surface for a mask layer
    1.82 + * Returns true and through outparams a surface for the mask layer if
    1.83 + * a mask layer is present and has a valid surface and transform;
    1.84 + * false otherwise.
    1.85 + * The transform for the layer will be put in aMaskData
    1.86 + */
    1.87 +bool
    1.88 +GetMaskData(Layer* aMaskLayer,
    1.89 +            const gfx::Point& aDeviceOffset,
    1.90 +            AutoMoz2DMaskData* aMaskData);
    1.91 +
    1.92 +// Paint the current source to a context using a mask, if present
    1.93 +void
    1.94 +PaintWithMask(gfxContext* aContext, float aOpacity, Layer* aMaskLayer);
    1.95 +
    1.96 +// Fill the rect with the source, using a mask and opacity, if present
    1.97 +void
    1.98 +FillRectWithMask(gfx::DrawTarget* aDT,
    1.99 +                 const gfx::Rect& aRect,
   1.100 +                 const gfx::Color& aColor,
   1.101 +                 const gfx::DrawOptions& aOptions,
   1.102 +                 gfx::SourceSurface* aMaskSource = nullptr,
   1.103 +                 const gfx::Matrix* aMaskTransform = nullptr);
   1.104 +void
   1.105 +FillRectWithMask(gfx::DrawTarget* aDT,
   1.106 +                 const gfx::Rect& aRect,
   1.107 +                 gfx::SourceSurface* aSurface,
   1.108 +                 gfx::Filter aFilter,
   1.109 +                 const gfx::DrawOptions& aOptions,
   1.110 +                 gfx::ExtendMode aExtendMode,
   1.111 +                 gfx::SourceSurface* aMaskSource = nullptr,
   1.112 +                 const gfx::Matrix* aMaskTransform = nullptr,
   1.113 +                 const gfx::Matrix* aSurfaceTransform = nullptr);
   1.114 +void
   1.115 +FillRectWithMask(gfx::DrawTarget* aDT,
   1.116 +                 const gfx::Point& aDeviceOffset,
   1.117 +                 const gfx::Rect& aRect,
   1.118 +                 gfx::SourceSurface* aSurface,
   1.119 +                 gfx::Filter aFilter,
   1.120 +                 const gfx::DrawOptions& aOptions,
   1.121 +                 Layer* aMaskLayer);
   1.122 +void
   1.123 +FillRectWithMask(gfx::DrawTarget* aDT,
   1.124 +                 const gfx::Point& aDeviceOffset,
   1.125 +                 const gfx::Rect& aRect,
   1.126 +                 const gfx::Color& aColor,
   1.127 +                 const gfx::DrawOptions& aOptions,
   1.128 +                 Layer* aMaskLayer);
   1.129 +
   1.130 +BasicImplData*
   1.131 +ToData(Layer* aLayer);
   1.132 +
   1.133 +/**
   1.134 + * Returns the operator to be used when blending and compositing this layer.
   1.135 + * Currently there is no way to specify both a blending and a compositing
   1.136 + * operator other than normal and source over respectively.
   1.137 + *
   1.138 + * If the layer has
   1.139 + * an effective blend mode operator other than normal, as returned by
   1.140 + * GetEffectiveMixBlendMode, this operator is used for blending, and source
   1.141 + * over is used for compositing.
   1.142 + * If the blend mode for this layer is normal, the compositing operator
   1.143 + * returned by GetOperator is used.
   1.144 + */
   1.145 +gfx::CompositionOp
   1.146 +GetEffectiveOperator(Layer* aLayer);
   1.147 +
   1.148 +}
   1.149 +}
   1.150 +
   1.151 +#endif

mercurial