Bug 1085187: Properly deal with sampling restriction when using DataSourceSurfaces. r=jrmuizel

This commit is contained in:
Bas Schouten 2014-10-29 23:40:38 +01:00
parent f30549a93c
commit fc6eaaa812
2 changed files with 12 additions and 6 deletions

View File

@ -1211,9 +1211,15 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
D2D1_RECT_F samplingBounds;
Matrix mat = pat->mMatrix;
if (!pat->mSamplingRect.IsEmpty()) {
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),
@ -1221,7 +1227,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
}
RefPtr<ID2D1ImageBrush> imageBrush;
RefPtr<ID2D1Image> image = GetImageForSurface(pat->mSurface, mat, pat->mExtendMode);
RefPtr<ID2D1Image> image = GetImageForSurface(pat->mSurface, mat, pat->mExtendMode, !pat->mSamplingRect.IsEmpty() ? &pat->mSamplingRect : nullptr);
mDC->CreateImageBrush(image,
D2D1::ImageBrushProperties(samplingBounds,
D2DExtend(pat->mExtendMode),
@ -1238,7 +1244,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
TemporaryRef<ID2D1Image>
DrawTargetD2D1::GetImageForSurface(SourceSurface *aSurface, Matrix &aSourceTransform,
ExtendMode aExtendMode)
ExtendMode aExtendMode, const IntRect* aSourceRect)
{
RefPtr<ID2D1Image> image;
@ -1258,7 +1264,7 @@ DrawTargetD2D1::GetImageForSurface(SourceSurface *aSurface, Matrix &aSourceTrans
return nullptr;
}
return CreatePartialBitmapForSurface(dataSurf, mTransform, mSize, aExtendMode,
aSourceTransform, mDC);
aSourceTransform, mDC, aSourceRect);
}
break;
}

View File

@ -129,11 +129,11 @@ public:
uint32_t GetByteSize() const;
TemporaryRef<ID2D1Image> GetImageForSurface(SourceSurface *aSurface, Matrix &aSourceTransform,
ExtendMode aExtendMode);
ExtendMode aExtendMode, const IntRect* aSourceRect = nullptr);
TemporaryRef<ID2D1Image> GetImageForSurface(SourceSurface *aSurface, ExtendMode aExtendMode) {
Matrix mat;
return GetImageForSurface(aSurface, mat, aExtendMode);
return GetImageForSurface(aSurface, mat, aExtendMode, nullptr);
}
static ID2D1Factory1 *factory();