2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2013-11-27 15:22:46 +04:00
|
|
|
* 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 _MOZILLA_GFX_FILTERNODESOFTWARE_H_
|
|
|
|
#define _MOZILLA_GFX_FILTERNODESOFTWARE_H_
|
|
|
|
|
|
|
|
#include "Filters.h"
|
2017-12-20 19:36:23 +03:00
|
|
|
#include "mozilla/Mutex.h"
|
2013-11-27 15:22:46 +04:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
class DataSourceSurface;
|
|
|
|
class DrawTarget;
|
|
|
|
struct DrawOptions;
|
|
|
|
class FilterNodeSoftware;
|
|
|
|
|
2018-02-09 00:21:06 +03:00
|
|
|
/**
|
|
|
|
* Can be attached to FilterNodeSoftware instances using
|
|
|
|
* AddInvalidationListener. FilterInvalidated is called whenever the output of
|
|
|
|
* the observed filter may have changed; that is, whenever cached GetOutput()
|
|
|
|
* results (and results derived from them) need to discarded.
|
|
|
|
*/
|
|
|
|
class FilterInvalidationListener {
|
|
|
|
public:
|
2019-05-01 11:47:10 +03:00
|
|
|
virtual void FilterInvalidated(FilterNodeSoftware* aFilter) = 0;
|
2018-02-09 00:21:06 +03:00
|
|
|
};
|
|
|
|
|
2013-11-27 15:22:46 +04:00
|
|
|
/**
|
|
|
|
* This is the base class for the software (i.e. pure CPU, non-accelerated)
|
|
|
|
* FilterNode implementation. The software implementation is backend-agnostic,
|
|
|
|
* so it can be used as a fallback for all DrawTarget implementations.
|
|
|
|
*/
|
2018-02-09 00:21:06 +03:00
|
|
|
class FilterNodeSoftware : public FilterNode,
|
|
|
|
public FilterInvalidationListener {
|
2013-11-27 15:22:46 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeSoftware, override)
|
2018-02-09 22:46:04 +03:00
|
|
|
FilterNodeSoftware();
|
2013-11-27 15:22:46 +04:00
|
|
|
virtual ~FilterNodeSoftware();
|
|
|
|
|
|
|
|
// Factory method, intended to be called from DrawTarget*::CreateFilter.
|
2015-06-17 17:00:52 +03:00
|
|
|
static already_AddRefed<FilterNode> Create(FilterType aType);
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
// Draw the filter, intended to be called by DrawTarget*::DrawFilter.
|
2019-05-01 11:47:10 +03:00
|
|
|
void Draw(DrawTarget* aDrawTarget, const Rect& aSourceRect,
|
|
|
|
const Point& aDestPoint, const DrawOptions& aOptions);
|
2013-11-27 15:22:46 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
FilterBackend GetBackendType() override { return FILTER_BACKEND_SOFTWARE; }
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetInput(uint32_t aIndex, SourceSurface* aSurface) override;
|
|
|
|
void SetInput(uint32_t aIndex, FilterNode* aFilter) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
virtual const char* GetName() { return "Unknown"; }
|
2013-12-10 17:50:41 +04:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
void AddInvalidationListener(FilterInvalidationListener* aListener);
|
|
|
|
void RemoveInvalidationListener(FilterInvalidationListener* aListener);
|
2018-02-09 00:21:06 +03:00
|
|
|
|
|
|
|
// FilterInvalidationListener implementation
|
2019-05-01 11:47:10 +03:00
|
|
|
void FilterInvalidated(FilterNodeSoftware* aFilter) override;
|
2018-02-09 00:21:06 +03:00
|
|
|
|
2013-11-27 15:22:46 +04:00
|
|
|
protected:
|
|
|
|
// The following methods are intended to be overriden by subclasses.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translates a *FilterInputs enum value into an index for the
|
|
|
|
* mInputFilters / mInputSurfaces arrays. Returns -1 for invalid inputs.
|
|
|
|
* If somebody calls SetInput(enumValue, input) with an enumValue for which
|
|
|
|
* InputIndex(enumValue) is -1, we abort.
|
|
|
|
*/
|
|
|
|
virtual int32_t InputIndex(uint32_t aInputEnumIndex) { return -1; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Every filter node has an output rect, which can also be infinite. The
|
|
|
|
* output rect can depend on the values of any set attributes and on the
|
|
|
|
* output rects of any input filters or surfaces.
|
|
|
|
* This method returns the intersection of the filter's output rect with
|
|
|
|
* aInRect. Filters with unconstrained output always return aInRect.
|
|
|
|
*/
|
2019-05-01 11:47:10 +03:00
|
|
|
virtual IntRect GetOutputRectInRect(const IntRect& aInRect) = 0;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a surface with the rendered output which is of size aRect.Size().
|
|
|
|
* aRect is required to be a subrect of this filter's output rect; in other
|
|
|
|
* words, aRect == GetOutputRectInRect(aRect) must always be true.
|
|
|
|
* May return nullptr in error conditions or for an empty aRect.
|
|
|
|
* Implementations are not required to allocate a new surface and may even
|
|
|
|
* pass through input surfaces unchanged.
|
|
|
|
* Callers need to treat the returned surface as immutable.
|
|
|
|
*/
|
2019-05-01 11:47:10 +03:00
|
|
|
virtual already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) = 0;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
2018-02-09 00:21:06 +03:00
|
|
|
/**
|
|
|
|
* Call RequestRect (see below) on any input filters with the desired input
|
|
|
|
* rect, so that the input filter knows what to cache the next time it
|
|
|
|
* renders.
|
|
|
|
*/
|
2019-05-01 11:47:10 +03:00
|
|
|
virtual void RequestFromInputsForRect(const IntRect& aRect) {}
|
2018-02-09 00:21:06 +03:00
|
|
|
|
2013-11-27 15:22:46 +04:00
|
|
|
/**
|
|
|
|
* This method provides a caching default implementation but can be overriden
|
|
|
|
* by subclasses that don't want to cache their output. Those classes should
|
|
|
|
* call Render(aRect) directly from here.
|
|
|
|
*/
|
2019-05-01 11:47:10 +03:00
|
|
|
virtual already_AddRefed<DataSourceSurface> GetOutput(const IntRect& aRect);
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
// The following methods are non-virtual helper methods.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Format hints for GetInputDataSourceSurface. Some callers of
|
|
|
|
* GetInputDataSourceSurface can handle both B8G8R8A8 and A8 surfaces, these
|
|
|
|
* should pass CAN_HANDLE_A8 in order to avoid unnecessary conversions.
|
|
|
|
* Callers that can only handle B8G8R8A8 surfaces pass NEED_COLOR_CHANNELS.
|
|
|
|
*/
|
|
|
|
enum FormatHint { CAN_HANDLE_A8, NEED_COLOR_CHANNELS };
|
|
|
|
|
|
|
|
/**
|
2014-01-10 23:06:16 +04:00
|
|
|
* Returns SurfaceFormat::B8G8R8A8 or SurfaceFormat::A8, depending on the
|
2013-11-27 15:22:46 +04:00
|
|
|
* current surface format and the format hint.
|
|
|
|
*/
|
|
|
|
SurfaceFormat DesiredFormat(SurfaceFormat aCurrentFormat,
|
|
|
|
FormatHint aFormatHint);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Intended to be called by FilterNodeSoftware::Render implementations.
|
|
|
|
* Returns a surface of size aRect.Size() or nullptr in error conditions. The
|
|
|
|
* returned surface contains the output of the specified input filter or
|
|
|
|
* input surface in aRect. If aRect extends beyond the input filter's output
|
|
|
|
* rect (or the input surface's dimensions), the remaining area is filled
|
|
|
|
* according to aEdgeMode: The default, EDGE_MODE_NONE, simply pads with
|
|
|
|
* transparent black.
|
2014-01-10 23:06:16 +04:00
|
|
|
* If non-null, the returned surface is guaranteed to be of SurfaceFormat::A8
|
|
|
|
* or SurfaceFormat::B8G8R8A8. If aFormatHint is NEED_COLOR_CHANNELS, the
|
|
|
|
* returned surface is guaranteed to be of SurfaceFormat::B8G8R8A8 always.
|
2013-11-27 15:22:46 +04:00
|
|
|
* Each pixel row of the returned surface is guaranteed to be 16-byte aligned.
|
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<DataSourceSurface> GetInputDataSourceSurface(
|
2019-05-01 11:47:10 +03:00
|
|
|
uint32_t aInputEnumIndex, const IntRect& aRect,
|
2013-11-27 15:22:46 +04:00
|
|
|
FormatHint aFormatHint = CAN_HANDLE_A8,
|
|
|
|
ConvolveMatrixEdgeMode aEdgeMode = EDGE_MODE_NONE,
|
2019-05-01 11:47:10 +03:00
|
|
|
const IntRect* aTransparencyPaddedSourceRect = nullptr);
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the intersection of the input filter's or surface's output rect
|
|
|
|
* with aInRect.
|
|
|
|
*/
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect GetInputRectInRect(uint32_t aInputEnumIndex, const IntRect& aInRect);
|
2013-11-27 15:22:46 +04:00
|
|
|
|
2018-02-09 00:21:06 +03:00
|
|
|
/**
|
|
|
|
* Calls RequestRect on the specified input, if it's a filter.
|
|
|
|
*/
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestInputRect(uint32_t aInputEnumIndex, const IntRect& aRect);
|
2019-01-28 02:36:04 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls MapRectToSource on the specified input, if it's a filter.
|
|
|
|
*/
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect MapInputRectToSource(uint32_t aInputEnumIndex, const IntRect& aRect,
|
|
|
|
const IntRect& aMax, FilterNode* aSourceNode);
|
2018-02-09 00:21:06 +03:00
|
|
|
|
2013-11-27 15:22:46 +04:00
|
|
|
/**
|
|
|
|
* Returns the number of set input filters or surfaces. Needed for filters
|
|
|
|
* which can have an arbitrary number of inputs.
|
|
|
|
*/
|
|
|
|
size_t NumberOfSetInputs();
|
|
|
|
|
2018-02-09 00:21:06 +03:00
|
|
|
/**
|
|
|
|
* Discard the cached surface that was stored in the GetOutput default
|
|
|
|
* implementation. Needs to be called whenever attributes or inputs are set
|
|
|
|
* that might change the result of a Render() call.
|
|
|
|
*/
|
|
|
|
void Invalidate();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called in order to let this filter know what to cache during the next
|
|
|
|
* GetOutput call. Expected to call RequestRect on this filter's input
|
|
|
|
* filters.
|
|
|
|
*/
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestRect(const IntRect& aRect);
|
2018-02-09 00:21:06 +03:00
|
|
|
|
2013-11-27 15:22:46 +04:00
|
|
|
/**
|
|
|
|
* Set input filter and clear input surface for this input index, or set
|
|
|
|
* input surface and clear input filter. One of aSurface and aFilter should
|
|
|
|
* be null.
|
|
|
|
*/
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetInput(uint32_t aIndex, SourceSurface* aSurface,
|
|
|
|
FilterNodeSoftware* aFilter);
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* mInputSurfaces / mInputFilters: For each input index, either a surface or
|
|
|
|
* a filter is set, and the other is null.
|
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
std::vector<RefPtr<SourceSurface> > mInputSurfaces;
|
|
|
|
std::vector<RefPtr<FilterNodeSoftware> > mInputFilters;
|
2018-02-09 00:21:06 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Weak pointers to our invalidation listeners, i.e. to those filters who
|
|
|
|
* have this filter as an input. Invalidation listeners are required to
|
|
|
|
* unsubscribe themselves from us when they let go of their reference to us.
|
|
|
|
* This ensures that the pointers in this array are never stale.
|
|
|
|
*/
|
2019-05-01 11:47:10 +03:00
|
|
|
std::vector<FilterInvalidationListener*> mInvalidationListeners;
|
2018-02-09 00:21:06 +03:00
|
|
|
|
2018-02-09 22:46:04 +03:00
|
|
|
/**
|
|
|
|
* Lock guarding mRequestedRect, mCachedRect, and mCachedOutput. All uses
|
|
|
|
* of those members must aquire this lock.
|
|
|
|
*/
|
|
|
|
Mutex mCacheMutex;
|
|
|
|
|
2018-02-09 00:21:06 +03:00
|
|
|
/**
|
|
|
|
* Stores the rect which we want to render and cache on the next call to
|
|
|
|
* GetOutput.
|
|
|
|
*/
|
|
|
|
IntRect mRequestedRect;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores our cached output.
|
|
|
|
*/
|
|
|
|
IntRect mCachedRect;
|
|
|
|
RefPtr<DataSourceSurface> mCachedOutput;
|
2013-11-27 15:22:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Subclasses for specific filters.
|
|
|
|
|
2013-11-27 15:25:27 +04:00
|
|
|
class FilterNodeTransformSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeTransformSoftware, override)
|
2013-11-27 15:25:27 +04:00
|
|
|
FilterNodeTransformSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Transform"; }
|
2013-11-27 15:25:27 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, uint32_t aGraphicsFilter) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const Matrix& aMatrix) override;
|
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:25:27 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
|
|
|
IntRect SourceRectForOutputRect(const IntRect& aRect);
|
2013-11-27 15:25:27 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
Matrix mMatrix;
|
2016-05-25 19:01:18 +03:00
|
|
|
SamplingFilter mSamplingFilter;
|
2013-11-27 15:25:27 +04:00
|
|
|
};
|
|
|
|
|
2013-11-27 15:22:46 +04:00
|
|
|
class FilterNodeBlendSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeBlendSoftware, override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeBlendSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Blend"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, uint32_t aBlendMode) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
BlendMode mBlendMode;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeMorphologySoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeMorphologySoftware,
|
|
|
|
override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeMorphologySoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Morphology"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const IntSize& aRadii) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, uint32_t aOperator) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
IntSize mRadii;
|
|
|
|
MorphologyOperator mOperator;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeColorMatrixSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeColorMatrixSoftware,
|
|
|
|
override)
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "ColorMatrix"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const Matrix5x4& aMatrix) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, uint32_t aAlphaMode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
Matrix5x4 mMatrix;
|
|
|
|
AlphaMode mAlphaMode;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeFloodSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeFloodSoftware, override)
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Flood"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2020-03-09 17:16:17 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const DeviceColor& aColor) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> GetOutput(const IntRect& aRect) override;
|
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
2020-03-09 17:16:17 +03:00
|
|
|
DeviceColor mColor;
|
2013-11-27 15:22:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeTileSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeTileSoftware, override)
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Tile"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const IntRect& aSourceRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
IntRect mSourceRect;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Baseclass for the four different component transfer filters.
|
|
|
|
*/
|
|
|
|
class FilterNodeComponentTransferSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeComponentTransferSoftware,
|
|
|
|
override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeComponentTransferSoftware();
|
|
|
|
|
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, bool aDisable) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
virtual void GenerateLookupTable(ptrdiff_t aComponent,
|
|
|
|
uint8_t aTables[4][256], bool aDisabled);
|
|
|
|
virtual void FillLookupTable(ptrdiff_t aComponent, uint8_t aTable[256]) = 0;
|
|
|
|
|
|
|
|
bool mDisableR;
|
|
|
|
bool mDisableG;
|
|
|
|
bool mDisableB;
|
|
|
|
bool mDisableA;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeTableTransferSoftware
|
|
|
|
: public FilterNodeComponentTransferSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeTableTransferSoftware,
|
|
|
|
override)
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "TableTransfer"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeComponentTransferSoftware::SetAttribute;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const Float* aFloat,
|
2019-04-11 15:36:51 +03:00
|
|
|
uint32_t aSize) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-04-11 15:36:51 +03:00
|
|
|
void FillLookupTable(ptrdiff_t aComponent, uint8_t aTable[256]) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
2019-05-01 11:47:10 +03:00
|
|
|
void FillLookupTableImpl(std::vector<Float>& aTableValues,
|
2013-11-27 15:22:46 +04:00
|
|
|
uint8_t aTable[256]);
|
|
|
|
|
|
|
|
std::vector<Float> mTableR;
|
|
|
|
std::vector<Float> mTableG;
|
|
|
|
std::vector<Float> mTableB;
|
|
|
|
std::vector<Float> mTableA;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeDiscreteTransferSoftware
|
|
|
|
: public FilterNodeComponentTransferSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeDiscreteTransferSoftware,
|
|
|
|
override)
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "DiscreteTransfer"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeComponentTransferSoftware::SetAttribute;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const Float* aFloat,
|
2019-04-11 15:36:51 +03:00
|
|
|
uint32_t aSize) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-04-11 15:36:51 +03:00
|
|
|
void FillLookupTable(ptrdiff_t aComponent, uint8_t aTable[256]) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
2019-05-01 11:47:10 +03:00
|
|
|
void FillLookupTableImpl(std::vector<Float>& aTableValues,
|
2013-11-27 15:22:46 +04:00
|
|
|
uint8_t aTable[256]);
|
|
|
|
|
|
|
|
std::vector<Float> mTableR;
|
|
|
|
std::vector<Float> mTableG;
|
|
|
|
std::vector<Float> mTableB;
|
|
|
|
std::vector<Float> mTableA;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeLinearTransferSoftware
|
|
|
|
: public FilterNodeComponentTransferSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeLinearTransformSoftware,
|
|
|
|
override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeLinearTransferSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "LinearTransfer"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeComponentTransferSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, Float aValue) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-04-11 15:36:51 +03:00
|
|
|
void FillLookupTable(ptrdiff_t aComponent, uint8_t aTable[256]) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
void FillLookupTableImpl(Float aSlope, Float aIntercept, uint8_t aTable[256]);
|
|
|
|
|
|
|
|
Float mSlopeR;
|
|
|
|
Float mSlopeG;
|
|
|
|
Float mSlopeB;
|
|
|
|
Float mSlopeA;
|
|
|
|
Float mInterceptR;
|
|
|
|
Float mInterceptG;
|
|
|
|
Float mInterceptB;
|
|
|
|
Float mInterceptA;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeGammaTransferSoftware
|
|
|
|
: public FilterNodeComponentTransferSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeGammaTransferSoftware,
|
|
|
|
override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeGammaTransferSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "GammaTransfer"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeComponentTransferSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, Float aValue) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-04-11 15:36:51 +03:00
|
|
|
void FillLookupTable(ptrdiff_t aComponent, uint8_t aTable[256]) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
void FillLookupTableImpl(Float aAmplitude, Float aExponent, Float aOffset,
|
|
|
|
uint8_t aTable[256]);
|
|
|
|
|
|
|
|
Float mAmplitudeR;
|
|
|
|
Float mAmplitudeG;
|
|
|
|
Float mAmplitudeB;
|
|
|
|
Float mAmplitudeA;
|
|
|
|
Float mExponentR;
|
|
|
|
Float mExponentG;
|
|
|
|
Float mExponentB;
|
|
|
|
Float mExponentA;
|
|
|
|
Float mOffsetR;
|
|
|
|
Float mOffsetG;
|
|
|
|
Float mOffsetB;
|
|
|
|
Float mOffsetA;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeConvolveMatrixSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeConvolveMatrixSoftware,
|
|
|
|
override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeConvolveMatrixSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "ConvolveMatrix"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const IntSize& aKernelSize) override;
|
|
|
|
void SetAttribute(uint32_t aIndex, const Float* aMatrix,
|
2019-04-11 15:36:51 +03:00
|
|
|
uint32_t aSize) override;
|
|
|
|
void SetAttribute(uint32_t aIndex, Float aValue) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const Size& aKernelUnitLength) override;
|
|
|
|
void SetAttribute(uint32_t aIndex, const IntRect& aSourceRect) override;
|
|
|
|
void SetAttribute(uint32_t aIndex, const IntPoint& aTarget) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, uint32_t aEdgeMode) override;
|
|
|
|
void SetAttribute(uint32_t aIndex, bool aPreserveAlpha) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
template <typename CoordType>
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> DoRender(const IntRect& aRect,
|
2013-11-27 15:22:46 +04:00
|
|
|
CoordType aKernelUnitLengthX,
|
|
|
|
CoordType aKernelUnitLengthY);
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect InflatedSourceRect(const IntRect& aDestRect);
|
|
|
|
IntRect InflatedDestRect(const IntRect& aSourceRect);
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
IntSize mKernelSize;
|
|
|
|
std::vector<Float> mKernelMatrix;
|
|
|
|
Float mDivisor;
|
|
|
|
Float mBias;
|
|
|
|
IntPoint mTarget;
|
|
|
|
IntRect mSourceRect;
|
|
|
|
ConvolveMatrixEdgeMode mEdgeMode;
|
|
|
|
Size mKernelUnitLength;
|
|
|
|
bool mPreserveAlpha;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeDisplacementMapSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeDisplacementMapSoftware,
|
|
|
|
override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeDisplacementMapSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "DisplacementMap"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, Float aScale) override;
|
|
|
|
void SetAttribute(uint32_t aIndex, uint32_t aValue) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect InflatedSourceOrDestRect(const IntRect& aDestOrSourceRect);
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
Float mScale;
|
|
|
|
ColorChannel mChannelX;
|
|
|
|
ColorChannel mChannelY;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeTurbulenceSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeTurbulenceSoftware,
|
|
|
|
override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeTurbulenceSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Turbulence"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const Size& aSize) override;
|
|
|
|
void SetAttribute(uint32_t aIndex, const IntRect& aRenderRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, bool aStitchable) override;
|
|
|
|
void SetAttribute(uint32_t aIndex, uint32_t aValue) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
IntRect mRenderRect;
|
|
|
|
Size mBaseFrequency;
|
|
|
|
uint32_t mNumOctaves;
|
|
|
|
uint32_t mSeed;
|
|
|
|
bool mStitchable;
|
|
|
|
TurbulenceType mType;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeArithmeticCombineSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeArithmeticCombineSoftware,
|
|
|
|
override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeArithmeticCombineSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "ArithmeticCombine"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const Float* aFloat,
|
2019-04-11 15:36:51 +03:00
|
|
|
uint32_t aSize) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
Float mK1;
|
|
|
|
Float mK2;
|
|
|
|
Float mK3;
|
|
|
|
Float mK4;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeCompositeSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeCompositeSoftware, override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeCompositeSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Composite"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, uint32_t aOperator) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
CompositeOperator mOperator;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Base class for FilterNodeGaussianBlurSoftware and
|
|
|
|
// FilterNodeDirectionalBlurSoftware.
|
|
|
|
class FilterNodeBlurXYSoftware : public FilterNodeSoftware {
|
2014-02-24 17:23:37 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeBlurXYSoftware, override)
|
2013-11-27 15:22:46 +04:00
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect InflatedSourceOrDestRect(const IntRect& aDestRect);
|
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
// Implemented by subclasses.
|
|
|
|
virtual Size StdDeviationXY() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeGaussianBlurSoftware : public FilterNodeBlurXYSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeGaussianBlurSoftware,
|
|
|
|
override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeGaussianBlurSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "GaussianBlur"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, Float aStdDeviation) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-04-11 15:36:51 +03:00
|
|
|
Size StdDeviationXY() override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
Float mStdDeviation;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeDirectionalBlurSoftware : public FilterNodeBlurXYSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeDirectionalBlurSoftware,
|
|
|
|
override)
|
2013-11-27 15:22:46 +04:00
|
|
|
FilterNodeDirectionalBlurSoftware();
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "DirectionalBlur"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, Float aStdDeviation) override;
|
|
|
|
void SetAttribute(uint32_t aIndex, uint32_t aBlurDirection) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-04-11 15:36:51 +03:00
|
|
|
Size StdDeviationXY() override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
Float mStdDeviation;
|
|
|
|
BlurDirection mBlurDirection;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeCropSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeCropSoftware, override)
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Crop"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const Rect& aSourceRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
IntRect mCropRect;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodePremultiplySoftware : public FilterNodeSoftware {
|
2013-12-10 17:50:41 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodePremultiplySoftware,
|
|
|
|
override)
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Premultiply"; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-11-27 15:22:46 +04:00
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeUnpremultiplySoftware : public FilterNodeSoftware {
|
2013-12-10 17:50:41 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeUnpremultiplySoftware,
|
|
|
|
override)
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Unpremultiply"; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-11-27 15:22:46 +04:00
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
};
|
|
|
|
|
2018-07-17 22:11:13 +03:00
|
|
|
class FilterNodeOpacitySoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeOpacitySoftware, override)
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* GetName() override { return "Opacity"; }
|
2018-07-17 22:11:13 +03:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, Float aValue) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-07-17 22:11:13 +03:00
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
2018-07-17 22:11:13 +03:00
|
|
|
|
|
|
|
Float mValue = 1.0f;
|
|
|
|
};
|
|
|
|
|
2013-11-27 15:22:46 +04:00
|
|
|
template <typename LightType, typename LightingType>
|
|
|
|
class FilterNodeLightingSoftware : public FilterNodeSoftware {
|
|
|
|
public:
|
2014-02-26 19:13:48 +04:00
|
|
|
#if defined(MOZILLA_INTERNAL_API) && \
|
|
|
|
(defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
|
|
|
|
// Helpers for refcounted
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* typeName() const override { return mTypeName; }
|
2019-04-11 15:36:51 +03:00
|
|
|
size_t typeSize() const override { return sizeof(*this); }
|
2014-02-26 19:13:48 +04:00
|
|
|
#endif
|
2019-05-01 11:47:10 +03:00
|
|
|
explicit FilterNodeLightingSoftware(const char* aTypeName);
|
|
|
|
const char* GetName() override { return "Lighting"; }
|
2013-11-27 15:22:46 +04:00
|
|
|
using FilterNodeSoftware::SetAttribute;
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, Float) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const Size&) override;
|
|
|
|
void SetAttribute(uint32_t aIndex, const Point3D&) override;
|
2020-03-09 17:16:17 +03:00
|
|
|
void SetAttribute(uint32_t aIndex, const DeviceColor&) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
|
|
|
|
FilterNode* aSourceNode) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
protected:
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> Render(const IntRect& aRect) override;
|
|
|
|
IntRect GetOutputRectInRect(const IntRect& aRect) override;
|
2019-04-11 15:36:51 +03:00
|
|
|
int32_t InputIndex(uint32_t aInputEnumIndex) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
void RequestFromInputsForRect(const IntRect& aRect) override;
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
template <typename CoordType>
|
2019-05-01 11:47:10 +03:00
|
|
|
already_AddRefed<DataSourceSurface> DoRender(const IntRect& aRect,
|
2013-11-27 15:22:46 +04:00
|
|
|
CoordType aKernelUnitLengthX,
|
|
|
|
CoordType aKernelUnitLengthY);
|
|
|
|
|
2017-12-20 19:36:23 +03:00
|
|
|
Mutex mLock;
|
2013-11-27 15:22:46 +04:00
|
|
|
LightType mLight;
|
|
|
|
LightingType mLighting;
|
|
|
|
Float mSurfaceScale;
|
|
|
|
Size mKernelUnitLength;
|
2020-03-09 17:16:17 +03:00
|
|
|
DeviceColor mColor;
|
2014-02-26 19:13:48 +04:00
|
|
|
#if defined(MOZILLA_INTERNAL_API) && \
|
|
|
|
(defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
|
2019-05-01 11:47:10 +03:00
|
|
|
const char* mTypeName;
|
2014-02-26 19:13:48 +04:00
|
|
|
#endif
|
2013-11-27 15:22:46 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2013-11-27 15:22:46 +04:00
|
|
|
|
|
|
|
#endif // _MOZILLA_GFX_FILTERNODESOFTWARE_H_
|