void RenderSnapshottedPlugIn::paintSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset) { Image* image = m_snapshotResource->image().get(); if (!image || image->isNull()) return; LayoutUnit cWidth = contentWidth(); LayoutUnit cHeight = contentHeight(); if (!cWidth || !cHeight) return; GraphicsContext& context = paintInfo.context(); LayoutSize contentSize(cWidth, cHeight); LayoutPoint contentLocation = location() + paintOffset; contentLocation.move(borderLeft() + paddingLeft(), borderTop() + paddingTop()); LayoutRect rect(contentLocation, contentSize); IntRect alignedRect = snappedIntRect(rect); if (alignedRect.width() <= 0 || alignedRect.height() <= 0) return; InterpolationQuality interpolation = chooseInterpolationQuality(context, *image, image, alignedRect.size()); ImageOrientationDescription orientationDescription(shouldRespectImageOrientation(), style().imageOrientation()); context.drawImage(*image, alignedRect, ImagePaintingOptions(orientationDescription, interpolation)); }
void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect) { IntRect alignedRect = pixelSnappedIntRect(rect); if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || alignedRect.width() <= 0 || alignedRect.height() <= 0) return; RefPtr<Image> img = m_imageResource->image(alignedRect.width(), alignedRect.height()); if (!img || img->isNull()) return; Image* image = img.get(); InterpolationQuality interpolationQuality = chooseInterpolationQuality(context, image, image, alignedRect.size()); TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "data", InspectorPaintImageEvent::data(*this)); InterpolationQuality previousInterpolationQuality = context->imageInterpolationQuality(); context->setImageInterpolationQuality(interpolationQuality); context->drawImage(image, alignedRect, CompositeSourceOver, shouldRespectImageOrientation()); context->setImageInterpolationQuality(previousInterpolationQuality); }