2
* Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
3
* Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public License
16
* along with this library; see the file COPYING.LIB. If not, write to
17
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
26
#include "AffineTransform.h"
28
#include "GraphicsContext.h"
30
#include "RenderTreeAsText.h"
31
#include "SVGRenderingContext.h"
32
#include "TextStream.h"
36
FETile::FETile(Filter* filter)
37
: FilterEffect(filter)
41
PassRefPtr<FETile> FETile::create(Filter* filter)
43
return adoptRef(new FETile(filter));
46
void FETile::platformApplySoftware()
48
// FIXME: See bug 47315. This is a hack to work around a compile failure, but is incorrect behavior otherwise.
50
FilterEffect* in = inputEffect(0);
52
ImageBuffer* resultImage = createImageBufferResult();
56
setIsAlphaImage(in->isAlphaImage());
58
// Source input needs more attention. It has the size of the filterRegion but gives the
59
// size of the cutted sourceImage back. This is part of the specification and optimization.
60
FloatRect tileRect = in->maxEffectRect();
61
FloatPoint inMaxEffectLocation = tileRect.location();
62
FloatPoint maxEffectLocation = maxEffectRect().location();
63
if (in->filterEffectType() == FilterEffectTypeSourceInput) {
64
Filter* filter = this->filter();
65
tileRect = filter->filterRegion();
66
tileRect.scale(filter->filterResolution().width(), filter->filterResolution().height());
69
OwnPtr<ImageBuffer> tileImage;
70
if (!SVGRenderingContext::createImageBufferForPattern(tileRect, tileRect, tileImage, ColorSpaceDeviceRGB, filter()->renderingMode()))
73
GraphicsContext* tileImageContext = tileImage->context();
74
tileImageContext->translate(-inMaxEffectLocation.x(), -inMaxEffectLocation.y());
75
tileImageContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, in->absolutePaintRect().location());
77
RefPtr<Pattern> pattern = Pattern::create(tileImage->copyImage(CopyBackingStore), true, true);
79
AffineTransform patternTransform;
80
patternTransform.translate(inMaxEffectLocation.x() - maxEffectLocation.x(), inMaxEffectLocation.y() - maxEffectLocation.y());
81
pattern->setPatternSpaceTransform(patternTransform);
82
GraphicsContext* filterContext = resultImage->context();
83
filterContext->setFillPattern(pattern);
84
filterContext->fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()));
92
TextStream& FETile::externalRepresentation(TextStream& ts, int indent) const
94
writeIndent(ts, indent);
96
FilterEffect::externalRepresentation(ts);
98
inputEffect(0)->externalRepresentation(ts, indent + 1);
103
} // namespace WebCore
105
#endif // ENABLE(FILTERS)