2012-06-29 06:01:34 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef GFX_BASICLAYERSIMPL_H
|
|
|
|
#define GFX_BASICLAYERSIMPL_H
|
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "BasicImplData.h" // for BasicImplData
|
|
|
|
#include "BasicLayers.h" // for BasicLayerManager
|
|
|
|
#include "ReadbackLayer.h" // for ReadbackLayer
|
|
|
|
#include "gfxContext.h" // for gfxContext, etc
|
2015-01-06 23:35:02 +00:00
|
|
|
#include "mozilla/Attributes.h" // for MOZ_STACK_CLASS
|
2013-08-27 22:10:28 +00:00
|
|
|
#include "mozilla/Maybe.h" // for Maybe
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "nsDebug.h" // for NS_ASSERTION
|
|
|
|
#include "nsISupportsImpl.h" // for gfxContext::Release, etc
|
|
|
|
#include "nsRegion.h" // for nsIntRegion
|
2012-06-29 06:01:34 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2014-04-01 04:02:09 +00:00
|
|
|
namespace gfx {
|
|
|
|
class DrawTarget;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace gfx
|
2014-04-01 04:02:09 +00:00
|
|
|
|
2012-06-29 06:01:34 +00:00
|
|
|
namespace layers {
|
|
|
|
|
2014-04-01 04:02:09 +00:00
|
|
|
class AutoMoz2DMaskData;
|
2013-08-11 23:17:23 +00:00
|
|
|
class Layer;
|
2012-06-29 06:01:34 +00:00
|
|
|
|
|
|
|
class AutoSetOperator {
|
2015-09-25 05:38:58 +00:00
|
|
|
typedef mozilla::gfx::CompositionOp CompositionOp;
|
2012-06-29 06:01:34 +00:00
|
|
|
public:
|
2015-09-25 05:38:58 +00:00
|
|
|
AutoSetOperator(gfxContext* aContext, CompositionOp aOperator) {
|
|
|
|
if (aOperator != CompositionOp::OP_OVER) {
|
|
|
|
aContext->SetOp(aOperator);
|
2012-06-29 06:01:34 +00:00
|
|
|
mContext = aContext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~AutoSetOperator() {
|
|
|
|
if (mContext) {
|
2015-09-25 05:38:58 +00:00
|
|
|
mContext->SetOp(CompositionOp::OP_OVER);
|
2012-06-29 06:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxContext> mContext;
|
2012-06-29 06:01:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BasicReadbackLayer : public ReadbackLayer,
|
|
|
|
public BasicImplData
|
|
|
|
{
|
|
|
|
public:
|
2014-08-20 04:55:14 +00:00
|
|
|
explicit BasicReadbackLayer(BasicLayerManager* aLayerManager) :
|
2015-01-07 05:39:46 +00:00
|
|
|
ReadbackLayer(aLayerManager, static_cast<BasicImplData*>(this))
|
2012-06-29 06:01:34 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(BasicReadbackLayer);
|
|
|
|
}
|
2014-07-15 15:37:45 +00:00
|
|
|
|
|
|
|
protected:
|
2012-06-29 06:01:34 +00:00
|
|
|
virtual ~BasicReadbackLayer()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(BasicReadbackLayer);
|
|
|
|
}
|
|
|
|
|
2014-07-15 15:37:45 +00:00
|
|
|
public:
|
2015-11-29 07:07:55 +00:00
|
|
|
virtual void SetVisibleRegion(const LayerIntRegion& aRegion)
|
2012-06-29 06:01:34 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(BasicManager()->InConstruction(),
|
|
|
|
"Can only set properties in construction phase");
|
|
|
|
ReadbackLayer::SetVisibleRegion(aRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BasicLayerManager* BasicManager()
|
|
|
|
{
|
|
|
|
return static_cast<BasicLayerManager*>(mManager);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Extract a mask surface for a mask layer
|
2012-07-12 12:51:58 +00:00
|
|
|
* Returns true and through outparams a surface for the mask layer if
|
|
|
|
* a mask layer is present and has a valid surface and transform;
|
|
|
|
* false otherwise.
|
|
|
|
* The transform for the layer will be put in aMaskData
|
2012-06-29 06:01:34 +00:00
|
|
|
*/
|
2012-07-12 12:51:58 +00:00
|
|
|
bool
|
2014-05-12 00:31:27 +00:00
|
|
|
GetMaskData(Layer* aMaskLayer,
|
|
|
|
const gfx::Point& aDeviceOffset,
|
|
|
|
AutoMoz2DMaskData* aMaskData);
|
2012-06-29 06:01:34 +00:00
|
|
|
|
2015-11-11 15:15:39 +00:00
|
|
|
already_AddRefed<gfx::SourceSurface> GetMaskForLayer(Layer* aLayer, gfx::Matrix* aMaskTransform);
|
|
|
|
|
2012-06-29 06:01:34 +00:00
|
|
|
// Paint the current source to a context using a mask, if present
|
|
|
|
void
|
|
|
|
PaintWithMask(gfxContext* aContext, float aOpacity, Layer* aMaskLayer);
|
|
|
|
|
2014-04-01 04:02:09 +00:00
|
|
|
// Fill the rect with the source, using a mask and opacity, if present
|
|
|
|
void
|
2014-04-11 12:23:09 +00:00
|
|
|
FillRectWithMask(gfx::DrawTarget* aDT,
|
|
|
|
const gfx::Rect& aRect,
|
|
|
|
const gfx::Color& aColor,
|
|
|
|
const gfx::DrawOptions& aOptions,
|
|
|
|
gfx::SourceSurface* aMaskSource = nullptr,
|
|
|
|
const gfx::Matrix* aMaskTransform = nullptr);
|
|
|
|
void
|
|
|
|
FillRectWithMask(gfx::DrawTarget* aDT,
|
|
|
|
const gfx::Rect& aRect,
|
|
|
|
gfx::SourceSurface* aSurface,
|
2016-05-25 16:01:18 +00:00
|
|
|
gfx::SamplingFilter aSamplingFilter,
|
2014-04-11 12:23:09 +00:00
|
|
|
const gfx::DrawOptions& aOptions,
|
|
|
|
gfx::ExtendMode aExtendMode,
|
|
|
|
gfx::SourceSurface* aMaskSource = nullptr,
|
|
|
|
const gfx::Matrix* aMaskTransform = nullptr,
|
|
|
|
const gfx::Matrix* aSurfaceTransform = nullptr);
|
|
|
|
void
|
2014-04-01 04:02:09 +00:00
|
|
|
FillRectWithMask(gfx::DrawTarget* aDT,
|
2014-05-12 00:31:27 +00:00
|
|
|
const gfx::Point& aDeviceOffset,
|
2014-04-01 04:02:09 +00:00
|
|
|
const gfx::Rect& aRect,
|
|
|
|
gfx::SourceSurface* aSurface,
|
2016-05-25 16:01:18 +00:00
|
|
|
gfx::SamplingFilter aSamplingFilter,
|
2014-04-01 04:02:09 +00:00
|
|
|
const gfx::DrawOptions& aOptions,
|
|
|
|
Layer* aMaskLayer);
|
2012-06-29 06:01:34 +00:00
|
|
|
void
|
2014-04-01 04:02:09 +00:00
|
|
|
FillRectWithMask(gfx::DrawTarget* aDT,
|
2014-05-12 00:31:27 +00:00
|
|
|
const gfx::Point& aDeviceOffset,
|
2014-04-01 04:02:09 +00:00
|
|
|
const gfx::Rect& aRect,
|
|
|
|
const gfx::Color& aColor,
|
|
|
|
const gfx::DrawOptions& aOptions,
|
|
|
|
Layer* aMaskLayer);
|
2012-06-29 06:01:34 +00:00
|
|
|
|
2017-01-10 18:48:44 +00:00
|
|
|
void
|
|
|
|
FillPathWithMask(gfx::DrawTarget* aDT,
|
|
|
|
const gfx::Path* aPath,
|
|
|
|
const gfx::Rect& aClipRect,
|
|
|
|
const gfx::Color& aColor,
|
|
|
|
const gfx::DrawOptions& aOptions,
|
|
|
|
gfx::SourceSurface* aMaskSource = nullptr,
|
|
|
|
const gfx::Matrix* aMaskTransform = nullptr);
|
|
|
|
void
|
|
|
|
FillPathWithMask(gfx::DrawTarget* aDT,
|
|
|
|
const gfx::Path* aPath,
|
|
|
|
const gfx::Rect& aClipRect,
|
|
|
|
gfx::SourceSurface* aSurface,
|
|
|
|
gfx::SamplingFilter aSamplingFilter,
|
|
|
|
const gfx::DrawOptions& aOptions,
|
|
|
|
gfx::ExtendMode aExtendMode,
|
|
|
|
gfx::SourceSurface* aMaskSource,
|
|
|
|
const gfx::Matrix* aMaskTransform,
|
|
|
|
const gfx::Matrix* aSurfaceTransform);
|
|
|
|
|
2012-06-29 06:01:34 +00:00
|
|
|
BasicImplData*
|
|
|
|
ToData(Layer* aLayer);
|
|
|
|
|
2014-02-27 16:56:48 +00:00
|
|
|
/**
|
|
|
|
* Returns the operator to be used when blending and compositing this layer.
|
|
|
|
* Currently there is no way to specify both a blending and a compositing
|
|
|
|
* operator other than normal and source over respectively.
|
|
|
|
*
|
|
|
|
* If the layer has
|
|
|
|
* an effective blend mode operator other than normal, as returned by
|
|
|
|
* GetEffectiveMixBlendMode, this operator is used for blending, and source
|
|
|
|
* over is used for compositing.
|
|
|
|
* If the blend mode for this layer is normal, the compositing operator
|
|
|
|
* returned by GetOperator is used.
|
|
|
|
*/
|
|
|
|
gfx::CompositionOp
|
|
|
|
GetEffectiveOperator(Layer* aLayer);
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2012-06-29 06:01:34 +00:00
|
|
|
|
|
|
|
#endif
|