void GraphicsContext::drawImage(Image& image, const FloatRect& destination, const ImagePaintingOptions& imagePaintingOptions) { #if PLATFORM(IOS) FloatRect srcRect(FloatPoint(), image.originalSize()); #else FloatRect srcRect(FloatPoint(), image.size()); #endif drawImage(image, destination, srcRect, imagePaintingOptions); }
void GraphicsContext::drawImage(Image* image, ColorSpace colorSpace, const FloatRect& destination, const ImagePaintingOptions& imagePaintingOptions) { if (!image) return; #if PLATFORM(IOS) FloatRect srcRect(FloatPoint(), image->originalSize()); #else FloatRect srcRect(FloatPoint(), image->size()); #endif drawImage(image, colorSpace, destination, srcRect, imagePaintingOptions); }
bool TOSMagnify::CreateImage(BPoint mouseLoc, bool force) { bool created = false; if (Window() && Window()->Lock()) { int32 width, height; fParent->PixelCount(&width, &height); int32 pixelSize = fParent->PixelSize(); BRect srcRect(0, 0, width - 1, height - 1); srcRect.OffsetBy(mouseLoc.x - (width / 2), mouseLoc.y - (height / 2)); if (force || CopyScreenRect(srcRect)) { srcRect.OffsetTo(BPoint(0, 0)); BRect destRect(Bounds()); DrawBitmap(fBitmap, srcRect, destRect); DrawGrid(width, height, destRect, pixelSize); DrawSelection(); Sync(); created = true; } Window()->Unlock(); } else printf("window problem\n"); return created; }
void SVGImagePainter::paintForeground(const PaintInfo& paintInfo) { const LayoutImageResource* imageResource = m_layoutSVGImage.imageResource(); IntSize imageViewportSize = expandedIntSize(computeImageViewportSize()); if (imageViewportSize.isEmpty()) return; RefPtr<Image> image = imageResource->image( imageViewportSize, m_layoutSVGImage.style()->effectiveZoom()); FloatRect destRect = m_layoutSVGImage.objectBoundingBox(); FloatRect srcRect(0, 0, image->width(), image->height()); SVGImageElement* imageElement = toSVGImageElement(m_layoutSVGImage.element()); imageElement->preserveAspectRatio()->currentValue()->transformRect(destRect, srcRect); InterpolationQuality interpolationQuality = InterpolationDefault; interpolationQuality = ImageQualityController::imageQualityController() ->chooseInterpolationQuality( m_layoutSVGImage, image.get(), image.get(), LayoutSize(destRect.size())); InterpolationQuality previousInterpolationQuality = paintInfo.context.imageInterpolationQuality(); paintInfo.context.setImageInterpolationQuality(interpolationQuality); paintInfo.context.drawImage(image.get(), destRect, &srcRect); paintInfo.context.setImageInterpolationQuality(previousInterpolationQuality); }
//===================================================================================================> // bool TiledBackground::draw ( IDXSPRITE spriteobj, const RECT* dstRect ) { //todo sas - not quite right, just yet. This should NOT stretch to the dstSurface's full size // so... if dstRect isn't given... fool it into drawing in same aspect as srcSurface Rect srcRect( 0, 0, myTiledBgTexture.width(), myTiledBgTexture.height() ); if (dstRect == NULL) dstRect = &srcRect; Rect dRect = *dstRect; //todo: this isn't right. limit to min's. dRect.bottom = min( dRect.bottom, srcRect.bottom ); dRect.right = min( dRect.right, srcRect.right); //HRESULT hr = myDevice->StretchRect( myTiledBgSurface, NULL, dstSurface, &dRect, D3DTEXF_NONE ); //HRESULT hr = spriteobj->Draw( myTiledBgTexture, NULL, NULL ); //TODO: Need to change locations D3DXVECTOR3 vPos( 0, 0, 0 ); HRESULT hr = myTiledBgTexture.drawStretch( spriteobj, &srcRect, &dRect ); //drawMySpriteMap( spriteobj ); return SUCCEEDED( hr ); //TODO }
void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, CompositeOperator op) { FloatRect srcRect(src); FloatRect dstRect(dst); if (dstRect.width() == 0.0f || dstRect.height() == 0.0f || srcRect.width() == 0.0f || srcRect.height() == 0.0f) return; startAnimation(); cairo_surface_t* image = frameAtIndex(m_currentFrame); if (!image) // If it's too early we won't have an image yet. return; if (mayFillWithSolidColor()) { fillWithSolidColor(context, dstRect, solidColor(), op); return; } IntSize selfSize = size(); cairo_t* cr = context->platformContext(); cairo_save(cr); // Set the compositing operation. if (op == CompositeSourceOver && !frameHasAlphaAtIndex(m_currentFrame)) context->setCompositeOperation(CompositeCopy); else context->setCompositeOperation(op); // If we're drawing a sub portion of the image or scaling then create // a pattern transformation on the image and draw the transformed pattern. // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image); // To avoid the unwanted gradient effect (#14017) we use // CAIRO_FILTER_NEAREST now, but the real fix will be to have // CAIRO_EXTEND_PAD implemented for surfaces in Cairo allowing us to still // use bilinear filtering cairo_pattern_set_filter(pattern, CAIRO_FILTER_NEAREST); float scaleX = srcRect.width() / dstRect.width(); float scaleY = srcRect.height() / dstRect.height(); cairo_matrix_t matrix = { scaleX, 0, 0, scaleY, srcRect.x(), srcRect.y() }; cairo_pattern_set_matrix(pattern, &matrix); // Draw the image. cairo_translate(cr, dstRect.x(), dstRect.y()); cairo_set_source(cr, pattern); cairo_pattern_destroy(pattern); cairo_rectangle(cr, 0, 0, dstRect.width(), dstRect.height()); cairo_clip(cr); cairo_paint_with_alpha(cr, context->getAlpha()); cairo_restore(cr); if (imageObserver()) imageObserver()->didDraw(this); }
void RenderSVGImage::paint(PaintInfo& paintInfo, int, int) { if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN) return; paintInfo.context->save(); paintInfo.context->concatCTM(localTransform()); if (paintInfo.phase == PaintPhaseForeground) { SVGResourceFilter* filter = 0; PaintInfo savedInfo(paintInfo); prepareToRenderSVGContent(this, paintInfo, m_localBounds, filter); FloatRect destRect = m_localBounds; FloatRect srcRect(0, 0, image()->width(), image()->height()); SVGImageElement* imageElt = static_cast<SVGImageElement*>(node()); if (imageElt->preserveAspectRatio()->align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio()); paintInfo.context->drawImage(image(), destRect, srcRect); finishRenderSVGContent(this, paintInfo, m_localBounds, filter, savedInfo.context); } paintInfo.context->restore(); }
// add the entire signal b to this signal, at the subpixel destination offset. // void MLSignal::add2D(const MLSignal& b, const Vec2& destOffset) { MLSignal& a = *this; Vec2 iDestOffset, fDestOffset; destOffset.getIntAndFracParts(iDestOffset, fDestOffset); int destX = iDestOffset[0]; int destY = iDestOffset[1]; float srcPosFX = fDestOffset[0]; float srcPosFY = fDestOffset[1]; MLRect srcRect(0, 0, b.getWidth() + 1, b.getHeight() + 1); // add (1, 1) for interpolation MLRect destRect = srcRect.translated(iDestOffset).intersect(getBoundsRect()); for(int j=destRect.top(); j<destRect.bottom(); ++j) { for(int i=destRect.left(); i<destRect.right(); ++i) { a(i, j) += b.getInterpolatedLinear(i - destX - srcPosFX, j - destY - srcPosFY); } } setConstant(false); }
void ClientLayerManager::MakeSnapshotIfRequired() { if (!mShadowTarget) { return; } if (mWidget) { if (CompositorChild* remoteRenderer = GetRemoteRenderer()) { nsIntRect bounds = ToOutsideIntRect(mShadowTarget->GetClipExtents()); SurfaceDescriptor inSnapshot; if (!bounds.IsEmpty() && mForwarder->AllocSurfaceDescriptor(bounds.Size().ToIntSize(), gfxContentType::COLOR_ALPHA, &inSnapshot) && remoteRenderer->SendMakeSnapshot(inSnapshot, bounds)) { RefPtr<DataSourceSurface> surf = GetSurfaceForDescriptor(inSnapshot); DrawTarget* dt = mShadowTarget->GetDrawTarget(); Rect dstRect(bounds.x, bounds.y, bounds.width, bounds.height); Rect srcRect(0, 0, bounds.width, bounds.height); dt->DrawSurface(surf, dstRect, srcRect, DrawSurfaceOptions(), DrawOptions(1.0f, CompositionOp::OP_OVER)); } mForwarder->DestroySharedSurface(&inSnapshot); } } mShadowTarget = nullptr; }
void Viewport::_render() { april::rendersys->setTextureBlendMode(april::BM_DEFAULT); grect drawRect(0.0f, 0.0f, (float)this->rect->width, (float)this->rect->height); grect srcRect(0.0f, 0.0f, 1.0f, 1.0f); this->_renderTexture(drawRect, srcRect, this->texture, 255); }
void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op) { FloatRect srcRect(src); FloatRect dstRect(dst); if (dstRect.width() == 0.0f || dstRect.height() == 0.0f || srcRect.width() == 0.0f || srcRect.height() == 0.0f) return; startAnimation(); cairo_surface_t* image = frameAtIndex(m_currentFrame); if (!image) // If it's too early we won't have an image yet. return; if (mayFillWithSolidColor()) { fillWithSolidColor(context, dstRect, solidColor(), styleColorSpace, op); return; } context->save(); // Set the compositing operation. if (op == CompositeSourceOver && !frameHasAlphaAtIndex(m_currentFrame)) context->setCompositeOperation(CompositeCopy); else context->setCompositeOperation(op); context->platformContext()->drawSurfaceToContext(image, dstRect, srcRect, context); context->restore(); if (imageObserver()) imageObserver()->didDraw(this); }
void MythPainter::DrawTextLayout(const QRect & canvasRect, const LayoutVector & layouts, const FormatVector & formats, const MythFontProperties & font, int alpha, const QRect & destRect) { if (canvasRect.isNull()) return; QRect canvas(canvasRect); QRect dest(destRect); MythImage *im = GetImageFromTextLayout(layouts, formats, font, canvas, dest); if (!im) { LOG(VB_GENERAL, LOG_ERR, QString("MythPainter::DrawTextLayout: " "Unable to create image.")); return; } if (im->isNull()) { LOG(VB_GENERAL, LOG_DEBUG, QString("MythPainter::DrawTextLayout: " "Rendered image is null.")); im->DecrRef(); return; } QRect srcRect(0, 0, dest.width(), dest.height()); DrawImage(dest, im, srcRect, alpha); im->DecrRef(); }
void Scalpel3DOScreen::rawBlitFrom(const Graphics::Surface &src, const Common::Point &pt) { Common::Rect srcRect(0, 0, src.w, src.h); Common::Rect destRect(pt.x, pt.y, pt.x + src.w, pt.y + src.h); addDirtyRect(destRect); copyRectToSurface(src, destRect.left, destRect.top, srcRect); }
void RenderSVGImage::paint(PaintInfo& paintInfo, int, int) { if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN) return; paintInfo.context->save(); paintInfo.context->concatCTM(localToParentTransform()); if (paintInfo.phase == PaintPhaseForeground) { SVGResourceFilter* filter = 0; PaintInfo savedInfo(paintInfo); if (prepareToRenderSVGContent(this, paintInfo, m_localBounds, filter)) { FloatRect destRect = m_localBounds; FloatRect srcRect(0, 0, image()->width(), image()->height()); SVGImageElement* imageElt = static_cast<SVGImageElement*>(node()); if (imageElt->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) imageElt->preserveAspectRatio().transformRect(destRect, srcRect); paintInfo.context->drawImage(image(), DeviceColorSpace, destRect, srcRect); } finishRenderSVGContent(this, paintInfo, filter, savedInfo.context); } if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth()) paintOutline(paintInfo.context, 0, 0, width(), height(), style()); paintInfo.context->restore(); }
// Drawing Routines void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatRect& src, CompositeOperator op) { QPixmap* image = nativeImageForCurrentFrame(); if (!image) return; if (mayFillWithSolidColor()) { fillWithSolidColor(ctxt, dst, solidColor(), op); return; } IntSize selfSize = size(); FloatRect srcRect(src); FloatRect dstRect(dst); ctxt->save(); // Set the compositing operation. ctxt->setCompositeOperation(op); QPainter* painter(ctxt->platformContext()); // Test using example site at // http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html painter->drawPixmap(dst, *image, src); ctxt->restore(); startAnimation(); }
void UBMagnifier::grabPoint(const QPoint &pGrab) { QMatrix transM = UBApplication::boardController->controlView()->matrix(); updPointGrab = pGrab; QPointF itemPos = gView->mapFromGlobal(pGrab); qreal zWidth = width() / (params.zoom * transM.m11()); qreal zWidthHalf = zWidth / 2; qreal zHeight = height() / (params.zoom * transM.m22()); qreal zHeightHalf = zHeight / 2; QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y()))); float x = pfScLtF.x() - zWidthHalf; float y = pfScLtF.y() - zHeightHalf; QPointF leftTop(x,y); QPointF rightBottom(x + zWidth, y + zHeight); QRectF srcRect(leftTop, rightBottom); QPixmap newPixMap(QSize(width(), height())); QPainter painter(&newPixMap); UBApplication::boardController->activeScene()->render(&painter, QRectF(0,0,width(),height()), srcRect); painter.end(); // pMap.fill(Qt::transparent); pMap = newPixMap; pMap.setMask(bmpMask); update(); }
void RenderSVGImage::paint(PaintInfo& paintInfo, const LayoutPoint&) { if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || !m_imageResource->hasImage()) return; FloatRect boundingBox = repaintRectInLocalCoordinates(); if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTransform, paintInfo)) return; PaintInfo childPaintInfo(paintInfo); bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == PaintPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline); if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) { GraphicsContextStateSaver stateSaver(*childPaintInfo.context); childPaintInfo.applyTransform(m_localTransform); if (childPaintInfo.phase == PaintPhaseForeground) { SVGRenderingContext renderingContext(this, childPaintInfo); if (renderingContext.isRenderingPrepared()) { RefPtr<Image> image = m_imageResource->image(); FloatRect destRect = m_objectBoundingBox; FloatRect srcRect(0, 0, image->width(), image->height()); SVGImageElement* imageElement = static_cast<SVGImageElement*>(node()); imageElement->preserveAspectRatio().transformRect(destRect, srcRect); childPaintInfo.context->drawImage(image.get(), ColorSpaceDeviceRGB, destRect, srcRect); } } if (drawsOutline) paintOutline(childPaintInfo.context, IntRect(boundingBox)); } }
void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op) { FloatRect srcRect(src); FloatRect dstRect(dst); if (dstRect.width() == 0.0f || dstRect.height() == 0.0f || srcRect.width() == 0.0f || srcRect.height() == 0.0f) return; startAnimation(); cairo_surface_t* image = frameAtIndex(m_currentFrame); if (!image) // If it's too early we won't have an image yet. return; //+EAWebKitChange //5/30/2012 #if ENABLE(IMAGE_COMPRESSION) // Check if this is a compressed surface. const void* pCompressedSurfaceUserData = cairo_surface_get_user_data (image, (cairo_user_data_key_t*) ImageCompressionGetUserDataKey()); #endif //-EAWebKitChange if (mayFillWithSolidColor()) { fillWithSolidColor(context, dstRect, solidColor(), styleColorSpace, op); //+EAWebKitChange //5/30/2012 #if ENABLE(IMAGE_COMPRESSION) if (pCompressedSurfaceUserData) cairo_surface_destroy(image); #endif //-EAWebKitChange return; } context->save(); // Set the compositing operation. if (op == CompositeSourceOver && !frameHasAlphaAtIndex(m_currentFrame)) context->setCompositeOperation(CompositeCopy); else context->setCompositeOperation(op); context->platformContext()->drawSurfaceToContext(image, dstRect, srcRect, context); context->restore(); if (imageObserver()) imageObserver()->didDraw(this); //+EAWebKitChange //5/30/2012 #if ENABLE(IMAGE_COMPRESSION) if (pCompressedSurfaceUserData) cairo_surface_destroy(image); #endif //-EAWebKitChange }
void FEImage::determineAbsolutePaintRect() { ASSERT(m_image); FloatRect srcRect(FloatPoint(), m_image->size()); FloatRect paintRect(m_absoluteSubregion); m_preserveAspectRatio.transformRect(paintRect, srcRect); paintRect.intersect(maxEffectRect()); setAbsolutePaintRect(enclosingIntRect(paintRect)); }
//! [3] void DBScreen::blit(const QImage &image, const QPoint &topLeft, const QRegion ®ion) { QVector<QRect> rects = region.rects(); for (int i = 0; i < rects.size(); i++) { QRect destRect = rects.at(i); QRect srcRect(destRect.x()-topLeft.x(), destRect.y()-topLeft.y(), destRect.width(), destRect.height()); painter->drawImage(destRect.topLeft(), image, srcRect); } }
void BaseSurface::SHtransBlitFrom(const Graphics::Surface &src, const Common::Point &pt, bool flipped, int overrideColor, int scaleVal) { Common::Rect srcRect(0, 0, src.w, src.h); Common::Rect destRect(pt.x, pt.y, pt.x + src.w * SCALE_THRESHOLD / scaleVal, pt.y + src.h * SCALE_THRESHOLD / scaleVal); Graphics::Screen::transBlitFrom(src, srcRect, destRect, TRANSPARENCY, flipped, overrideColor); }
void PictureTextCBox::Draw(const Point2i &/*mousePosition*/) { Surface & video_window = GetMainWindow(); if (m_value) { uint enabled_x = GetPositionX() + (GetSizeX() - m_enabled.GetWidth())/2 ; uint enabled_y = GetPositionY(); uint outside_x = std::max(uint(0), GetPositionX() - enabled_x); uint outside_y = std::max(uint(0), GetPositionY() - enabled_y); enabled_x += outside_x; enabled_y += outside_y; Rectanglei srcRect(outside_x, outside_y, m_enabled.GetWidth() - outside_x, m_enabled.GetHeight() - outside_y); video_window.Blit(m_enabled, srcRect, Point2i(enabled_x, enabled_y)); } else { uint disabled_x = GetPositionX() + (GetSizeX() - m_disabled_back.GetWidth())/2 ; uint disabled_y = GetPositionY(); uint outside_x = std::max(uint(0), GetPositionX() - disabled_x); uint outside_y = std::max(uint(0), GetPositionY() - disabled_y); disabled_x += outside_x; disabled_y += outside_y; Rectanglei srcRect(outside_x, outside_y, m_disabled_back.GetWidth() - outside_x, m_disabled_back.GetHeight() - outside_y); video_window.Blit(m_disabled_back, srcRect, Point2i(disabled_x, disabled_y)); } // center the image uint tmp_x = GetPositionX() + (GetSizeX() - m_image.GetWidth())/2 ; uint tmp_y = GetPositionY() + (m_enabled.GetHeight() - m_image.GetHeight())/2; video_window.Blit(m_image, Point2i(tmp_x, tmp_y)); Text::DrawCenterTop(GetPosition() + Point2i(GetSizeX()/2, GetSizeY() - Text::GetHeight())); if (!m_value) { uint disabled_x = GetPositionX() + (GetSizeX() - m_disabled_front.GetWidth())/2 ; uint disabled_y = GetPositionY() + (m_enabled.GetHeight() - m_disabled_front.GetHeight())/2; video_window.Blit(m_disabled_front, Point2i(disabled_x, disabled_y)); } }
void RenderSVGImage::paintForeground(PaintInfo& paintInfo) { RefPtr<Image> image = imageResource().image(); FloatRect destRect = m_objectBoundingBox; FloatRect srcRect(0, 0, image->width(), image->height()); imageElement().preserveAspectRatio().transformRect(destRect, srcRect); paintInfo.context->drawImage(image.get(), ColorSpaceDeviceRGB, destRect, srcRect); }
bool X11DataTextureSourceBasic::Update(gfx::DataSourceSurface* aSurface, nsIntRegion* aDestRegion, gfx::IntPoint* aSrcOffset) { // Reallocate our internal X11 surface if we don't have a DrawTarget yet, // or if we changed surface size or format since last update. if (!mBufferDrawTarget || (aSurface->GetSize() != mBufferDrawTarget->GetSize()) || (aSurface->GetFormat() != mBufferDrawTarget->GetFormat())) { nsRefPtr<gfxASurface> surf; gfxImageFormat imageFormat = SurfaceFormatToImageFormat(aSurface->GetFormat()); Display *display = DefaultXDisplay(); Screen *screen = DefaultScreenOfDisplay(display); XRenderPictFormat *xrenderFormat = gfxXlibSurface::FindRenderFormat(display, imageFormat); if (xrenderFormat) { surf = gfxXlibSurface::Create(screen, xrenderFormat, ThebesIntSize(aSurface->GetSize())); } if (!surf) { NS_WARNING("Couldn't create native surface, fallback to image surface"); surf = new gfxImageSurface(ThebesIntSize(aSurface->GetSize()), imageFormat); } mBufferDrawTarget = gfxPlatform::GetPlatform()-> CreateDrawTargetForSurface(surf, aSurface->GetSize()); } // Image contents have changed, upload to our DrawTarget // If aDestRegion is null, means we're updating the whole surface // Note : Incremental update with a source offset is only used on Mac. NS_ASSERTION(!aSrcOffset, "SrcOffset should not be used with linux OMTC basic"); if (aDestRegion) { nsIntRegionRectIterator iter(*aDestRegion); while (const nsIntRect* iterRect = iter.Next()) { IntRect srcRect(iterRect->x, iterRect->y, iterRect->width, iterRect->height); IntPoint dstPoint(iterRect->x, iterRect->y); // We're uploading regions to our buffer, so let's just copy contents over mBufferDrawTarget->CopySurface(aSurface, srcRect, dstPoint); } } else { // We're uploading the whole buffer, so let's just copy the full surface IntSize size = aSurface->GetSize(); mBufferDrawTarget->CopySurface(aSurface, IntRect(0, 0, size.width, size.height), IntPoint(0, 0)); } return true; }
void ClientLayerManager::MakeSnapshotIfRequired() { if (!mShadowTarget) { return; } if (mWidget) { if (CompositorBridgeChild* remoteRenderer = GetRemoteRenderer()) { // The compositor doesn't draw to a different sized surface // when there's a rotation. Instead we rotate the result // when drawing into dt LayoutDeviceIntRect outerBounds; mWidget->GetBounds(outerBounds); IntRect bounds = ToOutsideIntRect(mShadowTarget->GetClipExtents()); if (mTargetRotation) { bounds = RotateRect(bounds, outerBounds.ToUnknownRect(), mTargetRotation); } SurfaceDescriptor inSnapshot; if (!bounds.IsEmpty() && mForwarder->AllocSurfaceDescriptor(bounds.Size(), gfxContentType::COLOR_ALPHA, &inSnapshot)) { // Make a copy of |inSnapshot| because the call to send it over IPC // will call forget() on the Shmem inside, and zero it out. SurfaceDescriptor outSnapshot = inSnapshot; if (remoteRenderer->SendMakeSnapshot(inSnapshot, bounds)) { RefPtr<DataSourceSurface> surf = GetSurfaceForDescriptor(outSnapshot); DrawTarget* dt = mShadowTarget->GetDrawTarget(); Rect dstRect(bounds.x, bounds.y, bounds.width, bounds.height); Rect srcRect(0, 0, bounds.width, bounds.height); gfx::Matrix rotate = ComputeTransformForUnRotation(outerBounds.ToUnknownRect(), mTargetRotation); gfx::Matrix oldMatrix = dt->GetTransform(); dt->SetTransform(rotate * oldMatrix); dt->DrawSurface(surf, dstRect, srcRect, DrawSurfaceOptions(), DrawOptions(1.0f, CompositionOp::OP_OVER)); dt->SetTransform(oldMatrix); } mForwarder->DestroySurfaceDescriptor(&outSnapshot); } } } mShadowTarget = nullptr; }
bool FBORenderStrategy::render(Content* content, Image* renderImage) { if (!renderImage) return false; glWidget->makeCurrent(); QSize size(renderImage->width(), renderImage->height()); createFBOs(size); // Render frame into multisample FBO QPainter painter(multisampleFBO); painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, true); content->paintContent(&painter); painter.end(); // Blit from multisample to resolve FBO. // Rects are setup so the image is vertically flipped when blitted // so when we read the pixels back they are the right way up. // OpenGL does everything "upside down". QRect srcRect(0, 0, renderImage->width(), renderImage->height()); QRect dstRect(0, renderImage->height(), renderImage->width(), -renderImage->height()); QGLFramebufferObject::blitFramebuffer(resolveFBO, srcRect, multisampleFBO, dstRect); // Read back the pixels from the resolve FBO resolveFBO->bind(); glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); glPixelStorei(GL_PACK_ALIGNMENT, 1); if (renderImage->hasAlpha()) { glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glReadPixels(0, 0, renderImage->width(), renderImage->height(), GL_RGBA, GL_UNSIGNED_BYTE, renderImage->pixels()); } else { glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_ALIGNMENT, 3); glReadPixels(0, 0, renderImage->width(), renderImage->height(), GL_RGB, GL_UNSIGNED_BYTE, renderImage->pixels()); } glPopClientAttrib(); resolveFBO->release(); glWidget->doneCurrent(); return true; }
// TODO ici obtenir qque chose independant de la resolution void CDialogState::Draw(){ /* virtual void draw2DRectangle (SColor color, const core::rect< s32 > &pos, const core::rect< s32 > *clip=0)=0 Draws a 2d rectangle. virtual void draw2DRectangleOutline (const core::recti &pos, SColor color=SColor(255, 255, 255, 255))=0 Draws the outline of a 2D rectangle. */ if(_events.empty()){ return; } irr::gui::IGUIFont* font = gui()->getFont (_BC_FILE_HUDFONT); // gui::IGUIFont* font = engine->guienv->getFont("images/fonthaettenschweiler.bmp"); const CSpeech& speech = _events.front(); if(font){ //engine()->smgr->drawAll(); // Creation of displayed text, first add name of the interlocutor std::wstring text = speech._speaker->_name; text += L":\n"; // then his/her speech text += speech._message; font->draw( text.c_str(), core::recti(300,10,500,50), video::SColor(255,255,255,255) ); } irr::video::ITexture* texture = speech._speaker->_texture; if(texture){ irr::core::recti srcRect(irr::core::position2di(0,0),texture->getOriginalSize()); engine()->driver->draw2DImage( texture, core::position2di(10,10), srcRect, 0, // clipRect video::SColor(255,255,255,255), true // useAlphaChannelOfTexture ); } }
void Director::drawRect(const Common::Rect &rect) { _surface.fillRect(rect, 0); for (uint i = 0; i < _sprites.size(); ++i) { const Common::Rect &spriteRect = _sprites[i]->getBounds(); Common::Rect interRect = rect.findIntersectingRect(spriteRect); if (interRect.isEmpty()) continue; Common::Rect srcRect(interRect); srcRect.translate(-spriteRect.left, -spriteRect.top); _surface.transBlitFrom(*_sprites[i]->getDecoder()->getCurrentFrame(), srcRect, interRect, _sprites[i]->getDecoder()->getTransparentColourIndex()); } }
void RenderSVGImage::paintForeground(PaintInfo& paintInfo) { RefPtr<Image> image = imageResource().image(); if (!image) return; FloatRect destRect = m_objectBoundingBox; FloatRect srcRect(0, 0, image->width(), image->height()); imageElement().preserveAspectRatio().transformRect(destRect, srcRect); paintInfo.context().drawImage(*image, destRect, srcRect); }
QSGNode* QmlVlcVideoSurface::updatePaintNode( QSGNode* oldNode, UpdatePaintNodeData* /*data*/ ) { SGVlcVideoNode* node = static_cast<SGVlcVideoNode*>( oldNode ); if( !m_frame ) { delete node; return 0; } if( !node ) node = new SGVlcVideoNode; QRectF outRect( 0, 0, width(), height() ); QRectF srcRect( 0, 0, 1., 1. ); if( Stretch != fillMode() ) { const uint16_t fw = m_frame->width; const uint16_t fh = m_frame->height; const qreal frameAspect = qreal( fw ) / fh; const qreal itemAspect = width() / height(); if( PreserveAspectFit == fillMode() ) { qreal outWidth = width(); qreal outHeight = height(); if( frameAspect > itemAspect ) outHeight = outWidth / frameAspect; else if( frameAspect < itemAspect ) outWidth = outHeight * frameAspect; outRect = QRectF( ( width() - outWidth ) / 2, ( height() - outHeight ) / 2, outWidth, outHeight ); } else if( PreserveAspectCrop == fillMode() ) { if( frameAspect > itemAspect ) { srcRect.setX( ( 1. - itemAspect / frameAspect ) / 2 ); srcRect.setWidth( 1. - srcRect.x() - srcRect.x() ); } else if( frameAspect < itemAspect ) { srcRect.setY( ( 1. - frameAspect / itemAspect ) / 2 ); srcRect.setHeight( 1. - srcRect.y() - srcRect.y() ); } } } if( m_frameUpdated ) { node->setFrame( m_frame ); m_frameUpdated = false; } node->setRect( outRect, srcRect ); return node; }