mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1846686: Remove DataSourceSurfaces when adding SourceSurfaces to CanvasTranslator. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D186171
This commit is contained in:
parent
8742b079de
commit
c1c73dc306
@ -99,7 +99,8 @@ class InlineTranslator : public Translator {
|
||||
mPaths.InsertOrUpdate(aRefPtr, RefPtr{aPath});
|
||||
}
|
||||
|
||||
void AddSourceSurface(ReferencePtr aRefPtr, SourceSurface* aSurface) final {
|
||||
void AddSourceSurface(ReferencePtr aRefPtr,
|
||||
SourceSurface* aSurface) override {
|
||||
mSourceSurfaces.InsertOrUpdate(aRefPtr, RefPtr{aSurface});
|
||||
}
|
||||
|
||||
|
@ -355,11 +355,15 @@ inline bool RecordedGetDataForSurface::PlayCanvasEvent(
|
||||
return false;
|
||||
}
|
||||
|
||||
gfx::IntSize ssSize = surface->GetSize();
|
||||
size_t dataFormatWidth = ssSize.width * BytesPerPixel(surface->GetFormat());
|
||||
int32_t dataFormatWidth =
|
||||
surface->GetSize().width * BytesPerPixel(surface->GetFormat());
|
||||
int32_t srcStride = map->GetStride();
|
||||
if (dataFormatWidth > srcStride) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char* src = reinterpret_cast<char*>(map->GetData());
|
||||
char* endSrc = src + (ssSize.height * srcStride);
|
||||
char* endSrc = src + (map->GetSurface()->GetSize().height * srcStride);
|
||||
while (src < endSrc) {
|
||||
aTranslator->ReturnWrite(src, dataFormatWidth);
|
||||
src += srcStride;
|
||||
|
@ -169,6 +169,22 @@ class CanvasTranslator final : public gfx::InlineTranslator,
|
||||
*/
|
||||
void RemoveTexture(int64_t aTextureId);
|
||||
|
||||
/**
|
||||
* Overriden to remove any DataSourceSurfaces associated with the RefPtr.
|
||||
*
|
||||
* @param aRefPtr the key to the surface
|
||||
* @param aSurface the surface to store
|
||||
*/
|
||||
void AddSourceSurface(gfx::ReferencePtr aRefPtr,
|
||||
gfx::SourceSurface* aSurface) final {
|
||||
if (mMappedSurface == aRefPtr) {
|
||||
mPreparedMap = nullptr;
|
||||
mMappedSurface = nullptr;
|
||||
}
|
||||
RemoveDataSurface(aRefPtr);
|
||||
InlineTranslator::AddSourceSurface(aRefPtr, aSurface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the SourceSurface and other objects associated with a SourceSurface
|
||||
* from another process.
|
||||
@ -176,6 +192,10 @@ class CanvasTranslator final : public gfx::InlineTranslator,
|
||||
* @param aRefPtr the key to the objects to remove
|
||||
*/
|
||||
void RemoveSourceSurface(gfx::ReferencePtr aRefPtr) final {
|
||||
if (mMappedSurface == aRefPtr) {
|
||||
mPreparedMap = nullptr;
|
||||
mMappedSurface = nullptr;
|
||||
}
|
||||
RemoveDataSurface(aRefPtr);
|
||||
InlineTranslator::RemoveSourceSurface(aRefPtr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user