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#include "config.h" 23 24#if ENABLE(FILTERS) 25#include "FEMerge.h" 26 27#include "Filter.h" 28#include "GraphicsContext.h" 29#include "TextStream.h" 30 31namespace WebCore { 32 33FEMerge::FEMerge(Filter* filter) 34 : FilterEffect(filter) 35{ 36} 37 38PassRefPtr<FEMerge> FEMerge::create(Filter* filter) 39{ 40 return adoptRef(new FEMerge(filter)); 41} 42 43void FEMerge::platformApplySoftware() 44{ 45 unsigned size = numberOfEffectInputs(); 46 ASSERT(size > 0); 47 48 ImageBuffer* resultImage = createImageBufferResult(); 49 if (!resultImage) 50 return; 51 52 GraphicsContext* filterContext = resultImage->context(); 53 for (unsigned i = 0; i < size; ++i) { 54 FilterEffect* in = inputEffect(i); 55 filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect())); 56 } 57} 58 59void FEMerge::dump() 60{ 61} 62 63TextStream& FEMerge::externalRepresentation(TextStream& ts, int indent) const 64{ 65 writeIndent(ts, indent); 66 ts << "[feMerge"; 67 FilterEffect::externalRepresentation(ts); 68 unsigned size = numberOfEffectInputs(); 69 ASSERT(size > 0); 70 ts << " mergeNodes=\"" << size << "\"]\n"; 71 for (unsigned i = 0; i < size; ++i) 72 inputEffect(i)->externalRepresentation(ts, indent + 1); 73 return ts; 74} 75 76} // namespace WebCore 77 78#endif // ENABLE(FILTERS) 79