Commit 416e51c7 authored by achicu@adobe.com's avatar achicu@adobe.com

[CSS Shaders] Extract the CustomFilterParameterList to its own file

https://bugs.webkit.org/show_bug.cgi?id=100548

Reviewed by Dean Jackson.

Moved all the CustomFilterParameterList related methods to their own file.
Also made CustomFilterParameterList inherit from Vector instead of typedefing it,
so that we can add a different operator== and a blend method to it.

No new tests, just refactoring existing code.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* css/StyleResolver.h:
* platform/graphics/filters/CustomFilterOperation.cpp:
(WebCore::CustomFilterOperation::CustomFilterOperation):
(WebCore::CustomFilterOperation::blend):
* platform/graphics/filters/CustomFilterOperation.h:
(WebCore):
(WebCore::CustomFilterOperation::operator==):
* platform/graphics/filters/CustomFilterParameterList.cpp: Added.
(WebCore):
(WebCore::CustomFilterParameterList::operator==):
(WebCore::CustomFilterParameterList::checkAlphabeticalOrder):
(WebCore::CustomFilterParameterList::blend):
* platform/graphics/filters/CustomFilterParameterList.h: Added.
(WebCore):
(CustomFilterParameterList):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@132808 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3b223845
......@@ -1911,6 +1911,7 @@ SET(WebCore_SOURCES
platform/graphics/filters/CustomFilterGlobalContext.cpp
platform/graphics/filters/CustomFilterMesh.cpp
platform/graphics/filters/CustomFilterOperation.cpp
platform/graphics/filters/CustomFilterParameterList.cpp
platform/graphics/filters/CustomFilterProgram.cpp
platform/graphics/filters/CustomFilterProgramInfo.cpp
platform/graphics/filters/DistantLightSource.cpp
......
2012-10-29 Alexandru Chiculita <achicu@adobe.com>
[CSS Shaders] Extract the CustomFilterParameterList to its own file
https://bugs.webkit.org/show_bug.cgi?id=100548
Reviewed by Dean Jackson.
Moved all the CustomFilterParameterList related methods to their own file.
Also made CustomFilterParameterList inherit from Vector instead of typedefing it,
so that we can add a different operator== and a blend method to it.
No new tests, just refactoring existing code.
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* css/StyleResolver.h:
* platform/graphics/filters/CustomFilterOperation.cpp:
(WebCore::CustomFilterOperation::CustomFilterOperation):
(WebCore::CustomFilterOperation::blend):
* platform/graphics/filters/CustomFilterOperation.h:
(WebCore):
(WebCore::CustomFilterOperation::operator==):
* platform/graphics/filters/CustomFilterParameterList.cpp: Added.
(WebCore):
(WebCore::CustomFilterParameterList::operator==):
(WebCore::CustomFilterParameterList::checkAlphabeticalOrder):
(WebCore::CustomFilterParameterList::blend):
* platform/graphics/filters/CustomFilterParameterList.h: Added.
(WebCore):
(CustomFilterParameterList):
2012-10-29 Brady Eidson <beidson@apple.com>
Try to fix 32-bit builds after my incompletely tested m_identifier change.
......@@ -4336,6 +4336,8 @@ webcore_sources += \
Source/WebCore/platform/graphics/filters/CustomFilterOperation.cpp \
Source/WebCore/platform/graphics/filters/CustomFilterOperation.h \
Source/WebCore/platform/graphics/filters/CustomFilterParameter.h \
Source/WebCore/platform/graphics/filters/CustomFilterParameterList.cpp \
Source/WebCore/platform/graphics/filters/CustomFilterParameterList.h \
Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp \
Source/WebCore/platform/graphics/filters/CustomFilterProgram.h \
Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp \
......
......@@ -2078,6 +2078,7 @@ HEADERS += \
platform/graphics/filters/CustomFilterCompiledProgram.h \
platform/graphics/filters/CustomFilterOperation.h \
platform/graphics/filters/CustomFilterParameter.h \
platform/graphics/filters/CustomFilterParameterList.h \
platform/graphics/filters/CustomFilterProgram.h \
platform/graphics/filters/CustomFilterProgramInfo.h \
platform/graphics/filters/CustomFilterTransformParameter.h \
......@@ -3492,6 +3493,7 @@ enable?(FILTERS) {
SOURCES += \
platform/graphics/filters/CustomFilterGlobalContext.cpp \
platform/graphics/filters/CustomFilterOperation.cpp \
platform/graphics/filters/CustomFilterParameterList.cpp \
platform/graphics/filters/CustomFilterProgram.cpp \
platform/graphics/filters/CustomFilterProgramInfo.cpp \
platform/graphics/filters/CustomFilterCompiledProgram.cpp \
......
......@@ -4977,6 +4977,8 @@
'platform/graphics/filters/CustomFilterOperation.cpp',
'platform/graphics/filters/CustomFilterOperation.h',
'platform/graphics/filters/CustomFilterParameter.h',
'platform/graphics/filters/CustomFilterParameterList.cpp',
'platform/graphics/filters/CustomFilterParameterList.h',
'platform/graphics/filters/CustomFilterProgram.cpp',
'platform/graphics/filters/CustomFilterProgram.h',
'platform/graphics/filters/CustomFilterProgramInfo.cpp',
......
......@@ -31924,6 +31924,14 @@
RelativePath="..\platform\graphics\filters\CustomFilterParameter.h"
>
</File>
<File
RelativePath="..\platform\graphics\filters\CustomFilterParameterList.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\filters\CustomFilterParameterList.h"
>
</File>
<File
RelativePath="..\platform\graphics\filters\CustomFilterProgram.cpp"
>
......@@ -1498,6 +1498,8 @@
5081E3E03CFF80C16EF8B48B /* CachedResourceRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 5081E3E13D0280C16EF8B48B /* CachedResourceRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
508CCA4F13CF106B003151F3 /* RenderFlowThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 508CCA4D13CF106B003151F3 /* RenderFlowThread.h */; };
508CCA5013CF106B003151F3 /* RenderFlowThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 508CCA4E13CF106B003151F3 /* RenderFlowThread.cpp */; };
5093334F163B0E4300099A60 /* CustomFilterParameterList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5093334D163B0E4300099A60 /* CustomFilterParameterList.cpp */; };
50933350163B0E4300099A60 /* CustomFilterParameterList.h in Headers */ = {isa = PBXBuildFile; fileRef = 5093334E163B0E4300099A60 /* CustomFilterParameterList.h */; };
50987C26157D676D00BDA835 /* CustomFilterGlobalContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50987C24157D676D00BDA835 /* CustomFilterGlobalContext.cpp */; };
50987C27157D676D00BDA835 /* CustomFilterGlobalContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 50987C25157D676D00BDA835 /* CustomFilterGlobalContext.h */; };
509CC9FB14C069ED00BBECBD /* CustomFilterParameter.h in Headers */ = {isa = PBXBuildFile; fileRef = 509CC9FA14C069ED00BBECBD /* CustomFilterParameter.h */; };
......@@ -8704,6 +8706,8 @@
5081E3E13D0280C16EF8B48B /* CachedResourceRequest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedResourceRequest.h; sourceTree = "<group>"; };
508CCA4D13CF106B003151F3 /* RenderFlowThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderFlowThread.h; sourceTree = "<group>"; };
508CCA4E13CF106B003151F3 /* RenderFlowThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFlowThread.cpp; sourceTree = "<group>"; };
5093334D163B0E4300099A60 /* CustomFilterParameterList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CustomFilterParameterList.cpp; path = filters/CustomFilterParameterList.cpp; sourceTree = "<group>"; };
5093334E163B0E4300099A60 /* CustomFilterParameterList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterParameterList.h; path = filters/CustomFilterParameterList.h; sourceTree = "<group>"; };
50987C24157D676D00BDA835 /* CustomFilterGlobalContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CustomFilterGlobalContext.cpp; path = filters/CustomFilterGlobalContext.cpp; sourceTree = "<group>"; };
50987C25157D676D00BDA835 /* CustomFilterGlobalContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterGlobalContext.h; path = filters/CustomFilterGlobalContext.h; sourceTree = "<group>"; };
509CC9FA14C069ED00BBECBD /* CustomFilterParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterParameter.h; path = filters/CustomFilterParameter.h; sourceTree = "<group>"; };
......@@ -18244,6 +18248,8 @@
A75E8B7F0E1DE2B0007F2481 /* filters */ = {
isa = PBXGroup;
children = (
5093334D163B0E4300099A60 /* CustomFilterParameterList.cpp */,
5093334E163B0E4300099A60 /* CustomFilterParameterList.h */,
49ECEB5C1499790D00CDD3A4 /* arm */,
15B3FC1715FB217800A81BCB /* CustomFilterArrayParameter.h */,
50D4060F147D49DE00D30BB5 /* CustomFilterCompiledProgram.cpp */,
......@@ -25671,6 +25677,7 @@
E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
FD537353137B651800008DCE /* ZeroPole.h in Headers */,
50933350163B0E4300099A60 /* CustomFilterParameterList.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -28784,6 +28791,7 @@
977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
51ABF64D16392E2800132A7A /* LoaderStrategy.cpp in Sources */,
5093334F163B0E4300099A60 /* CustomFilterParameterList.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -61,6 +61,7 @@ class CSSValue;
class ContainerNode;
class CustomFilterOperation;
class CustomFilterParameter;
class CustomFilterParameterList;
class Document;
class Element;
class Frame;
......@@ -95,10 +96,6 @@ class WebKitCSSFilterValue;
class WebKitCSSShaderValue;
class WebKitCSSSVGDocumentValue;
#if ENABLE(CSS_SHADERS)
typedef Vector<RefPtr<CustomFilterParameter> > CustomFilterParameterList;
#endif
class MediaQueryResult {
WTF_MAKE_NONCOPYABLE(MediaQueryResult); WTF_MAKE_FAST_ALLOCATED;
public:
......
......@@ -36,65 +36,8 @@
#include "CustomFilterProgram.h"
#include "FilterOperation.h"
#include <wtf/text/StringHash.h>
namespace WebCore {
bool customFilterParametersEqual(const CustomFilterParameterList& listA, const CustomFilterParameterList& listB)
{
if (listA.size() != listB.size())
return false;
for (size_t i = 0; i < listA.size(); ++i) {
if (listA.at(i).get() != listB.at(i).get()
&& *listA.at(i).get() != *listB.at(i).get())
return false;
}
return true;
}
#if !ASSERT_DISABLED
static bool checkCustomFilterParametersOrder(const CustomFilterParameterList& parameters)
{
for (unsigned i = 1; i < parameters.size(); ++i) {
// Break for equal or not-sorted parameters.
if (!codePointCompareLessThan(parameters.at(i - 1)->name(), parameters.at(i)->name()))
return false;
}
return true;
}
#endif
void blendCustomFilterParameters(const CustomFilterParameterList& fromList, const CustomFilterParameterList& toList,
double progress, const LayoutSize& size, CustomFilterParameterList& resultList)
{
// This method expects both lists to be sorted by parameter name and the result list is also sorted.
ASSERT(checkCustomFilterParametersOrder(fromList));
ASSERT(checkCustomFilterParametersOrder(toList));
size_t fromListIndex = 0, toListIndex = 0;
while (fromListIndex < fromList.size() && toListIndex < toList.size()) {
CustomFilterParameter* paramFrom = fromList.at(fromListIndex).get();
CustomFilterParameter* paramTo = toList.at(toListIndex).get();
if (paramFrom->name() == paramTo->name()) {
resultList.append(paramTo->blend(paramFrom, progress, size));
++fromListIndex;
++toListIndex;
continue;
}
if (codePointCompareLessThan(paramFrom->name(), paramTo->name())) {
resultList.append(paramFrom);
++fromListIndex;
continue;
}
resultList.append(paramTo);
++toListIndex;
}
for (; fromListIndex < fromList.size(); ++fromListIndex)
resultList.append(fromList.at(fromListIndex));
for (; toListIndex < toList.size(); ++toListIndex)
resultList.append(toList.at(toListIndex));
ASSERT(checkCustomFilterParametersOrder(resultList));
}
CustomFilterOperation::CustomFilterOperation(PassRefPtr<CustomFilterProgram> program, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, MeshBoxType meshBoxType, MeshType meshType)
: FilterOperation(CUSTOM)
, m_program(program)
......@@ -105,7 +48,7 @@ CustomFilterOperation::CustomFilterOperation(PassRefPtr<CustomFilterProgram> pro
, m_meshType(meshType)
{
// Make sure that the parameters are alwyas sorted by name. We use that to merge two CustomFilterOperations in animations.
ASSERT(checkCustomFilterParametersOrder(m_parameters));
ASSERT(m_parameters.checkAlphabeticalOrder());
}
CustomFilterOperation::~CustomFilterOperation()
......@@ -129,7 +72,7 @@ PassRefPtr<FilterOperation> CustomFilterOperation::blend(const FilterOperation*
return this;
CustomFilterParameterList animatedParameters;
blendCustomFilterParameters(fromOp->m_parameters, m_parameters, progress, size, animatedParameters);
m_parameters.blend(fromOp->m_parameters, progress, size, animatedParameters);
return CustomFilterOperation::create(m_program, animatedParameters, m_meshRows, m_meshColumns, m_meshBoxType, m_meshType);
}
......
......@@ -31,23 +31,15 @@
#define CustomFilterOperation_h
#if ENABLE(CSS_SHADERS)
#include "CustomFilterParameterList.h"
#include "CustomFilterProgram.h"
#include "FilterOperation.h"
#include "LayoutTypes.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
// CSS Shaders
class CustomFilterParameter;
typedef Vector<RefPtr<CustomFilterParameter> > CustomFilterParameterList;
bool customFilterParametersEqual(const CustomFilterParameterList&, const CustomFilterParameterList&);
void blendCustomFilterParameters(const CustomFilterParameterList& listFrom, const CustomFilterParameterList& listTo,
double progress, const LayoutSize&, CustomFilterParameterList& resultList);
class CustomFilterOperation : public FilterOperation {
public:
enum MeshBoxType {
......@@ -92,11 +84,11 @@ private:
const CustomFilterOperation* other = static_cast<const CustomFilterOperation*>(&o);
return *m_program.get() == *other->m_program.get()
&& m_meshRows == other->m_meshRows
&& m_meshColumns == other->m_meshColumns
&& m_meshBoxType == other->m_meshBoxType
&& m_meshType == other->m_meshType
&& customFilterParametersEqual(m_parameters, other->m_parameters);
&& m_meshRows == other->m_meshRows
&& m_meshColumns == other->m_meshColumns
&& m_meshBoxType == other->m_meshBoxType
&& m_meshType == other->m_meshType
&& m_parameters == other->m_parameters;
}
CustomFilterOperation(PassRefPtr<CustomFilterProgram>, const CustomFilterParameterList&, unsigned meshRows, unsigned meshColumns, MeshBoxType, MeshType);
......
/*
* Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#if ENABLE(CSS_SHADERS)
#include "CustomFilterParameterList.h"
#include "CustomFilterParameter.h"
#include <wtf/text/StringHash.h>
namespace WebCore {
CustomFilterParameterList::CustomFilterParameterList()
{
}
CustomFilterParameterList::CustomFilterParameterList(size_t size)
: CustomFilterParameterListBase(size)
{
}
bool CustomFilterParameterList::operator==(const CustomFilterParameterList& other) const
{
if (size() != other.size())
return false;
for (size_t i = 0; i < size(); ++i) {
if (at(i).get() != other.at(i).get()
&& *at(i).get() != *other.at(i).get())
return false;
}
return true;
}
bool CustomFilterParameterList::checkAlphabeticalOrder() const
{
for (unsigned i = 1; i < size(); ++i) {
// Break for equal or not-sorted parameters.
if (!codePointCompareLessThan(at(i - 1)->name(), at(i)->name()))
return false;
}
return true;
}
void CustomFilterParameterList::blend(const CustomFilterParameterList& fromList,
double progress, const LayoutSize& frameSize, CustomFilterParameterList& resultList) const
{
// This method expects both lists to be sorted by parameter name and the result list is also sorted.
ASSERT(checkAlphabeticalOrder());
ASSERT(fromList.checkAlphabeticalOrder());
size_t fromListIndex = 0, toListIndex = 0;
while (fromListIndex < fromList.size() && toListIndex < size()) {
CustomFilterParameter* paramFrom = fromList.at(fromListIndex).get();
CustomFilterParameter* paramTo = at(toListIndex).get();
if (paramFrom->name() == paramTo->name()) {
resultList.append(paramTo->blend(paramFrom, progress, frameSize));
++fromListIndex;
++toListIndex;
continue;
}
if (codePointCompareLessThan(paramFrom->name(), paramTo->name())) {
resultList.append(paramFrom);
++fromListIndex;
continue;
}
resultList.append(paramTo);
++toListIndex;
}
for (; fromListIndex < fromList.size(); ++fromListIndex)
resultList.append(fromList.at(fromListIndex));
for (; toListIndex < size(); ++toListIndex)
resultList.append(at(toListIndex));
ASSERT(resultList.checkAlphabeticalOrder());
}
} // namespace WebCore
#endif // ENABLE(CSS_SHADERS)
/*
* Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef CustomFilterParameterList_h
#define CustomFilterParameterList_h
#if ENABLE(CSS_SHADERS)
#include "LayoutTypes.h"
#include <wtf/Vector.h>
namespace WebCore {
class CustomFilterParameter;
typedef Vector<RefPtr<CustomFilterParameter> > CustomFilterParameterListBase;
class CustomFilterParameterList : public CustomFilterParameterListBase {
public:
CustomFilterParameterList();
explicit CustomFilterParameterList(size_t);
bool checkAlphabeticalOrder() const;
void blend(const CustomFilterParameterList& from, double progress, const LayoutSize&, CustomFilterParameterList& resultList) const;
bool operator==(const CustomFilterParameterList&) const;
};
} // namespace WebCore
#endif // ENABLE(CSS_SHADERS)
#endif // CustomFilterParameterList_h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment