зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1316654 - Fix the DrawTargetSkia::CreateSimilarDrawTarget check for non-raster backed SkCanvas to avoid false positives. r=lsalzman
This commit is contained in:
Родитель
eb5cbfaadf
Коммит
a03162818c
|
@ -1587,11 +1587,11 @@ DrawTargetSkia::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFor
|
|||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
// Check that our SkCanvas isn't backed by vector storage such as PDF. If it
|
||||
// is then we want similar storage to avoid losing fidelity (if and when this
|
||||
// DrawTarget is Snapshot()'ed, drawning a raster back into this DrawTarget
|
||||
// will lose fidelity).
|
||||
if (mCanvas->imageInfo().colorType() == kUnknown_SkColorType) {
|
||||
if (!IsBackedByPixels(mCanvas.get())) {
|
||||
// If our canvas is backed by vector storage such as PDF then we want to
|
||||
// create a new DrawTarget with similar storage to avoid losing fidelity
|
||||
// (fidelity will be lost if the returned DT is Snapshot()'ed and drawn
|
||||
// back onto us since a raster will be drawn instead of vector commands).
|
||||
NS_WARNING("Not backed by pixels - we need to handle PDF backed SkCanvas");
|
||||
}
|
||||
#endif
|
||||
|
@ -1793,9 +1793,7 @@ DrawTargetSkia::Init(SkCanvas* aCanvas)
|
|||
|
||||
// If the canvas is backed by pixels we clear it to be on the safe side. If
|
||||
// it's not (for example, for PDF output) we don't.
|
||||
bool isBackedByPixels = imageInfo.colorType() != kUnknown_SkColorType;
|
||||
if (isBackedByPixels) {
|
||||
// Note for PDF backed SkCanvas |alphaType == kUnknown_SkAlphaType|.
|
||||
if (IsBackedByPixels(mCanvas.get())) {
|
||||
SkColor clearColor = imageInfo.isOpaque() ? SK_ColorBLACK : SK_ColorTRANSPARENT;
|
||||
mCanvas->clear(clearColor);
|
||||
}
|
||||
|
|
|
@ -371,6 +371,25 @@ static inline FillRule GetFillRule(SkPath::FillType aFillType)
|
|||
return FillRule::FILL_EVEN_ODD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the canvas is backed by pixels. Returns false if the canvas
|
||||
* wraps an SkPDFDocument, for example.
|
||||
*
|
||||
* Note: It is not clear whether the test used to implement this function may
|
||||
* result in it returning false in some circumstances even when the canvas
|
||||
* _is_ pixel backed. In other words maybe it is possible for such a canvas to
|
||||
* have kUnknown_SkPixelGeometry?
|
||||
*/
|
||||
static inline bool IsBackedByPixels(const SkCanvas* aCanvas)
|
||||
{
|
||||
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
|
||||
if (!aCanvas->getProps(&props) ||
|
||||
props.pixelGeometry() == kUnknown_SkPixelGeometry) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче