本文整理匯總了C++中DrawTarget::FillRect方法的典型用法代碼示例。如果您正苦於以下問題:C++ DrawTarget::FillRect方法的具體用法?C++ DrawTarget::FillRect怎麽用?C++ DrawTarget::FillRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DrawTarget
的用法示例。
在下文中一共展示了DrawTarget::FillRect方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: dstRect
void
GradientStopsView::UpdateView()
{
DrawTarget *dt = ui->dtWidget->GetDT();
dt->FillRect(Rect(0, 0, 100000, 100000), ColorPattern(Color(0.5f, 0.5f, 0.5f, 1.0f)));
RefPtr<GradientStops> stops = mTranslator->LookupGradientStops(mRefPtr);
ui->listWidget->clear();
if (!stops) {
dt->Flush();
ui->dtWidget->redraw();
ui->listWidget->addItem("Dead");
return;
}
IntSize dstSize = dt->GetSize();
RefPtr<DrawTarget> tmpdt = dt->CreateSimilarDrawTarget(IntSize(20, 20), SurfaceFormat::B8G8R8X8);
tmpdt->FillRect(Rect(0, 0, 10, 10), ColorPattern(Color(1.0f, 1.0f, 1.0f)));
tmpdt->FillRect(Rect(10, 10, 10, 10), ColorPattern(Color(1.0f, 1.0f, 1.0f)));
tmpdt->FillRect(Rect(10, 0, 10, 10), ColorPattern(Color(0.7f, 0.7f, 0.7f)));
tmpdt->FillRect(Rect(0, 10, 10, 10), ColorPattern(Color(0.7f, 0.7f, 0.7f)));
RefPtr<SourceSurface> src = tmpdt->Snapshot();
tmpdt = NULL;
Rect dstRect(0, 0, dstSize.width, dstSize.height);
dt->FillRect(dstRect, SurfacePattern(src, ExtendMode::REPEAT));
dt->FillRect(dstRect, LinearGradientPattern(Point(0, dstSize.height / 2), Point(dstSize.width, dstSize.height / 2), stops));
dt->Flush();
ui->dtWidget->redraw();
}
示例2: PaintCaret
void nsCaret::PaintCaret(DrawTarget& aDrawTarget,
nsIFrame* aForFrame,
const nsPoint &aOffset)
{
int32_t contentOffset;
nsIFrame* frame = GetFrameAndOffset(GetSelectionInternal(),
mOverrideContent, mOverrideOffset, &contentOffset);
if (!frame) {
return;
}
NS_ASSERTION(frame == aForFrame, "We're referring different frame");
int32_t appUnitsPerDevPixel = frame->PresContext()->AppUnitsPerDevPixel();
nsRect caretRect;
nsRect hookRect;
ComputeCaretRects(frame, contentOffset, &caretRect, &hookRect);
Rect devPxCaretRect =
NSRectToSnappedRect(caretRect + aOffset, appUnitsPerDevPixel, aDrawTarget);
Rect devPxHookRect =
NSRectToSnappedRect(hookRect + aOffset, appUnitsPerDevPixel, aDrawTarget);
ColorPattern color(ToDeviceColor(frame->GetCaretColorAt(contentOffset)));
aDrawTarget.FillRect(devPxCaretRect, color);
if (!hookRect.IsEmpty()) {
aDrawTarget.FillRect(devPxHookRect, color);
}
}
示例3: pattern
static void
RepeatOrStretchSurface(DrawTarget& aDT, SourceSurface* aSurface,
const Rect& aDest, const Rect& aSrc, Rect& aSkipRect)
{
if (aSkipRect.Contains(aDest)) {
return;
}
if ((!aDT.GetTransform().IsRectilinear() &&
aDT.GetBackendType() != BackendType::CAIRO) ||
(aDT.GetBackendType() == BackendType::DIRECT2D)) {
// Use stretching if possible, since it leads to less seams when the
// destination is transformed. However, don't do this if we're using cairo,
// because if cairo is using pixman it won't render anything for large
// stretch factors because pixman's internal fixed point precision is not
// high enough to handle those scale factors.
// Calling FillRect on a D2D backend with a repeating pattern is much slower
// than DrawSurface, so special case the D2D backend here.
aDT.DrawSurface(aSurface, aDest, aSrc);
return;
}
SurfacePattern pattern(aSurface, ExtendMode::REPEAT,
Matrix::Translation(aDest.TopLeft() - aSrc.TopLeft()),
Filter::GOOD, RoundedToInt(aSrc));
aDT.FillRect(aDest, pattern);
}
示例4: cyan
static void
PaintDebugPlaceholder(nsIFrame* aFrame, nsRenderingContext* aCtx,
const nsRect& aDirtyRect, nsPoint aPt)
{
ColorPattern cyan(ToDeviceColor(Color(0.f, 1.f, 1.f, 1.f)));
DrawTarget* drawTarget = aCtx->GetDrawTarget();
int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
nscoord x = nsPresContext::CSSPixelsToAppUnits(-5);
nsRect r(aPt.x + x, aPt.y,
nsPresContext::CSSPixelsToAppUnits(13),
nsPresContext::CSSPixelsToAppUnits(3));
drawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), cyan);
nscoord y = nsPresContext::CSSPixelsToAppUnits(-10);
r = nsRect(aPt.x, aPt.y + y,
nsPresContext::CSSPixelsToAppUnits(3),
nsPresContext::CSSPixelsToAppUnits(10));
drawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), cyan);
}
示例5: pattern
void
gfxSurfaceDrawable::DrawInternal(gfxContext* aContext,
const gfxRect& aFillRect,
const IntRect& aSamplingRect,
bool aRepeat,
const GraphicsFilter& aFilter,
gfxFloat aOpacity,
const gfxMatrix& aTransform)
{
ExtendMode extend = ExtendMode::CLAMP;
if (aRepeat) {
extend = ExtendMode::REPEAT;
}
Matrix patternTransform = ToMatrix(aTransform * mTransform);
patternTransform.Invert();
SurfacePattern pattern(mSourceSurface, extend,
patternTransform, ToFilter(aFilter), aSamplingRect);
Rect fillRect = ToRect(aFillRect);
DrawTarget* dt = aContext->GetDrawTarget();
if (aContext->CurrentOperator() == gfxContext::OPERATOR_CLEAR) {
dt->ClearRect(fillRect);
} else if (aContext->CurrentOperator() == gfxContext::OPERATOR_SOURCE &&
aOpacity == 1.0) {
// Emulate cairo operator source which is bound by mask!
dt->ClearRect(fillRect);
dt->FillRect(fillRect, pattern);
} else {
dt->FillRect(fillRect, pattern,
DrawOptions(aOpacity,
CompositionOpForOp(aContext->CurrentOperator()),
aContext->CurrentAntialiasMode()));
}
}
示例6: pattern
bool
gfxSurfaceDrawable::Draw(gfxContext* aContext,
const gfxRect& aFillRect,
bool aRepeat,
const GraphicsFilter& aFilter,
const gfxMatrix& aTransform)
{
ExtendMode extend = ExtendMode::CLAMP;
if (aRepeat) {
extend = ExtendMode::REPEAT;
}
Matrix patternTransform = ToMatrix(aTransform * mTransform);
patternTransform.Invert();
SurfacePattern pattern(mSourceSurface, extend,
patternTransform, ToFilter(aFilter));
Rect fillRect = ToRect(aFillRect);
DrawTarget* dt = aContext->GetDrawTarget();
if (aContext->CurrentOperator() == gfxContext::OPERATOR_CLEAR) {
dt->ClearRect(fillRect);
} else if (aContext->CurrentOperator() == gfxContext::OPERATOR_SOURCE) {
// Emulate cairo operator source which is bound by mask!
dt->ClearRect(fillRect);
dt->FillRect(fillRect, pattern);
} else {
CompositionOp op = CompositionOpForOp(aContext->CurrentOperator());
AntialiasMode aaMode =
aContext->CurrentAntialiasMode() == gfxContext::MODE_ALIASED ?
AntialiasMode::NONE :
AntialiasMode::SUBPIXEL;
dt->FillRect(fillRect, pattern, DrawOptions(1.0f, op, aaMode));
}
return true;
}
示例7: ToReferenceFrame
void
nsDisplayCanvasBackgroundColor::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
nsCanvasFrame* frame = static_cast<nsCanvasFrame*>(mFrame);
nsPoint offset = ToReferenceFrame();
nsRect bgClipRect = frame->CanvasArea() + offset;
if (NS_GET_A(mColor) > 0) {
DrawTarget* drawTarget = aCtx->GetDrawTarget();
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
Rect devPxRect =
NSRectToSnappedRect(bgClipRect, appUnitsPerDevPixel, *drawTarget);
drawTarget->FillRect(devPxRect, ColorPattern(ToDeviceColor(mColor)));
}
}
示例8: minRect
// Blurs a small surface and creates the mask.
static already_AddRefed<SourceSurface>
CreateBlurMask(const IntSize& aRectSize,
RectCornerRadii* aCornerRadii,
gfxIntSize aBlurRadius,
IntMargin& aExtendDestBy,
IntMargin& aSliceBorder,
DrawTarget& aDestDrawTarget)
{
IntMargin slice;
gfxAlphaBoxBlur blur;
IntSize minSize =
ComputeMinSizeForShadowShape(aCornerRadii, aBlurRadius, slice, aRectSize);
IntRect minRect(IntPoint(), minSize);
gfxContext* blurCtx = blur.Init(ThebesRect(Rect(minRect)), gfxIntSize(),
aBlurRadius, nullptr, nullptr);
if (!blurCtx) {
return nullptr;
}
DrawTarget* blurDT = blurCtx->GetDrawTarget();
ColorPattern black(Color(0.f, 0.f, 0.f, 1.f));
if (aCornerRadii) {
RefPtr<Path> roundedRect =
MakePathForRoundedRect(*blurDT, Rect(minRect), *aCornerRadii);
blurDT->Fill(roundedRect, black);
} else {
blurDT->FillRect(Rect(minRect), black);
}
IntPoint topLeft;
RefPtr<SourceSurface> result = blur.DoBlur(&aDestDrawTarget, &topLeft);
if (!result) {
return nullptr;
}
IntRect expandedMinRect(topLeft, result->GetSize());
aExtendDestBy = expandedMinRect - minRect;
aSliceBorder = slice + aExtendDestBy;
MOZ_ASSERT(aSliceBorder.LeftRight() <= expandedMinRect.width);
MOZ_ASSERT(aSliceBorder.TopBottom() <= expandedMinRect.height);
return result.forget();
}
示例9: rect
static void
PaintIndeterminateMark(nsIFrame* aFrame,
nsRenderingContext* aCtx,
const nsRect& aDirtyRect,
nsPoint aPt)
{
DrawTarget* drawTarget = aCtx->GetDrawTarget();
int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
nsRect rect(aPt, aFrame->GetSize());
rect.Deflate(aFrame->GetUsedBorderAndPadding());
rect.y += (rect.height - rect.height/4) / 2;
rect.height /= 4;
Rect devPxRect = NSRectToSnappedRect(rect, appUnitsPerDevPixel, *drawTarget);
drawTarget->FillRect(devPxRect,
ColorPattern(ToDeviceColor(aFrame->StyleColor()->mColor)));
}
示例10: DrawToCanvas
void DocumentRendererParent::DrawToCanvas(const nsIntSize& aSize,
const nsCString& aData)
{
if (!mCanvas || !mCanvasContext)
return;
DrawTarget* drawTarget = mCanvasContext->GetDrawTarget();
Rect rect(0, 0, aSize.width, aSize.height);
MaybeSnapToDevicePixels(rect, *drawTarget, true);
RefPtr<DataSourceSurface> dataSurface =
Factory::CreateWrappingDataSourceSurface(reinterpret_cast<uint8_t*>(const_cast<nsCString&>(aData).BeginWriting()),
aSize.width * 4,
IntSize(aSize.width, aSize.height),
SurfaceFormat::B8G8R8A8);
SurfacePattern pattern(dataSurface, ExtendMode::CLAMP);
drawTarget->FillRect(rect, pattern);
gfxRect damageRect = mCanvasContext->UserToDevice(ThebesRect(rect));
mCanvas->Redraw(damageRect);
}
示例11: autoRestoreTransform
void
gfxWindowsNativeDrawing::PaintToContext()
{
if (mRenderState == RENDER_STATE_NATIVE_DRAWING_DONE) {
// nothing to do, it already went to the context
mRenderState = RENDER_STATE_DONE;
} else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_WHITE_DONE) {
RefPtr<gfxImageSurface> black = mBlackSurface->GetAsImageSurface();
RefPtr<gfxImageSurface> white = mWhiteSurface->GetAsImageSurface();
if (!gfxAlphaRecovery::RecoverAlpha(black, white)) {
NS_ERROR("Alpha recovery failure");
return;
}
RefPtr<DataSourceSurface> source =
Factory::CreateWrappingDataSourceSurface(black->Data(),
black->Stride(),
black->GetSize(),
SurfaceFormat::B8G8R8A8);
{
DrawTarget* dt = mContext->GetDrawTarget();
AutoRestoreTransform autoRestoreTransform(dt);
Matrix newTransform = dt->GetTransform();
newTransform.PreTranslate(ToPoint(mNativeRect.TopLeft()));
dt->SetTransform(newTransform);
Rect rect(Point(0.0, 0.0), ToSize(mNativeRect.Size()));
Matrix m = Matrix::Scaling(1.0 / mScale.width, 1.0 / mScale.height);
Filter filter = (mNativeDrawFlags & DO_NEAREST_NEIGHBOR_FILTERING)
? Filter::LINEAR
: Filter::GOOD;
SurfacePattern pat(source, ExtendMode::CLAMP, m, filter);
dt->FillRect(rect, pat);
}
mRenderState = RENDER_STATE_DONE;
} else {
NS_ERROR("Invalid RenderState in gfxWindowsNativeDrawing::PaintToContext");
}
}