summaryrefslogtreecommitdiffstats
path: root/gfx/2d/Factory.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /gfx/2d/Factory.cpp
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/2d/Factory.cpp')
-rw-r--r--gfx/2d/Factory.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp
index abf7a8669b..1bdf597142 100644
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -1106,6 +1106,40 @@ already_AddRefed<DataSourceSurface> Factory::CreateDataSourceSurfaceWithStride(
return nullptr;
}
+already_AddRefed<DataSourceSurface> Factory::CopyDataSourceSurface(
+ DataSourceSurface* aSource) {
+ // Don't worry too much about speed.
+ MOZ_ASSERT(aSource->GetFormat() == SurfaceFormat::R8G8B8A8 ||
+ aSource->GetFormat() == SurfaceFormat::R8G8B8X8 ||
+ aSource->GetFormat() == SurfaceFormat::B8G8R8A8 ||
+ aSource->GetFormat() == SurfaceFormat::B8G8R8X8);
+
+ DataSourceSurface::ScopedMap srcMap(aSource, DataSourceSurface::READ);
+ if (NS_WARN_IF(!srcMap.IsMapped())) {
+ MOZ_ASSERT_UNREACHABLE("CopyDataSourceSurface: Failed to map surface.");
+ return nullptr;
+ }
+
+ IntSize size = aSource->GetSize();
+ SurfaceFormat format = aSource->GetFormat();
+
+ RefPtr<DataSourceSurface> dst = CreateDataSourceSurfaceWithStride(
+ size, format, srcMap.GetStride(), /* aZero */ false);
+ if (NS_WARN_IF(!dst)) {
+ return nullptr;
+ }
+
+ DataSourceSurface::ScopedMap dstMap(dst, DataSourceSurface::WRITE);
+ if (NS_WARN_IF(!dstMap.IsMapped())) {
+ MOZ_ASSERT_UNREACHABLE("CopyDataSourceSurface: Failed to map surface.");
+ return nullptr;
+ }
+
+ SwizzleData(srcMap.GetData(), srcMap.GetStride(), format, dstMap.GetData(),
+ dstMap.GetStride(), format, size);
+ return dst.forget();
+}
+
void Factory::CopyDataSourceSurface(DataSourceSurface* aSource,
DataSourceSurface* aDest) {
// Don't worry too much about speed.