зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1160070 - Used BitmapBrush instead of ImageBrush when no sampling bounds. r=bas
This commit is contained in:
Родитель
04a761af4f
Коммит
da2704a55c
|
@ -1453,29 +1453,46 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
|
|||
D2D1_RECT_F samplingBounds;
|
||||
Matrix mat = pat->mMatrix;
|
||||
|
||||
bool useSamplingRect = false;
|
||||
if (!pat->mSamplingRect.IsEmpty() &&
|
||||
(pat->mSurface->GetType() == SurfaceType::D2D1_1_IMAGE)) {
|
||||
samplingBounds = D2DRect(pat->mSamplingRect);
|
||||
mat.PreTranslate(pat->mSamplingRect.x, pat->mSamplingRect.y);
|
||||
} else if (!pat->mSamplingRect.IsEmpty()) {
|
||||
// We will do a partial upload of the sampling restricted area from GetImageForSurface.
|
||||
samplingBounds = D2D1::RectF(0, 0, pat->mSamplingRect.width, pat->mSamplingRect.height);
|
||||
} else {
|
||||
samplingBounds = D2D1::RectF(0, 0,
|
||||
Float(pat->mSurface->GetSize().width),
|
||||
Float(pat->mSurface->GetSize().height));
|
||||
}
|
||||
|
||||
MOZ_ASSERT(pat->mSurface->IsValid());
|
||||
|
||||
RefPtr<ID2D1ImageBrush> imageBrush;
|
||||
RefPtr<ID2D1Image> image = GetImageForSurface(pat->mSurface, mat, pat->mExtendMode, !pat->mSamplingRect.IsEmpty() ? &pat->mSamplingRect : nullptr);
|
||||
|
||||
if (!image) {
|
||||
return CreateTransparentBlackBrush();
|
||||
}
|
||||
|
||||
bool useSamplingRect = false;
|
||||
if (pat->mSamplingRect.IsEmpty()) {
|
||||
RefPtr<ID2D1Bitmap> bitmap;
|
||||
image->QueryInterface((ID2D1Bitmap**)byRef(bitmap));
|
||||
if (bitmap) {
|
||||
RefPtr<ID2D1BitmapBrush> bitmapBrush;
|
||||
mDC->CreateBitmapBrush(bitmap,
|
||||
D2D1::BitmapBrushProperties(D2DExtend(pat->mExtendMode),
|
||||
D2DExtend(pat->mExtendMode),
|
||||
D2DFilter(pat->mFilter)),
|
||||
D2D1::BrushProperties(aAlpha, D2DMatrix(mat)),
|
||||
byRef(bitmapBrush));
|
||||
if (!bitmapBrush) {
|
||||
gfxWarning() << "Couldn't create bitmap brush!";
|
||||
return CreateTransparentBlackBrush();
|
||||
}
|
||||
return bitmapBrush.forget();
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<ID2D1ImageBrush> imageBrush;
|
||||
if (pat->mSamplingRect.IsEmpty()) {
|
||||
samplingBounds = D2D1::RectF(0, 0,
|
||||
Float(pat->mSurface->GetSize().width),
|
||||
Float(pat->mSurface->GetSize().height));
|
||||
} else if (pat->mSurface->GetType() == SurfaceType::D2D1_1_IMAGE) {
|
||||
samplingBounds = D2DRect(pat->mSamplingRect);
|
||||
mat.PreTranslate(pat->mSamplingRect.x, pat->mSamplingRect.y);
|
||||
} else {
|
||||
// We will do a partial upload of the sampling restricted area from GetImageForSurface.
|
||||
samplingBounds = D2D1::RectF(0, 0, pat->mSamplingRect.width, pat->mSamplingRect.height);
|
||||
}
|
||||
mDC->CreateImageBrush(image,
|
||||
D2D1::ImageBrushProperties(samplingBounds,
|
||||
D2DExtend(pat->mExtendMode),
|
||||
|
|
Загрузка…
Ссылка в новой задаче