예제 #1
0
void FEOffset::apply(Filter* filter)
{
    m_in->apply(filter);
    if (!m_in->resultImage())
        return;

    GraphicsContext* filterContext = getEffectContext();
    if (!filterContext)
        return;

    setIsAlphaImage(m_in->isAlphaImage());

    FloatRect sourceImageRect = filter->sourceImageRect();
    sourceImageRect.scale(filter->filterResolution().width(), filter->filterResolution().height());

    if (filter->effectBoundingBoxMode()) {
        m_dx *= sourceImageRect.width();
        m_dy *= sourceImageRect.height();
    }
    m_dx *= filter->filterResolution().width();
    m_dy *= filter->filterResolution().height();

    FloatRect dstRect = FloatRect(m_dx + m_in->scaledSubRegion().x() - scaledSubRegion().x(),
                                  m_dy + m_in->scaledSubRegion().y() - scaledSubRegion().y(),
                                  m_in->scaledSubRegion().width(),
                                  m_in->scaledSubRegion().height());

    filterContext->drawImageBuffer(m_in->resultImage(), DeviceColorSpace, dstRect);
}
예제 #2
0
GraphicsContext* FilterEffect::getEffectContext()
{
    IntRect bufferRect = enclosingIntRect(scaledSubRegion());
    m_effectBuffer = ImageBuffer::create(bufferRect.size(), LinearRGB);
    return m_effectBuffer->context();
}
예제 #3
0
FloatRect FilterEffect::calculateDrawingRect(const FloatRect& srcRect)
{
    FloatPoint startPoint = FloatPoint(srcRect.x() - scaledSubRegion().x(), srcRect.y() - scaledSubRegion().y());
    FloatRect drawingRect = FloatRect(startPoint, srcRect.size());
    return drawingRect;
}
예제 #4
0
IntRect FilterEffect::calculateDrawingIntRect(const FloatRect& effectRect)
{
    IntPoint location = roundedIntPoint(FloatPoint(scaledSubRegion().x() - effectRect.x(),
                                                   scaledSubRegion().y() - effectRect.y()));
    return IntRect(location, resultImage()->size());
}