本文整理匯總了C++中DrawTarget::OptimizeSourceSurface方法的典型用法代碼示例。如果您正苦於以下問題:C++ DrawTarget::OptimizeSourceSurface方法的具體用法?C++ DrawTarget::OptimizeSourceSurface怎麽用?C++ DrawTarget::OptimizeSourceSurface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DrawTarget
的用法示例。
在下文中一共展示了DrawTarget::OptimizeSourceSurface方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: BlurCache
static already_AddRefed<SourceSurface>
GetBlur(gfxContext* aDestinationCtx,
const IntSize& aRectSize,
const IntSize& aBlurRadius,
const RectCornerRadii* aCornerRadii,
const Color& aShadowColor,
bool aMirrorCorners,
IntMargin& aOutBlurMargin,
IntMargin& aOutSlice,
IntSize& aOutMinSize)
{
if (!gBlurCache) {
gBlurCache = new BlurCache();
}
IntSize minSize =
ComputeMinSizeForShadowShape(aCornerRadii, aBlurRadius, aOutSlice, aRectSize);
// We can get seams using the min size rect when drawing to the destination rect
// if we have a non-pixel aligned destination transformation. In those cases,
// fallback to just rendering the destination rect.
// During printing, we record all the Moz 2d commands and replay them on the parent side
// with Cairo. Cairo printing uses StretchDIBits to stretch the surface. However,
// since our source image is only 1px for some parts, we make thousands of calls.
// Instead just render the blur ourself here as one image and send it over for printing.
// TODO: May need to change this with the blob renderer in WR since it also records.
Matrix destMatrix = ToMatrix(aDestinationCtx->CurrentMatrix());
bool useDestRect = !destMatrix.IsRectilinear() || destMatrix.HasNonIntegerTranslation() ||
aDestinationCtx->GetDrawTarget()->IsRecording();
if (useDestRect) {
minSize = aRectSize;
}
aOutMinSize = minSize;
DrawTarget* destDT = aDestinationCtx->GetDrawTarget();
if (!useDestRect) {
BlurCacheData* cached = gBlurCache->Lookup(minSize, aBlurRadius,
aCornerRadii, aShadowColor,
destDT->GetBackendType());
if (cached) {
// See CreateBoxShadow() for these values
aOutBlurMargin = cached->mBlurMargin;
RefPtr<SourceSurface> blur = cached->mBlur;
return blur.forget();
}
}
RefPtr<SourceSurface> boxShadow =
CreateBoxShadow(destDT, minSize, aCornerRadii, aBlurRadius,
aShadowColor, aMirrorCorners, aOutBlurMargin);
if (!boxShadow) {
return nullptr;
}
if (RefPtr<SourceSurface> opt = destDT->OptimizeSourceSurface(boxShadow)) {
boxShadow = opt;
}
if (!useDestRect) {
CacheBlur(destDT, minSize, aBlurRadius, aCornerRadii, aShadowColor,
aOutBlurMargin, boxShadow);
}
return boxShadow.forget();
}