2
* Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
8
* 1. Redistributions of source code must retain the above
9
* copyright notice, this list of conditions and the following
11
* 2. Redistributions in binary form must reproduce the above
12
* copyright notice, this list of conditions and the following
13
* disclaimer in the documentation and/or other materials
14
* provided with the distribution.
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
17
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
20
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
#ifndef CustomFilterProgramInfo_h
31
#define CustomFilterProgramInfo_h
33
#if ENABLE(CSS_SHADERS)
34
#include "CustomFilterConstants.h"
35
#include "GraphicsTypes.h"
37
#include <wtf/HashTraits.h>
38
#include <wtf/text/WTFString.h>
43
struct CustomFilterProgramMixSettings {
44
CustomFilterProgramMixSettings()
45
: blendMode(BlendModeNormal)
46
, compositeOperator(CompositeSourceAtop)
50
bool operator==(const CustomFilterProgramMixSettings& o) const
52
return blendMode == o.blendMode && compositeOperator == o.compositeOperator;
56
CompositeOperator compositeOperator;
59
// CustomFilterProgramInfo is the key used to link CustomFilterProgram with CustomFilterCompiledProgram.
60
// It can be used as a key in a HashMap, with the note that at least one of Strings needs to be non-null.
61
// Null strings are placeholders for the default shader.
62
class CustomFilterProgramInfo {
64
CustomFilterProgramInfo(const String&, const String&, CustomFilterProgramType, const CustomFilterProgramMixSettings&, CustomFilterMeshType);
66
CustomFilterProgramInfo();
67
bool isEmptyValue() const;
69
CustomFilterProgramInfo(WTF::HashTableDeletedValueType);
70
bool isHashTableDeletedValue() const;
72
unsigned hash() const;
73
bool operator==(const CustomFilterProgramInfo&) const;
75
const String& vertexShaderString() const { return m_vertexShaderString; }
76
const String& fragmentShaderString() const { return m_fragmentShaderString; }
77
CustomFilterProgramType programType() const { return m_programType; }
78
const CustomFilterProgramMixSettings& mixSettings() const { return m_mixSettings; }
79
CustomFilterMeshType meshType() const { return m_meshType; }
81
String m_vertexShaderString;
82
String m_fragmentShaderString;
83
CustomFilterProgramType m_programType;
84
CustomFilterProgramMixSettings m_mixSettings;
85
CustomFilterMeshType m_meshType;
88
struct CustomFilterProgramInfoHash {
89
static unsigned hash(const CustomFilterProgramInfo& programInfo) { return programInfo.hash(); }
90
static bool equal(const CustomFilterProgramInfo& a, const CustomFilterProgramInfo& b) { return a == b; }
91
static const bool safeToCompareToEmptyOrDeleted = false;
94
struct CustomFilterProgramInfoHashTraits : WTF::SimpleClassHashTraits<CustomFilterProgramInfo> {
95
static const bool hasIsEmptyValueFunction = true;
96
static bool isEmptyValue(const CustomFilterProgramInfo& info) { return info.isEmptyValue(); }
99
} // namespace WebCore
103
template<> struct HashTraits<WebCore::CustomFilterProgramInfo> : WebCore::CustomFilterProgramInfoHashTraits { };
104
template<> struct DefaultHash<WebCore::CustomFilterProgramInfo> {
105
typedef WebCore::CustomFilterProgramInfoHash Hash;
109
#endif // ENABLE(CSS_SHADERS)
111
#endif // CustomFilterProgramInfo_h