當前位置: 首頁>>代碼示例>>C++>>正文


C++ DrawTarget::ClearRect方法代碼示例

本文整理匯總了C++中DrawTarget::ClearRect方法的典型用法代碼示例。如果您正苦於以下問題:C++ DrawTarget::ClearRect方法的具體用法?C++ DrawTarget::ClearRect怎麽用?C++ DrawTarget::ClearRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DrawTarget的用法示例。


在下文中一共展示了DrawTarget::ClearRect方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: GetUpdateSurface

DrawTarget*
ContentClientIncremental::BorrowDrawTargetForPainting(const PaintState& aPaintState,
        RotatedContentBuffer::DrawIterator* aIter)
{
    if (aPaintState.mMode == SurfaceMode::SURFACE_NONE) {
        return nullptr;
    }

    if (aIter) {
        if (aIter->mCount++ > 0) {
            return nullptr;
        }
        aIter->mDrawRegion = aPaintState.mRegionToDraw;
    }

    DrawTarget* result = nullptr;

    nsIntRect drawBounds = aPaintState.mRegionToDraw.GetBounds();
    MOZ_ASSERT(!mLoanedDrawTarget);

    // BeginUpdate is allowed to modify the given region,
    // if it wants more to be repainted than we request.
    if (aPaintState.mMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
        nsIntRegion drawRegionCopy = aPaintState.mRegionToDraw;
        RefPtr<DrawTarget> onBlack = GetUpdateSurface(BUFFER_BLACK, drawRegionCopy);
        RefPtr<DrawTarget> onWhite = GetUpdateSurface(BUFFER_WHITE, aPaintState.mRegionToDraw);
        if (onBlack && onWhite) {
            NS_ASSERTION(aPaintState.mRegionToDraw == drawRegionCopy,
                         "BeginUpdate should always modify the draw region in the same way!");
            FillSurface(onBlack, aPaintState.mRegionToDraw, nsIntPoint(drawBounds.x, drawBounds.y), gfxRGBA(0.0, 0.0, 0.0, 1.0));
            FillSurface(onWhite, aPaintState.mRegionToDraw, nsIntPoint(drawBounds.x, drawBounds.y), gfxRGBA(1.0, 1.0, 1.0, 1.0));
            mLoanedDrawTarget = Factory::CreateDualDrawTarget(onBlack, onWhite);
        } else {
            mLoanedDrawTarget = nullptr;
        }
    } else {
        mLoanedDrawTarget = GetUpdateSurface(BUFFER_BLACK, aPaintState.mRegionToDraw);
    }
    if (!mLoanedDrawTarget) {
        NS_WARNING("unable to get context for update");
        return nullptr;
    }

    result = mLoanedDrawTarget;
    mLoanedTransform = mLoanedDrawTarget->GetTransform();
    mLoanedTransform.Translate(-drawBounds.x, -drawBounds.y);
    result->SetTransform(mLoanedTransform);
    mLoanedTransform.Translate(drawBounds.x, drawBounds.y);

    if (mContentType == gfxContentType::COLOR_ALPHA) {
        gfxUtils::ClipToRegion(result, aPaintState.mRegionToDraw);
        nsIntRect bounds = aPaintState.mRegionToDraw.GetBounds();
        result->ClearRect(Rect(bounds.x, bounds.y, bounds.width, bounds.height));
    }

    return result;
}
開發者ID:plancalculus,項目名稱:xulrunner,代碼行數:57,代碼來源:ContentClient.cpp

示例2: 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()));
    }
}
開發者ID:Andrel322,項目名稱:gecko-dev,代碼行數:38,代碼來源:gfxDrawable.cpp

示例3: 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;
}
開發者ID:bebef1987,項目名稱:gecko-dev,代碼行數:38,代碼來源:gfxDrawable.cpp


注:本文中的DrawTarget::ClearRect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。