~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/platform/graphics/filters/FEComponentTransfer.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
 
3
 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
 
4
 * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Library General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Library General Public License
 
17
 * along with this library; see the file COPYING.LIB.  If not, write to
 
18
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
19
 * Boston, MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
#ifndef FEComponentTransfer_h
 
23
#define FEComponentTransfer_h
 
24
 
 
25
#if ENABLE(FILTERS)
 
26
#include "FilterEffect.h"
 
27
 
 
28
#include "Filter.h"
 
29
#include <wtf/Vector.h>
 
30
 
 
31
namespace WebCore {
 
32
 
 
33
enum ComponentTransferType {
 
34
    FECOMPONENTTRANSFER_TYPE_UNKNOWN  = 0,
 
35
    FECOMPONENTTRANSFER_TYPE_IDENTITY = 1,
 
36
    FECOMPONENTTRANSFER_TYPE_TABLE    = 2,
 
37
    FECOMPONENTTRANSFER_TYPE_DISCRETE = 3,
 
38
    FECOMPONENTTRANSFER_TYPE_LINEAR   = 4,
 
39
    FECOMPONENTTRANSFER_TYPE_GAMMA    = 5
 
40
};
 
41
 
 
42
struct ComponentTransferFunction {
 
43
    ComponentTransferFunction()
 
44
        : type(FECOMPONENTTRANSFER_TYPE_UNKNOWN)
 
45
        , slope(0)
 
46
        , intercept(0)
 
47
        , amplitude(0)
 
48
        , exponent(0)
 
49
        , offset(0)
 
50
    {
 
51
    }
 
52
 
 
53
    ComponentTransferType type;
 
54
 
 
55
    float slope;
 
56
    float intercept;
 
57
    float amplitude;
 
58
    float exponent;
 
59
    float offset;
 
60
 
 
61
    Vector<float> tableValues;
 
62
};
 
63
 
 
64
class FEComponentTransfer : public FilterEffect {
 
65
public:
 
66
    static PassRefPtr<FEComponentTransfer> create(Filter*, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc,
 
67
                                                  const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc);
 
68
 
 
69
    ComponentTransferFunction redFunction() const;
 
70
    void setRedFunction(const ComponentTransferFunction&);
 
71
 
 
72
    ComponentTransferFunction greenFunction() const;
 
73
    void setGreenFunction(const ComponentTransferFunction&);
 
74
 
 
75
    ComponentTransferFunction blueFunction() const;
 
76
    void setBlueFunction(const ComponentTransferFunction&);
 
77
 
 
78
    ComponentTransferFunction alphaFunction() const;
 
79
    void setAlphaFunction(const ComponentTransferFunction&);
 
80
 
 
81
    virtual void platformApplySoftware();
 
82
#if USE(SKIA)
 
83
    virtual bool platformApplySkia();
 
84
    virtual SkImageFilter* createImageFilter(SkiaImageFilterBuilder*);
 
85
#endif
 
86
    virtual void dump();
 
87
 
 
88
    virtual TextStream& externalRepresentation(TextStream&, int indention) const;
 
89
 
 
90
private:
 
91
    FEComponentTransfer(Filter*, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc,
 
92
                        const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc);
 
93
 
 
94
    void getValues(unsigned char rValues[256], unsigned char gValues[256], unsigned char bValues[256], unsigned char aValues[256]);
 
95
 
 
96
    ComponentTransferFunction m_redFunc;
 
97
    ComponentTransferFunction m_greenFunc;
 
98
    ComponentTransferFunction m_blueFunc;
 
99
    ComponentTransferFunction m_alphaFunc;
 
100
};
 
101
 
 
102
} // namespace WebCore
 
103
 
 
104
#endif // ENABLE(FILTERS)
 
105
 
 
106
#endif // FEComponentTransfer_h