зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1296166 - Avoid calling EnsureTarget in CanvasRenderingContext2D::GetImageData. r=nical
This commit is contained in:
Родитель
9e7beee054
Коммит
06cc318190
|
@ -5301,12 +5301,6 @@ CanvasRenderingContext2D::GetImageData(JSContext* aCx, double aSx,
|
|||
mDrawObserver->DidDrawCall(CanvasDrawObserver::DrawCallType::GetImageData);
|
||||
}
|
||||
|
||||
EnsureTarget();
|
||||
if (!IsTargetValid()) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!mCanvasElement && !mDocShell) {
|
||||
NS_ERROR("No canvas element and no docshell in GetImageData!!!");
|
||||
aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
@ -5415,10 +5409,24 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx,
|
|||
RefPtr<DataSourceSurface> readback;
|
||||
DataSourceSurface::MappedSurface rawData;
|
||||
if (!srcReadRect.IsEmpty()) {
|
||||
RefPtr<SourceSurface> snapshot = mTarget->Snapshot();
|
||||
RefPtr<SourceSurface> snapshot;
|
||||
if (mTarget) {
|
||||
snapshot = mTarget->Snapshot();
|
||||
} else if (mBufferProvider) {
|
||||
snapshot = mBufferProvider->BorrowSnapshot();
|
||||
} else {
|
||||
EnsureTarget();
|
||||
snapshot = mTarget->Snapshot();
|
||||
}
|
||||
|
||||
if (snapshot) {
|
||||
readback = snapshot->GetDataSurface();
|
||||
}
|
||||
|
||||
if (!mTarget && mBufferProvider) {
|
||||
mBufferProvider->ReturnSnapshot(snapshot.forget());
|
||||
}
|
||||
|
||||
if (!readback || !readback->Map(DataSourceSurface::READ, &rawData)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче