Bug 1321075: Check if the backend is friendly to data draw target creation before attempting to make it. r=bas

MozReview-Commit-ID: 8jvUvrmCTAY

--HG--
extra : rebase_source : 1325c3cc3a1b02b96bb4b3cb249afeeae7a77864
This commit is contained in:
Milan Sreckovic 2016-11-29 15:46:49 -05:00
Родитель 1368b01c9d
Коммит dd0c296f12
3 изменённых файлов: 24 добавлений и 7 удалений

Просмотреть файл

@ -282,9 +282,17 @@ BufferTextureData::BorrowDrawTarget()
const RGBDescriptor& rgb = mDescriptor.get_RGBDescriptor();
uint32_t stride = ImageDataSerializer::GetRGBStride(rgb);
mDrawTarget = gfx::Factory::CreateDrawTargetForData(mMoz2DBackend,
GetBuffer(), rgb.size(),
stride, rgb.format(), true);
if (gfx::Factory::DoesBackendSupportDataDrawtarget(mMoz2DBackend)) {
mDrawTarget = gfx::Factory::CreateDrawTargetForData(mMoz2DBackend,
GetBuffer(), rgb.size(),
stride, rgb.format(), true);
} else {
// Fall back to supported platform backend. Note that mMoz2DBackend
// does not match the draw target type.
mDrawTarget = gfxPlatform::CreateDrawTargetForData(GetBuffer(), rgb.size(),
stride, rgb.format(),
true);
}
if (mDrawTarget) {
RefPtr<gfx::DrawTarget> dt = mDrawTarget;
@ -294,6 +302,7 @@ BufferTextureData::BorrowDrawTarget()
// TODO - should we warn? should we really fallback to cairo? perhaps
// at least update mMoz2DBackend...
if (mMoz2DBackend != gfx::BackendType::CAIRO) {
gfxCriticalNote << "Falling to CAIRO from " << (int)mMoz2DBackend;
mDrawTarget = gfx::Factory::CreateDrawTargetForData(gfx::BackendType::CAIRO,
GetBuffer(), rgb.size(),
stride, rgb.format(), true);

Просмотреть файл

@ -1469,7 +1469,11 @@ gfxPlatform::CreateSimilarSoftwareDrawTarget(DrawTarget* aDT,
}
/* static */ already_AddRefed<DrawTarget>
gfxPlatform::CreateDrawTargetForData(unsigned char* aData, const IntSize& aSize, int32_t aStride, SurfaceFormat aFormat)
gfxPlatform::CreateDrawTargetForData(unsigned char* aData,
const IntSize& aSize,
int32_t aStride,
SurfaceFormat aFormat,
bool aUninitialized)
{
BackendType backendType = gfxVars::ContentBackend();
NS_ASSERTION(backendType != BackendType::NONE, "No backend.");
@ -1484,7 +1488,8 @@ gfxPlatform::CreateDrawTargetForData(unsigned char* aData, const IntSize& aSize,
RefPtr<DrawTarget> dt = Factory::CreateDrawTargetForData(backendType,
aData, aSize,
aStride, aFormat);
aStride, aFormat,
aUninitialized);
return dt.forget();
}

Просмотреть файл

@ -241,8 +241,11 @@ public:
CreateSimilarSoftwareDrawTarget(DrawTarget* aDT, const IntSize &aSize, mozilla::gfx::SurfaceFormat aFormat);
static already_AddRefed<DrawTarget>
CreateDrawTargetForData(unsigned char* aData, const mozilla::gfx::IntSize& aSize,
int32_t aStride, mozilla::gfx::SurfaceFormat aFormat);
CreateDrawTargetForData(unsigned char* aData,
const mozilla::gfx::IntSize& aSize,
int32_t aStride,
mozilla::gfx::SurfaceFormat aFormat,
bool aUninitialized = false);
/**
* Returns true if rendering to data surfaces produces the same results as