1 /* 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer. 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. 15 * 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 27 * SUCH DAMAGE. 28 */ 29 30 #ifndef ValidatedCustomFilterOperation_h 31 #define ValidatedCustomFilterOperation_h 32 33 #include "core/platform/graphics/filters/FilterOperation.h" 34 #include "core/platform/graphics/filters/custom/CustomFilterConstants.h" 35 #include "core/platform/graphics/filters/custom/CustomFilterParameterList.h" 36 37 namespace WebCore { 38 39 class CustomFilterValidatedProgram; 40 41 class ValidatedCustomFilterOperation : public FilterOperation { 42 public: 43 static PassRefPtr<ValidatedCustomFilterOperation> create(PassRefPtr<CustomFilterValidatedProgram> validatedProgram, 44 const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType) 45 { 46 return adoptRef(new ValidatedCustomFilterOperation(validatedProgram, sortedParameters, meshRows, meshColumns, meshType)); 47 } 48 49 virtual ~ValidatedCustomFilterOperation(); 50 51 virtual bool affectsOpacity() const { return true; } 52 virtual bool movesPixels() const { return true; } 53 54 virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress, bool blendToPassthrough = false); 55 56 CustomFilterValidatedProgram* validatedProgram() const { return m_validatedProgram.get(); } 57 const CustomFilterParameterList& parameters() const { return m_parameters; } 58 59 unsigned meshRows() const { return m_meshRows; } 60 unsigned meshColumns() const { return m_meshColumns; } 61 62 CustomFilterMeshType meshType() const { return m_meshType; } 63 64 private: 65 virtual bool operator==(const FilterOperation& o) const 66 { 67 if (!isSameType(o)) 68 return false; 69 70 const ValidatedCustomFilterOperation* other = static_cast<const ValidatedCustomFilterOperation*>(&o); 71 return m_validatedProgram.get() == other->m_validatedProgram.get() 72 && m_meshRows == other->m_meshRows 73 && m_meshColumns == other->m_meshColumns 74 && m_meshType == other->m_meshType 75 && m_parameters == other->m_parameters; 76 } 77 78 ValidatedCustomFilterOperation(PassRefPtr<CustomFilterValidatedProgram>, const CustomFilterParameterList&, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType); 79 80 RefPtr<CustomFilterValidatedProgram> m_validatedProgram; 81 82 CustomFilterParameterList m_parameters; 83 unsigned m_meshRows; 84 unsigned m_meshColumns; 85 CustomFilterMeshType m_meshType; 86 }; 87 88 } // namespace WebCore 89 90 91 #endif // ValidatedCustomFilterOperation_h 92