本文整理汇总了C++中GraphicsContext::clip方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsContext::clip方法的具体用法?C++ GraphicsContext::clip怎么用?C++ GraphicsContext::clip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext::clip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintButton
bool RenderThemeAndroid::paintButton(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
{
// If it is a disabled button, simply paint it to the master picture.
Node* node = obj->node();
Element* formControlElement = static_cast<Element*>(node);
if (formControlElement) {
android::WebFrame* webFrame = getWebFrame(node);
if (webFrame) {
GraphicsContext *context = info.context;
IntRect innerrect = IntRect(rect.x() + paddingButton, rect.y() + paddingButton,
rect.width() - 2 * paddingButton, rect.height() - 2 * paddingButton);
IntSize cornerrect = IntSize(cornerButton, cornerButton);
Color bg, bright, dark, medium;
if (formControlElement->isEnabledFormControl()) {
bg = Color(defaultBgColor);
bright = Color(defaultBgBright);
dark = Color(defaultBgDark);
medium = Color(defaultBgMedium);
} else {
bg = Color(disabledBgColor);
bright = Color(disabledBgBright);
dark = Color(disabledBgDark);
medium = Color(disabledBgMedium);
}
context->save();
context->clip(
IntRect(innerrect.x(), innerrect.y(), innerrect.width(), 1));
context->fillRoundedRect(innerrect, cornerrect, cornerrect,
cornerrect, cornerrect, bright, context->fillColorSpace());
context->restore();
context->save();
context->clip(IntRect(innerrect.x(), innerrect.y() + innerrect.height() - 1,
innerrect.width(), 1));
context->fillRoundedRect(innerrect, cornerrect, cornerrect,
cornerrect, cornerrect, dark, context->fillColorSpace());
context->restore();
context->save();
context->clip(IntRect(innerrect.x(), innerrect.y() + 1, innerrect.width(),
innerrect.height() - 2));
context->fillRoundedRect(innerrect, cornerrect, cornerrect,
cornerrect, cornerrect, bg, context->fillColorSpace());
context->restore();
context->setStrokeColor(medium, context->strokeColorSpace());
context->setStrokeThickness(1.0f);
context->drawLine(IntPoint(innerrect.x(), innerrect.y() + cornerButton),
IntPoint(innerrect.x(), innerrect.y() + innerrect.height() - cornerButton));
context->drawLine(IntPoint(innerrect.x() + innerrect.width(), innerrect.y() + cornerButton),
IntPoint(innerrect.x() + innerrect.width(), innerrect.y() + innerrect.height() - cornerButton));
}
}
// We always return false so we do not request to be redrawn.
return false;
}
示例2: paintReplaced
void RenderEmbeddedObject::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (!showsUnavailablePluginIndicator())
return;
if (paintInfo.phase == PaintPhaseSelection)
return;
FloatRect contentRect;
Path path;
FloatRect replacementTextRect;
Font font;
TextRun run("");
float textWidth;
if (!getReplacementTextGeometry(paintOffset, contentRect, path, replacementTextRect, font, run, textWidth))
return;
GraphicsContext* context = paintInfo.context;
GraphicsContextStateSaver stateSaver(*context);
context->clip(contentRect);
context->setAlphaAsFloat(replacementTextRoundedRectOpacity);
context->setFillColor(Color::white);
context->fillPath(path);
const FontMetrics& fontMetrics = font.fontMetrics();
float labelX = roundf(replacementTextRect.location().x() + (replacementTextRect.size().width() - textWidth) / 2);
float labelY = roundf(replacementTextRect.location().y() + (replacementTextRect.size().height() - fontMetrics.height()) / 2 + fontMetrics.ascent());
TextRunPaintInfo runInfo(run);
runInfo.bounds = replacementTextRect;
context->setAlphaAsFloat(replacementTextTextOpacity);
context->setFillColor(Color::black);
context->drawBidiText(font, runInfo, FloatPoint(labelX, labelY));
}
示例3: dstRect
ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect)
: m_imageElement(nullptr)
, m_cropRect(cropRect)
, m_bitmapOffset(IntPoint())
{
IntSize playerSize;
if (video->webMediaPlayer())
playerSize = video->webMediaPlayer()->naturalSize();
IntRect videoRect = IntRect(IntPoint(), playerSize);
IntRect srcRect = intersection(cropRect, videoRect);
IntRect dstRect(IntPoint(), srcRect.size());
OwnPtr<ImageBuffer> buf = ImageBuffer::create(videoRect.size());
if (!buf)
return;
GraphicsContext* c = buf->context();
c->clip(dstRect);
c->translate(-srcRect.x(), -srcRect.y());
video->paintCurrentFrameInContext(c, videoRect);
m_bitmap = buf->copyImage(DontCopyBackingStore);
m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cropRect.y())), srcRect.size());
ScriptWrappable::init(this);
}
示例4: draw
void FindIndicator::draw(GraphicsContext& graphicsContext, const IntRect& dirtyRect)
{
for (size_t i = 0; i < m_textRects.size(); ++i) {
FloatRect textRect = m_textRects[i];
textRect.move(leftBorderThickness, topBorderThickness);
graphicsContext.save();
FloatRect outerPathRect = inflateRect(textRect, horizontalOutsetToCenterOfLightBorder, verticalOutsetToCenterOfLightBorder);
graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, shadowColor(), ColorSpaceSRGB);
graphicsContext.addPath(pathWithRoundedRect(outerPathRect, cornerRadius));
graphicsContext.setFillColor(lightBorderColor(), ColorSpaceDeviceRGB);
graphicsContext.fillPath();
graphicsContext.restore();
graphicsContext.save();
FloatRect innerPathRect = inflateRect(textRect, horizontalPaddingInsideLightBorder, verticalPaddingInsideLightBorder);
graphicsContext.clip(pathWithRoundedRect(innerPathRect, cornerRadius));
RefPtr<Gradient> gradient = Gradient::create(FloatPoint(innerPathRect.x(), innerPathRect.y()), FloatPoint(innerPathRect.x(), innerPathRect.bottom()));
gradient->addColorStop(0, gradientLightColor());
gradient->addColorStop(1, gradientDarkColor());
graphicsContext.setFillGradient(gradient);
graphicsContext.fillRect(outerPathRect);
graphicsContext.restore();
graphicsContext.save();
graphicsContext.translate(FloatSize(roundf(leftBorderThickness), roundf(topBorderThickness) + m_contentImage->bounds().height()));
graphicsContext.scale(FloatSize(1, -1));
m_contentImage->paint(&graphicsContext, m_contentImage->bounds());
graphicsContext.restore();
}
}
示例5: paintReplaced
void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (!pluginCrashedOrWasMissing())
return;
if (paintInfo.phase == PaintPhaseSelection)
return;
GraphicsContext* context = paintInfo.context;
if (context->paintingDisabled())
return;
FloatRect contentRect;
Path path;
FloatRect replacementTextRect;
Font font;
TextRun run("");
float textWidth;
if (!getReplacementTextGeometry(paintOffset, contentRect, path, replacementTextRect, font, run, textWidth))
return;
GraphicsContextStateSaver stateSaver(*context);
context->clip(contentRect);
context->setAlpha(m_missingPluginIndicatorIsPressed ? replacementTextPressedRoundedRectOpacity : replacementTextRoundedRectOpacity);
context->setFillColor(m_missingPluginIndicatorIsPressed ? replacementTextRoundedRectPressedColor() : Color::white, style()->colorSpace());
context->fillPath(path);
const FontMetrics& fontMetrics = font.fontMetrics();
float labelX = roundf(replacementTextRect.location().x() + (replacementTextRect.size().width() - textWidth) / 2);
float labelY = roundf(replacementTextRect.location().y() + (replacementTextRect.size().height() - fontMetrics.height()) / 2 + fontMetrics.ascent());
context->setAlpha(m_missingPluginIndicatorIsPressed ? replacementTextPressedTextOpacity : replacementTextTextOpacity);
context->setFillColor(Color::black, style()->colorSpace());
context->drawBidiText(font, run, FloatPoint(labelX, labelY));
}
示例6: paintReplaced
void HTMLCanvasPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
GraphicsContext* context = paintInfo.context;
LayoutRect contentRect = m_renderHTMLCanvas.contentBoxRect();
contentRect.moveBy(paintOffset);
LayoutRect paintRect = m_renderHTMLCanvas.replacedContentRect();
paintRect.moveBy(paintOffset);
bool clip = !contentRect.contains(paintRect);
if (clip) {
context->save();
context->clip(contentRect);
}
// FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast is set.
// See bug for more details: crbug.com/353716.
InterpolationQuality interpolationQuality = m_renderHTMLCanvas.style()->imageRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaultInterpolationQuality;
if (m_renderHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated)
interpolationQuality = InterpolationNone;
InterpolationQuality previousInterpolationQuality = context->imageInterpolationQuality();
context->setImageInterpolationQuality(interpolationQuality);
toHTMLCanvasElement(m_renderHTMLCanvas.node())->paint(context, paintRect);
context->setImageInterpolationQuality(previousInterpolationQuality);
if (clip)
context->restore();
}
示例7: paintContents
void AcceleratedCompositingContext::paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& rectToPaint)
{
context.save();
context.clip(rectToPaint);
core(&m_webView)->mainFrame().view()->paint(&context, enclosingIntRect(rectToPaint));
context.restore();
}
示例8: drawRect
void WebPage::drawRect(GraphicsContext& graphicsContext, const IntRect& rect)
{
graphicsContext.save();
graphicsContext.clip(rect);
m_mainFrame->coreFrame()->view()->paint(&graphicsContext, rect);
graphicsContext.restore();
}
示例9: paintReplaced
void RenderVideo::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
MediaPlayer* mediaPlayer = mediaElement()->player();
bool displayingPoster = videoElement()->shouldDisplayPosterImage();
if (!displayingPoster && !mediaPlayer)
return;
LayoutRect rect = videoBox();
if (rect.isEmpty())
return;
rect.moveBy(paintOffset);
LayoutRect contentRect = contentBoxRect();
contentRect.moveBy(paintOffset);
GraphicsContext* context = paintInfo.context;
bool clip = !contentRect.contains(rect);
if (clip) {
context->save();
context->clip(contentRect);
}
if (displayingPoster)
paintIntoRect(context, rect);
else if ((document().view() && document().view()->paintBehavior() & PaintBehaviorFlattenCompositingLayers) || !acceleratedRenderingInUse())
mediaPlayer->paint(context, pixelSnappedIntRect(rect));
if (clip)
context->restore();
}
示例10: draw
void FindIndicator::draw(GraphicsContext& graphicsContext, const IntRect& /*dirtyRect*/)
{
#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
for (size_t i = 0; i < m_textRectsInSelectionRectCoordinates.size(); ++i) {
FloatRect textRect = m_textRectsInSelectionRectCoordinates[i];
textRect.move(leftBorderThickness, topBorderThickness);
FloatRect outerPathRect = inflateRect(textRect, horizontalOutsetToCenterOfLightBorder, verticalOutsetToCenterOfLightBorder);
FloatRect innerPathRect = inflateRect(textRect, horizontalPaddingInsideLightBorder, verticalPaddingInsideLightBorder);
{
GraphicsContextStateSaver stateSaver(graphicsContext);
graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, shadowColor(), ColorSpaceSRGB);
graphicsContext.setFillColor(lightBorderColor(), ColorSpaceDeviceRGB);
graphicsContext.fillPath(pathWithRoundedRect(outerPathRect, cornerRadius));
}
{
GraphicsContextStateSaver stateSaver(graphicsContext);
graphicsContext.clip(pathWithRoundedRect(innerPathRect, cornerRadius));
RefPtr<Gradient> gradient = Gradient::create(FloatPoint(innerPathRect.x(), innerPathRect.y()), FloatPoint(innerPathRect.x(), innerPathRect.maxY()));
gradient->addColorStop(0, gradientLightColor());
gradient->addColorStop(1, gradientDarkColor());
graphicsContext.setFillGradient(gradient.releaseNonNull());
graphicsContext.fillRect(outerPathRect);
}
{
GraphicsContextStateSaver stateSaver(graphicsContext);
graphicsContext.translate(FloatSize(roundf(leftBorderThickness), roundf(topBorderThickness)));
IntRect contentImageRect = enclosingIntRect(m_textRectsInSelectionRectCoordinates[i]);
m_contentImage->paint(graphicsContext, m_contentImageScaleFactor, contentImageRect.location(), contentImageRect);
}
}
#else
for (auto& textRect : m_textRectsInSelectionRectCoordinates) {
FloatRect blurRect = textRect;
blurRect.move(flatShadowBlurRadius + flatStyleHorizontalBorder, flatShadowBlurRadius + flatStyleVerticalBorder);
FloatRect outerPathRect = inflateRect(blurRect, flatStyleHorizontalBorder, flatStyleVerticalBorder);
{
GraphicsContextStateSaver stateSaver(graphicsContext);
graphicsContext.setShadow(FloatSize(), flatRimShadowBlurRadius, flatRimShadowColor(), ColorSpaceSRGB);
graphicsContext.setFillColor(flatHighlightColor(), ColorSpaceSRGB);
graphicsContext.fillRect(outerPathRect);
graphicsContext.setShadow(FloatSize(flatShadowOffsetX, flatShadowOffsetY), flatShadowBlurRadius, flatDropShadowColor(), ColorSpaceSRGB);
graphicsContext.fillRect(outerPathRect);
}
{
GraphicsContextStateSaver stateSaver(graphicsContext);
graphicsContext.translate(FloatSize(flatShadowBlurRadius + flatStyleHorizontalBorder, flatShadowBlurRadius + flatStyleVerticalBorder));
IntRect contentImageRect = enclosingIntRect(textRect);
m_contentImage->paint(graphicsContext, m_contentImageScaleFactor, contentImageRect.location(), contentImageRect);
}
}
#endif
}
示例11: beginClip
void TextureMapperImageBuffer::beginClip(const TransformationMatrix& matrix, const FloatRect& rect)
{
GraphicsContext* context = currentContext();
if (!context)
return;
#if ENABLE(3D_RENDERING)
TransformationMatrix previousTransform = context->get3DTransform();
#else
AffineTransform previousTransform = context->getCTM();
#endif
context->save();
#if ENABLE(3D_RENDERING)
context->concat3DTransform(matrix);
#else
context->concatCTM(matrix.toAffineTransform());
#endif
context->clip(rect);
#if ENABLE(3D_RENDERING)
context->set3DTransform(previousTransform);
#else
context->setCTM(previousTransform);
#endif
}
示例12: beginFilterEffect
GraphicsContext* FilterEffectRendererHelper::beginFilterEffect(GraphicsContext* oldContext)
{
ASSERT(m_renderLayer);
FilterEffectRenderer* filter = m_renderLayer->filterRenderer();
filter->allocateBackingStoreIfNeeded();
// Paint into the context that represents the SourceGraphic of the filter.
GraphicsContext* sourceGraphicsContext = filter->inputContext();
if (!sourceGraphicsContext || !FilterEffect::isFilterSizeValid(filter->absoluteFilterRegion())) {
// Disable the filters and continue.
m_haveFilterEffect = false;
return oldContext;
}
m_savedGraphicsContext = oldContext;
// Translate the context so that the contents of the layer is captuterd in the offscreen memory buffer.
sourceGraphicsContext->save();
// FIXME: can we just use sourceImageRect for everything, and get rid of
// m_repaintRect?
FloatPoint offset = filter->sourceImageRect().location();
sourceGraphicsContext->translate(-offset.x(), -offset.y());
sourceGraphicsContext->clearRect(m_repaintRect);
sourceGraphicsContext->clip(m_repaintRect);
return sourceGraphicsContext;
}
示例13: drawingContext
void CanvasRenderingContext2D::clip()
{
GraphicsContext* c = drawingContext();
if (!c)
return;
c->clip(state().m_path);
clearPathForDashboardBackwardCompatibilityMode();
}
示例14: spoolRect
void PrintContext::spoolRect(GraphicsContext& ctx, const IntRect& rect)
{
// FIXME: Not correct for vertical text.
ctx.save();
ctx.translate(-rect.x(), -rect.y());
ctx.clip(rect);
m_frame->view()->paintContents(&ctx, rect);
ctx.restore();
}
示例15: beginPaint
GraphicsContext* ThreadSafeCoordinatedSurface::beginPaint(const IntRect& rect)
{
ASSERT(m_imageBuffer);
GraphicsContext* graphicsContext = m_imageBuffer->context();
graphicsContext->save();
graphicsContext->clip(rect);
graphicsContext->translate(rect.x(), rect.y());
return graphicsContext;
}