void BitmapSkPictureCanvasLayerTextureUpdater::paintContentsRect(SkCanvas* canvas, const IntRect& sourceRect) { // Translate the origin of contentRect to that of sourceRect. canvas->translate(contentRect().x() - sourceRect.x(), contentRect().y() - sourceRect.y()); drawPicture(canvas); }
void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(CCGraphicsContext* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { GraphicsContext3D* context3d = context->context3D(); if (!context3d) { // FIXME: Implement this path for software compositing. return; } // Make sure ganesh uses the correct GL context. context3d->makeContextCurrent(); // Notify ganesh to sync its internal GL state. context3d->grContext()->resetContext(); // Create an accelerated canvas to draw on. OwnPtr<SkCanvas> canvas = createAcceleratedCanvas(context3d, allocator, texture); // The compositor expects the textures to be upside-down so it can flip // the final composited image. Ganesh renders the image upright so we // need to do a y-flip. canvas->translate(0.0, texture->size().height()); canvas->scale(1.0, -1.0); // Only the region corresponding to destRect on the texture must be updated. canvas->clipRect(SkRect(destRect)); // Translate the origin of contentRect to that of destRect. // Note that destRect is defined relative to sourceRect. canvas->translate(contentRect().x() - sourceRect.x() + destRect.x(), contentRect().y() - sourceRect.y() + destRect.y()); drawPicture(canvas.get()); // Flush ganesh context so that all the rendered stuff appears on the texture. context3d->grContext()->flush(); }
void LayerTextureUpdaterSkPicture::updateTextureRect(LayerTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { if (m_createFrameBuffer) { deleteFrameBuffer(); createFrameBuffer(); m_createFrameBuffer = false; } if (!m_fbo) return; // Bind texture. context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); texture->framebufferTexture2D(); ASSERT(context()->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE); // Notify SKIA to sync its internal GL state. m_skiaContext->resetContext(); m_canvas->save(); m_canvas->clipRect(SkRect(destRect)); // Translate the origin of contentRect to that of destRect. // Note that destRect is defined relative to sourceRect. m_canvas->translate(contentRect().x() - sourceRect.x() + destRect.x(), contentRect().y() - sourceRect.y() + destRect.y()); m_canvas->drawPicture(m_picture); m_canvas->restore(); // Flush SKIA context so that all the rendered stuff appears on the texture. m_skiaContext->flush(GrContext::kForceCurrentRenderTarget_FlushBit); // Unbind texture. context()->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, 0, 0); context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0); }
void BitmapSkPictureCanvasLayerTextureUpdater::paintContentsRect(SkCanvas* canvas, const IntRect& sourceRect, CCRenderingStats& stats) { // Translate the origin of contentRect to that of sourceRect. canvas->translate(contentRect().x() - sourceRect.x(), contentRect().y() - sourceRect.y()); double rasterizeBeginTime = monotonicallyIncreasingTime(); drawPicture(canvas); stats.totalRasterizeTimeInSeconds += monotonicallyIncreasingTime() - rasterizeBeginTime; }
void PhotoWidget::setContentImage(const QPixmap &pixmap) { mContentPixmap = pixmap; QRectF pixmapRect = pixmap.rect(); /*calculate the new height for the content rect width */ float pixmapHeight = (pixmapRect.height() / pixmapRect.width() ) * contentRect().width(); pixmapRect.setHeight(pixmapHeight); pixmapRect.setWidth(contentRect().width()); setContentRect(pixmapRect); update(); }
void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { PlatformCanvas::AutoLocker locker(&m_canvas); texture->bindTexture(context, allocator); m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, texture->format(), context); }
QSize QIrParabolicEffectManager::sizeHint() const { QIR_P(const QIrParabolicEffectManager); QIrDockView * view = p->view; QList< QIrDockletBundle * > list = view->bundles(); QIrDock * dock = view->dock(); QRectF bounding; QRectF geom; int sepCount = 0, count = list.count(); QIrDockStyle * style = dock->dockStyle(); int spacing = p->view->dockletSpacing(); if ( !style ) return QSize(); bounding = contentRect(); for (int i = 0; i < count; i++) { if ( list[i]->docklet()->isSeparator() ) sepCount++; } QSize s = bounding.size().toSize(); if ( !dock->isExtended() ) { QSize mindockletSize = sizeForIconSize(style,spacing,dock->effectiveMinimumIconSize(),dock->minimumIconSize(),dock->maximumIconSize(),false,dock->orientation()); QSize minSepSize = sizeForIconSize(style,spacing,dock->effectiveMinimumIconSize(),dock->minimumIconSize(), dock->maximumIconSize(),true,dock->orientation()); if ( dock->orientation() == Qt::Horizontal ) { s.rwidth() = (count - sepCount) * (mindockletSize.width() + 1) + sepCount * (minSepSize.width() + 1) - 1; } else { s.rheight() = (count - sepCount) * (mindockletSize.height() + 1) + sepCount * (minSepSize.height() + 1) - 1; } } return s; }
void PictureContent::addEffect(const PictureEffect & effect) { if (!m_photo) return; m_photo->addEffect(effect); // adapt picture ratio after cropping if (effect.effect == PictureEffect::Crop) { QRect actualContentRect = contentRect(); if ((actualContentRect.height() + actualContentRect.width()) > 0) { qreal reduceRatio = (qreal)(effect.rect.width()+effect.rect.height())/ (qreal)(actualContentRect.height() +actualContentRect.width()); int newW = (int)((qreal)effect.rect.width()/reduceRatio); int newH = (int)((qreal)effect.rect.height()/reduceRatio); resizeContents(QRect(-newW/2, -newH/2, newW, newH), true); } } else if(effect.effect == PictureEffect::Opacity) setContentOpacity(effect.param); m_cachedPhoto = QPixmap(); update(); GFX_CHANGED(); // notify image change emit contentChanged(); }
void tMercuryControlSeparator::paintEvent(QPaintEvent*) { tMercuryStyle* style = GetMercuryStyle(); if( style == 0 ) { return; } QRect contentRect(GetContentRect()); QPainter painter(this); if( m_FixedWidth > 0 ) { if( m_IsVertical ) { int w = qMin(contentRect.width(), m_FixedWidth); contentRect.setLeft(contentRect.center().x() - w / 2); contentRect.setWidth(w); } else { int h = qMin(contentRect.height(), m_FixedWidth); contentRect.setTop(contentRect.center().y() - h / 2); contentRect.setHeight(h); } } painter.fillRect(contentRect, m_Gradient); }
void CompassFloatItem::paintContent( GeoPainter *painter, ViewportParams *viewport, const QString& renderPos, GeoSceneLayer * layer ) { Q_UNUSED( layer ) Q_UNUSED( renderPos ) painter->save(); painter->setRenderHint( QPainter::Antialiasing, true ); QRectF compassRect( contentRect() ); m_polarity = viewport->polarity(); QString dirstr = tr( "N" ); if ( m_polarity == -1 ) dirstr = tr( "S" ); if ( m_polarity == 0 ) dirstr = ""; int fontheight = QFontMetrics( font() ).ascent(); int fontwidth = QFontMetrics( font() ).boundingRect( dirstr ).width(); QPen outlinepen( background().color() ); outlinepen.setWidth( 2 ); QBrush outlinebrush( pen().color() ); QPainterPath outlinepath; const QPointF baseline( 0.5 * (qreal)( compassRect.width() - fontwidth ), (qreal)(fontheight) + 2.0 ); outlinepath.addText( baseline, font(), dirstr ); painter->setPen( outlinepen ); painter->setBrush( outlinebrush ); painter->drawPath( outlinepath ); painter->setPen( Qt::NoPen ); painter->drawPath( outlinepath ); painter->autoMapQuality(); int compassLength = static_cast<int>( compassRect.height() ) - 5 - fontheight; QSize compassSize( compassLength, compassLength ); // Rerender compass pixmap if the size has changed if ( m_compass.isNull() || m_compass.size() != compassSize ) { m_compass = QPixmap( compassSize ); m_compass.fill( Qt::transparent ); QPainter mapPainter( &m_compass ); mapPainter.setViewport( m_compass.rect() ); m_svgobj->render( &mapPainter ); mapPainter.setViewport( QRect( QPoint( 0, 0 ), viewport->size() ) ); } painter->drawPixmap( QPoint( static_cast<int>( compassRect.width() - compassLength ) / 2, fontheight + 5 ), m_compass ); painter->restore(); }
void tMercuryControlTank::DirtyControl() { tMercuryStyle* style = GetMercuryStyle(); if( style == 0 ) { return; } if( m_Font.isNull() ) { m_Font = style->GetFont("", tMercuryStyle::eFontRoleStandard); } m_Font->SetDirty(); QRectF contentRect(GetContentRect()); m_ElementSize = qMax(1.f, float(qMin(contentRect.width(), contentRect.height())) * 0.02f); m_BarWidth = float(contentRect.width()) * 0.75f; float left = float(contentRect.width()) * 0.125f; m_InnerRect = QRectF( float(contentRect.left()) + left + 2.f * m_ElementSize, float(contentRect.top()) + 3.f * m_ElementSize, m_BarWidth - 4.f * m_ElementSize, float(contentRect.height()) - 6.f * m_ElementSize - 1.f ); }
void LayerTextureUpdaterBitmap::updateTextureRect(LayerTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { PlatformCanvas::AutoLocker locker(&m_canvas); texture->bindTexture(); m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, context()); }
void CCLayerImpl::appendDebugBorderQuad(CCQuadSink& quadList, const CCSharedQuadState* sharedQuadState) const { if (!hasDebugBorders()) return; IntRect contentRect(IntPoint(), contentBounds()); quadList.append(CCDebugBorderDrawQuad::create(sharedQuadState, contentRect, debugBorderColor(), debugBorderWidth())); }
IntRect CCLayerImpl::layerRectToContentRect(const WebKit::WebRect& layerRect) { float widthScale = static_cast<float>(contentBounds().width()) / bounds().width(); float heightScale = static_cast<float>(contentBounds().height()) / bounds().height(); FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.height); contentRect.scale(widthScale, heightScale); return enclosingIntRect(contentRect); }
void BitmapCanvasLayerTextureUpdater::updateTextureRect(CCGraphicsContext* context, TextureAllocator* allocator, CCPrioritizedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { const SkBitmap& bitmap = m_canvas->getDevice()->accessBitmap(false); bitmap.lockPixels(); texture->bindTexture(context, allocator); m_texSubImage.upload(static_cast<const uint8_t*>(bitmap.getPixels()), contentRect(), sourceRect, destRect, texture->format(), context); bitmap.unlockPixels(); }
void TextContent::keyPressEvent(QKeyEvent * event){ // use F2 to edit the text if (event->key() == Qt::Key_F2) { event->accept(); emit requestConfig(mapToScene(contentRect().bottomRight()).toPoint()); return; } AbstractContent::keyPressEvent(event); }
void tSidebarControlTrim::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Assert(painter != 0 && option != 0); tSidebarControl::paint(painter, option, widget); tMercuryStyle* style = GetMercuryStyle(); if( style == 0 ) { return; } QRect contentRect(option->rect); contentRect.adjust(0, 0, 0, -1); float countMod = (1.8f - float(m_Count) * 0.2f); const int tabWidth = int(contentRect.width() * g_cTabWidth * countMod); const int columnHeight = int(contentRect.height() * g_cColumnHeight); const int columnGap = int(contentRect.width() * g_cColumnGap * countMod); const int indicatorHeight = int(contentRect.height() * g_cIndicatorHeight); const int verticalPadding = (contentRect.height() - columnHeight) / 2; QColor tickColorPrime = style->GetColor(tMercuryStyle::eColorRolePrimaryTickLine); QColor tickColor = style->GetColor(tMercuryStyle::eColorRoleSecondaryTickLine); QColor indicatorColor = style->GetColor(tMercuryStyle::eColorRoleLevelLine); int x = contentRect.left(); if( m_TabsVisible ) { DrawColumn(*painter, QRect(x, contentRect.top() + verticalPadding, tabWidth, columnHeight), tickColor, indicatorColor, tickColorPrime, indicatorHeight, m_ValueLeft, m_TabZeroPoint[0], m_TabValid[0]); } x += tabWidth * 2 + columnGap; const int valueWidth = (contentRect.width() - tabWidth * 4 - columnGap * (1 + m_Count)) / m_Count; for( int i = 0; i < m_Count; i++ ) { if( m_TrimVisible ) { DrawColumn(*painter, QRect(x, contentRect.top() + verticalPadding, valueWidth, columnHeight), tickColor, indicatorColor, tickColorPrime, indicatorHeight, qMin(1.f, 1.3333f * m_Values[i]), qMin(1.f, 1.3333f * m_ZeroPoints[i]), m_TrimValid[i]); } x += valueWidth + columnGap; } if( m_TabsVisible ) { DrawColumn(*painter, QRect(contentRect.right() - tabWidth, contentRect.top() + verticalPadding, tabWidth, columnHeight), tickColor, indicatorColor, tickColorPrime, indicatorHeight, m_ValueRight, m_TabZeroPoint[1], m_TabValid[1]); } }
void EmbeddedObjectPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) { if (!m_layoutEmbeddedObject.showsUnavailablePluginIndicator()) return; if (paintInfo.phase == PaintPhaseSelection) return; GraphicsContext& context = paintInfo.context; if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( context, m_layoutEmbeddedObject, paintInfo.phase)) return; LayoutRect contentRect(m_layoutEmbeddedObject.contentBoxRect()); contentRect.moveBy(paintOffset); LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutEmbeddedObject, paintInfo.phase, contentRect); GraphicsContextStateSaver stateSaver(context); context.clip(pixelSnappedIntRect(contentRect)); Font font = replacementTextFont(); const SimpleFontData* fontData = font.primaryFont(); DCHECK(fontData); if (!fontData) return; TextRun textRun(m_layoutEmbeddedObject.unavailablePluginReplacementText()); FloatSize textGeometry(font.width(textRun), fontData->getFontMetrics().height()); LayoutRect backgroundRect( 0, 0, textGeometry.width() + 2 * replacementTextRoundedRectLeftRightTextMargin, replacementTextRoundedRectHeight); backgroundRect.move(contentRect.center() - backgroundRect.center()); backgroundRect = LayoutRect(pixelSnappedIntRect(backgroundRect)); Path roundedBackgroundRect; FloatRect floatBackgroundRect(backgroundRect); roundedBackgroundRect.addRoundedRect( floatBackgroundRect, FloatSize(replacementTextRoundedRectRadius, replacementTextRoundedRectRadius)); context.setFillColor( scaleAlpha(Color::white, replacementTextRoundedRectOpacity)); context.fillPath(roundedBackgroundRect); FloatRect textRect(FloatPoint(), textGeometry); textRect.move(FloatPoint(contentRect.center()) - textRect.center()); TextRunPaintInfo runInfo(textRun); runInfo.bounds = floatBackgroundRect; context.setFillColor(scaleAlpha(Color::black, replacementTextTextOpacity)); context.drawBidiText( font, runInfo, textRect.location() + FloatSize(0, fontData->getFontMetrics().ascent())); }
void VRFSystemMiniView::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) { painter->setRenderHint(QPainter::Antialiasing, true); painter->setBrush(Qt::NoBrush); painter->setPen(QPen(Qt::black,1,Qt::SolidLine, Qt::RoundCap)); painter->drawRect(boundingRect()); painter->setPen(QPen(Qt::black,2,Qt::SolidLine, Qt::RoundCap)); QRectF _headerRect = headerRect(); painter->drawRect(_headerRect); painter->drawText(QRectF(_headerRect.x() + 5, _headerRect.y() + 5, _headerRect.width() - 10, _headerRect.height() - 10),Qt::AlignVCenter | Qt::AlignLeft,m_name); QRectF _contentRect = contentRect(); double x = _contentRect.x() + 5; double y = _contentRect.y() + 12; painter->drawPixmap(x,y,m_vrfOutdoorPix); x = x + m_vrfOutdoorPix.width() + 2; painter->drawPixmap(x,y,m_vrfTransferPix); x = x + m_vrfTerminalPix.width() + 2; painter->drawPixmap(x,y,m_vrfTerminalPix); x = x + m_vrfTerminalPix.width() + 2; QFont font = painter->font(); font.setPointSize(24); font.setWeight(QFont::Bold); painter->setFont(font); painter->drawText(QRectF(x,y,m_length,m_length / 2.0),Qt::AlignCenter,QString::number(m_terminals)); font.setPointSize(12); font.setWeight(QFont::Normal); painter->setFont(font); painter->drawText(QRectF(x,y + m_length / 2.0,m_length,m_length / 2.0),Qt::AlignCenter,QString("Terminals")); x = x + m_length; painter->drawPixmap(x,y,m_vrfZonePix); x = x + m_vrfZonePix.width(); font.setPointSize(24); font.setWeight(QFont::Bold); painter->setFont(font); painter->drawText(QRectF(x,y,m_length,m_length / 2.0),Qt::AlignCenter,QString::number(m_zones)); font.setPointSize(12); font.setWeight(QFont::Normal); painter->setFont(font); painter->drawText(QRectF(x,y + m_length / 2.0,m_length,m_length / 2.0),Qt::AlignCenter,QString("Zones")); x = x + m_length; }
void S60VideoDisplay::updateContentRect() { if (isPaintingEnabled()) { const int dx = qMax(0, extentRect().width() - nativeSize().width()); const int dy = qMax(0, extentRect().height() - nativeSize().height()); QRect contentRect(QPoint(dx/2, dy/2), nativeSize()); if (m_contentRect != contentRect) { m_contentRect = contentRect; emit contentRectChanged(m_contentRect); } } }
void VEditorScrollControl::onRender( Point2I pOffset, const RectI &pUpdateRect ) { Parent::onRender( pOffset, pUpdateRect ); const S32 offsetX = ( mHasVScrollBar ) ? mScrollBarThickness : 1; const S32 offsetY = ( mHasHScrollBar ) ? mScrollBarThickness : 1; RectI contentRect( pOffset.x + 1, pOffset.y + 1, getWidth() - offsetX - 1, getHeight() - offsetY - 1 ); contentRect.intersect( pUpdateRect ); GFX->getDrawUtil()->drawRect( contentRect, mProfile->mBorderColor ); }
void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { // Make sure SKIA uses the correct GL context. context->makeContextCurrent(); // Notify SKIA to sync its internal GL state. context->grContext()->resetContext(); // Create an accelerated canvas to draw on. FrameBuffer buffer; SkCanvas* canvas = buffer.initialize(context, allocator, texture); canvas->clipRect(SkRect(destRect)); // Translate the origin of contentRect to that of destRect. // Note that destRect is defined relative to sourceRect. canvas->translate(contentRect().x() - sourceRect.x() + destRect.x(), contentRect().y() - sourceRect.y() + destRect.y()); canvas->drawPicture(m_picture); // Flush SKIA context so that all the rendered stuff appears on the texture. context->grContext()->flush(); }
void CCRenderSurface::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuadsData, bool forReplica, CCRenderPass::Id renderPassId) { ASSERT(!forReplica || m_owningLayer->hasReplica()); IntRect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer); bool isOpaque = false; const WebTransformationMatrix& drawTransform = forReplica ? m_replicaDrawTransform : m_drawTransform; CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(CCSharedQuadState::create(drawTransform, m_contentRect, clippedRectInTarget, m_drawOpacity, isOpaque)); if (m_owningLayer->hasDebugBorders()) { int red = forReplica ? debugReplicaBorderColorRed : debugSurfaceBorderColorRed; int green = forReplica ? debugReplicaBorderColorGreen : debugSurfaceBorderColorGreen; int blue = forReplica ? debugReplicaBorderColorBlue : debugSurfaceBorderColorBlue; SkColor color = SkColorSetARGB(debugSurfaceBorderAlpha, red, green, blue); quadSink.append(CCDebugBorderDrawQuad::create(sharedQuadState, contentRect(), color, debugSurfaceBorderWidth), appendQuadsData); } // FIXME: By using the same RenderSurface for both the content and its reflection, // it's currently not possible to apply a separate mask to the reflection layer // or correctly handle opacity in reflections (opacity must be applied after drawing // both the layer and its reflection). The solution is to introduce yet another RenderSurface // to draw the layer and its reflection in. For now we only apply a separate reflection // mask if the contents don't have a mask of their own. CCLayerImpl* maskLayer = m_owningLayer->maskLayer(); if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().isEmpty())) maskLayer = 0; if (!maskLayer && forReplica) { maskLayer = m_owningLayer->replicaLayer()->maskLayer(); if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().isEmpty())) maskLayer = 0; } float maskTexCoordScaleX = 1; float maskTexCoordScaleY = 1; float maskTexCoordOffsetX = 1; float maskTexCoordOffsetY = 1; if (maskLayer) { maskTexCoordScaleX = static_cast<float>(contentRect().width()) / maskLayer->contentBounds().width(); maskTexCoordScaleY = static_cast<float>(contentRect().height()) / maskLayer->contentBounds().height(); maskTexCoordOffsetX = static_cast<float>(contentRect().x()) / contentRect().width() * maskTexCoordScaleX; maskTexCoordOffsetY = static_cast<float>(contentRect().y()) / contentRect().height() * maskTexCoordScaleY; } CCResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->contentsResourceId() : 0; IntRect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect : IntRect(); quadSink.append(CCRenderPassDrawQuad::create(sharedQuadState, contentRect(), renderPassId, forReplica, maskResourceId, contentsChangedSinceLastFrame, maskTexCoordScaleX, maskTexCoordScaleY, maskTexCoordOffsetX, maskTexCoordOffsetY), appendQuadsData); }
void Button::_setSize( const Size& _size ) { Widget::_setSize(_size); Rect contentRect(0,0,_size); if( m_pSkin ) contentRect -= m_pSkin->contentPadding(); Rect textRect = m_icon.getTextRect( contentRect, m_icon.getIconRect( contentRect ) ); m_text.onNewSize( textRect ); }
void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* compositorContext, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { ASSERT(!m_context || m_context == compositorContext); m_context = compositorContext; if (m_createFrameBuffer) { deleteFrameBuffer(); createFrameBuffer(); m_createFrameBuffer = false; } if (!m_fbo) return; // Bind texture. context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); texture->framebufferTexture2D(context(), allocator); ASSERT(context()->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE); // Make sure SKIA uses the correct GL context. context()->makeContextCurrent(); GrContext* skiaContext = m_context->grContext(); // Notify SKIA to sync its internal GL state. skiaContext->resetContext(); m_canvas->save(); m_canvas->clipRect(SkRect(destRect)); // Translate the origin of contentRect to that of destRect. // Note that destRect is defined relative to sourceRect. m_canvas->translate(contentRect().x() - sourceRect.x() + destRect.x(), contentRect().y() - sourceRect.y() + destRect.y()); m_canvas->drawPicture(m_picture); m_canvas->restore(); // Flush SKIA context so that all the rendered stuff appears on the texture. skiaContext->flush(); // Unbind texture. context()->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, 0, 0); context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0); }
QPainterPath ProgressFloatItem::backgroundShape() const { QPainterPath path; if ( active() ) { // Circular shape if active, invisible otherwise QRectF rect = contentRect(); qreal width = rect.width(); qreal height = rect.height(); path.addEllipse( marginLeft() + 2 * padding(), marginTop() + 2 * padding(), width, height ); } return path; }
void TimelineWidget::paintEvent(QPaintEvent* event) { QPainter painter(this); QRectF fullRect = contentsRect(); QRectF contentRect(0, 0, fullRect.width() - 1, fullRect.height() - LegendHeight); QRectF legendRect(0, fullRect.bottom() - LegendHeight, fullRect.right(), fullRect.bottom()); painter.save(); drawContent(painter, contentRect); painter.restore(); painter.save(); painter.translate(0, fullRect.height() - LegendHeight); drawLegend(painter, QRectF(legendRect)); painter.restore(); }
BOOL CComboBox::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID) { QWidget *parentView = (QWidget *)pParentWnd->GetNSWindow(); QComboBox *comboBox = new QComboBox(parentView); QRect contentRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); comboBox->move (contentRect.x(), contentRect.y()); comboBox->resize(contentRect.width(), contentRect.height()); comboBox->setAccessibleName(QString().setNum(nID)); m_hWnd = comboBox; mParentWin = pParentWnd; return TRUE; }
void CompassFloatItem::paintContent( QPainter *painter ) { painter->save(); QRectF compassRect( contentRect() ); const QString dirstr = (m_polarity == +1) ? tr("N") : (m_polarity == -1) ? tr("S") : /*else*/ QString(); int fontheight = QFontMetrics( font() ).ascent(); int fontwidth = QFontMetrics( font() ).boundingRect( dirstr ).width(); QPen outlinepen( background().color() ); outlinepen.setWidth( 2 ); QBrush outlinebrush( pen().color() ); QPainterPath outlinepath; const QPointF baseline( 0.5 * (qreal)( compassRect.width() - fontwidth ), (qreal)(fontheight) + 2.0 ); outlinepath.addText( baseline, font(), dirstr ); painter->setPen( outlinepen ); painter->setBrush( outlinebrush ); painter->drawPath( outlinepath ); painter->setPen( Qt::NoPen ); painter->drawPath( outlinepath ); int compassLength = static_cast<int>( compassRect.height() ) - 5 - fontheight; QSize compassSize( compassLength, compassLength ); // Rerender compass pixmap if the size has changed if ( m_compass.isNull() || m_compass.size() != compassSize ) { m_compass = QPixmap( compassSize ); m_compass.fill( Qt::transparent ); QPainter mapPainter( &m_compass ); mapPainter.setViewport( m_compass.rect() ); m_svgobj->render( &mapPainter ); } painter->drawPixmap( QPoint( static_cast<int>( compassRect.width() - compassLength ) / 2, fontheight + 5 ), m_compass ); painter->restore(); }
void PluginView::invalidateRect(const IntRect& dirtyRect) { if (!parent() || !m_plugin || !m_isInitialized) return; #if PLATFORM(MAC) if (m_plugin->pluginLayer()) return; #endif RenderBoxModelObject* renderer = toRenderBoxModelObject(m_pluginElement->renderer()); if (!renderer) return; IntRect contentRect(dirtyRect); contentRect.move(renderer->borderLeft() + renderer->paddingLeft(), renderer->borderTop() + renderer->paddingTop()); renderer->repaintRectangle(contentRect); }