2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) 2013 Google Inc. All rights reserved.
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.
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.
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.
23 #include "platform/graphics/filters/FETile.h"
25 #include "SkTileImageFilter.h"
27 #include "platform/graphics/filters/Filter.h"
28 #include "platform/graphics/filters/SkiaImageFilterBuilder.h"
29 #include "platform/text/TextStream.h"
33 FETile::FETile(Filter* filter)
34 : FilterEffect(filter)
38 PassRefPtr<FETile> FETile::create(Filter* filter)
40 return adoptRef(new FETile(filter));
43 FloatRect FETile::mapPaintRect(const FloatRect& rect, bool forward)
45 return forward ? maxEffectRect() : inputEffect(0)->maxEffectRect();
48 static FloatRect getRect(FilterEffect* effect)
50 FloatRect result = effect->filter()->filterRegion();
51 FloatRect boundaries = effect->effectBoundaries();
53 result.setX(boundaries.x());
55 result.setY(boundaries.y());
56 if (effect->hasWidth())
57 result.setWidth(boundaries.width());
58 if (effect->hasHeight())
59 result.setHeight(boundaries.height());
63 PassRefPtr<SkImageFilter> FETile::createImageFilter(SkiaImageFilterBuilder* builder)
65 RefPtr<SkImageFilter> input(builder->build(inputEffect(0), operatingColorSpace()));
66 FloatRect srcRect = inputEffect(0) ? getRect(inputEffect(0)) : filter()->filterRegion();
67 FloatRect dstRect = getRect(this);
68 return adoptRef(SkTileImageFilter::Create(srcRect, dstRect, input.get()));
71 TextStream& FETile::externalRepresentation(TextStream& ts, int indent) const
73 writeIndent(ts, indent);
75 FilterEffect::externalRepresentation(ts);
77 inputEffect(0)->externalRepresentation(ts, indent + 1);