Пример #1
0
void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
    const FloatRect& src, ColorSpace, CompositeOperator op, BlendMode blendMode)
{
    if (m_pixmap->isNull())
        return;

    FloatRect normalizedSrc = src.normalized();
    FloatRect normalizedDst = dst.normalized();

    CompositeOperator previousOperator = ctxt->compositeOperation();
    BlendMode previousBlendMode = ctxt->blendModeOperation();
    ctxt->setCompositeOperation(op, blendMode);

    if (ctxt->hasShadow()) {
        ShadowBlur shadow(ctxt->state());
        GraphicsContext* shadowContext = shadow.beginShadowLayer(ctxt, normalizedDst);
        if (shadowContext) {
            QPainter* shadowPainter = shadowContext->platformContext();
            shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
            shadow.endShadowLayer(ctxt);
        }
    }

    ctxt->platformContext()->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
    ctxt->setCompositeOperation(previousOperator, previousBlendMode);
}
void ImageBufferData::draw(GraphicsContext* thisContext, GraphicsContext* otherContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, bool useLowQualityScale) const
{
    const FloatRect normDestRect = destRect.normalized();
    const FloatRect normSrcRect = srcRect.normalized();

    if (normSrcRect.isEmpty() || normDestRect.isEmpty())
        return; // Nothing to draw.

    if (thisContext->platformContext()->isEmpty() && platformBufferHandle(m_buffer)) {
        CompositeOperator oldOperator = otherContext->compositeOperation();
        otherContext->setCompositeOperation(op);
        otherContext->platformContext()->drawBuffer(m_buffer, normDestRect, normSrcRect);
        otherContext->setCompositeOperation(oldOperator);
    } else {
        dispatchSyncCompositingMessage(BlackBerry::Platform::createFunctionCallMessage(
            &flushAndDraw, this, otherContext, styleColorSpace, normDestRect, normSrcRect, op, useLowQualityScale));
    }
}
Пример #3
0
// Drawing Routines
void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
                       const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op)
{
    QRectF normalizedDst = dst.normalized();
    QRectF normalizedSrc = src.normalized();

    startAnimation();

    if (normalizedSrc.isEmpty() || normalizedDst.isEmpty())
        return;

    QPixmap* image = nativeImageForCurrentFrame();
    if (!image)
        return;

    if (mayFillWithSolidColor()) {
        fillWithSolidColor(ctxt, normalizedDst, solidColor(), styleColorSpace, op);
        return;
    }

#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
    normalizedSrc = adjustSourceRectForDownSampling(normalizedSrc, image->size());
#endif

    CompositeOperator previousOperator = ctxt->compositeOperation();
    ctxt->setCompositeOperation(!image->hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);

    if (ctxt->hasShadow()) {
        ShadowBlur* shadow = ctxt->shadowBlur();
        GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
        if (shadowContext) {
            QPainter* shadowPainter = shadowContext->platformContext();
            shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc);
            shadow->endShadowLayer(ctxt);
        }
    }

    ctxt->platformContext()->drawPixmap(normalizedDst, *image, normalizedSrc);

    ctxt->setCompositeOperation(previousOperator);

    if (imageObserver())
        imageObserver()->didDraw(this);
}
Пример #4
0
// Drawing Routines
void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
                       const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op)
{
    QRectF normalizedDst = dst.normalized();
    QRectF normalizedSrc = src.normalized();

    startAnimation();

    if (normalizedSrc.isEmpty() || normalizedDst.isEmpty())
        return;

    QPixmap* image = nativeImageForCurrentFrame();
    if (!image)
        return;

    if (mayFillWithSolidColor()) {
        fillWithSolidColor(ctxt, normalizedDst, solidColor(), styleColorSpace, op);
        return;
    }

    CompositeOperator previousOperator = ctxt->compositeOperation();
    ctxt->setCompositeOperation(!image->hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);

    ContextShadow* shadow = ctxt->contextShadow();
    if (shadow->m_type != ContextShadow::NoShadow) {
        QPainter* shadowPainter = shadow->beginShadowLayer(ctxt, normalizedDst);
        if (shadowPainter) {
            shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255);
            shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc);
            shadow->endShadowLayer(ctxt);
        }
    }

    ctxt->platformContext()->drawPixmap(normalizedDst, *image, normalizedSrc);

    ctxt->setCompositeOperation(previousOperator);

    if (imageObserver())
        imageObserver()->didDraw(this);
}
Пример #5
0
void BitmapImage::readyWRATHWidgets(PaintedWidgetsOfWRATHHandleT<Image>& handle, ContextOfWRATH *ctx,
                                    const FloatRect& dst, const FloatRect& src,
                                    ColorSpace styleColorSpace, CompositeOperator op)
{
    BitmapImage_readyWRATHWidgets *d(BitmapImage_readyWRATHWidgets::object(this, handle));

    ContextOfWRATH::AutoPushNode autoPushRoot(ctx, d->m_root_node);

    d->m_solid_color.visible(false);
    if (d->m_image_rect_item.widget())
        d->m_image_rect_item.widget()->visible(false);

    FloatRect normalizedDst = dst.normalized();
    FloatRect normalizedSrc = src.normalized();

    startAnimation();

    if (normalizedSrc.isEmpty() || normalizedDst.isEmpty())
        return;

    NativeImagePtr nativeImage = nativeImageForCurrentFrame();
    if (!nativeImage)
        return;

    // "Hardcode" the requirement for the underlying wrath image type to WRATHImage.
    // The reason is support for setting texture coordinates, which isn't possible for WRATHCompoundImage
    WRATHImage* image = nativeImage->getWrathImage();
    if (!image)
        return;

    if (mayFillWithSolidColor()) {
        d->m_solid_color.visible(true);
        readyWRATHWidgetSolidColor(d->m_solid_color, ctx, this, normalizedDst, solidColor(), styleColorSpace, op);
        return;
    }

    // ImageRectOfWRATH methods handle changing the op with respect to composite operator
    /*
    CompositeOperator previousOperator = ctxt->compositeOperation();
    ctxt->setCompositeOperation(!image->hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
    */
    if(!nativeImage->hasAlpha() && op == CompositeSourceOver)
      {
        op=CompositeCopy;
      }
    
    /*
      [WRATH-DANGER]: No shadows

    ContextShadow* shadow = ctxt->contextShadow();
    if (shadow->m_type != ContextShadow::NoShadow) {
        QPainter* shadowPainter = shadow->beginShadowLayer(ctxt, normalizedDst);
        if (shadowPainter) {
            shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255);
            shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc);
            shadow->endShadowLayer(ctxt);
        }
    }
    */

    /*
      [WRATH-DANGER]: Possible rounding errors from converting to IntRect
     */
    d->m_image_rect_item.update(ctx, nativeImage,
                                normalizedDst, IntRect(normalizedSrc),
                                op);
    if (d->m_image_rect_item.widget())
      d->m_image_rect_item.widget()->visible(true);

    /*
      ctxt->platformContext()->drawPixmap(normalizedDst, *image, normalizedSrc);
    */

    /*
    ctxt->setCompositeOperation(previousOperator);
    */

    if (imageObserver())
        imageObserver()->didDraw(this);
}