--- a/mozilla-skia-bmo1136958.patch Sat Mar 14 15:56:15 2015 +0100
+++ b/mozilla-skia-bmo1136958.patch Sun Mar 22 13:59:40 2015 +0100
@@ -1,430 +1,282 @@
-From 8dc9e73b80ec33fe1a1c855829ef1438301a5de1 Mon Sep 17 00:00:00 2001
-From: Mike Hommey <mh+mozilla@glandium.org>
-Date: Thu, 26 Feb 2015 14:14:02 +0900
-Subject: [PATCH 1/2] Bug 1136958 - Remove duplicate
- SkDiscardableMemory_none.cpp from gfx/skia/moz.build
+From a8ab3ec3542469c1d4e0741121eb1be17cc0acb0 Mon Sep 17 00:00:00 2001
+From: Mike Hommey <mh@glandium.org>
+Date: Mon, 9 Mar 2015 08:42:19 +0900
+Subject: [PATCH] Bug 1136958 - Reintroduce pixman code path removed in bug
+ 1097776 for --disable-skia builds
-And to do so, cleanup gfx/skia/generate_mozbuild.py a little.
---
- gfx/skia/generate_mozbuild.py | 53 ++++++++++++++++---------------------------
- gfx/skia/moz.build | 1 -
- 2 files changed, 20 insertions(+), 34 deletions(-)
+ gfx/layers/basic/BasicCompositor.cpp | 94 +++++++++++++++++++++++++++++++---
+ gfx/layers/basic/BasicLayerManager.cpp | 88 +++++++++++++++++++++++++++++--
+ 2 files changed, 171 insertions(+), 11 deletions(-)
-diff --git a/configure.in b/configure.in
---- a/configure.in
-+++ b/configure.in
-@@ -7941,39 +7941,16 @@ if test -z "${GLIB_GMODULE_LIBS}" \
- fi
-
- AC_SUBST_LIST(GLIB_GMODULE_LIBS)
-
- dnl ========================================================
- dnl Graphics checks.
- dnl ========================================================
-
--if test "${OS_TARGET}" = "WINNT" -o \
-- "${OS_ARCH}" = "Darwin" -o \
-- "${MOZ_WIDGET_TOOLKIT}" = "android" -o \
-- "${MOZ_WIDGET_TOOLKIT}" = "gonk" -o \
-- "${MOZ_WIDGET_TOOLKIT}" = "gtk2" -o \
-- "${MOZ_WIDGET_TOOLKIT}" = "gtk3"; then
-- case "${target_cpu}" in
-- i*86*|x86_64|arm)
-- MOZ_ENABLE_SKIA=1
-- ;;
-- *)
-- MOZ_ENABLE_SKIA=
-- ;;
-- esac
--else
--MOZ_ENABLE_SKIA=
--fi
--
--MOZ_ARG_ENABLE_BOOL(skia,
--[ --enable-skia Enable use of Skia],
--MOZ_ENABLE_SKIA=1,
--MOZ_ENABLE_SKIA=)
--
- MOZ_ARG_DISABLE_BOOL(skia-gpu,
- [ --disable-skia-gpu Disable use of Skia-GPU],
- MOZ_DISABLE_SKIA_GPU=1,
- MOZ_DISABLE_SKIA_GPU=)
-
- if test "$USE_FC_FREETYPE"; then
- if test "$COMPILE_ENVIRONMENT"; then
- dnl ========================================================
-@@ -8191,30 +8168,26 @@ AC_SUBST(MOZ_TREE_CAIRO)
- AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
- AC_SUBST_LIST(MOZ_CAIRO_LIBS)
- AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
- AC_SUBST(MOZ_TREE_PIXMAN)
-
- dnl ========================================================
- dnl Skia
- dnl ========================================================
--if test "$MOZ_ENABLE_SKIA"; then
-- AC_DEFINE(MOZ_ENABLE_SKIA)
-- AC_DEFINE(USE_SKIA)
-- if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
-- AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
-- fi
--
-- if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64" -a "${CPU_ARCH}" != "sparc" -a -z "$MOZ_DISABLE_SKIA_GPU" ; then
-- MOZ_ENABLE_SKIA_GPU=1
-- AC_DEFINE(USE_SKIA_GPU)
-- AC_SUBST(MOZ_ENABLE_SKIA_GPU)
-- fi
--fi
--AC_SUBST(MOZ_ENABLE_SKIA)
-+AC_DEFINE(USE_SKIA)
-+if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
-+ AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
-+fi
-+
-+if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64" -a "${CPU_ARCH}" != "sparc" -a -z "$MOZ_DISABLE_SKIA_GPU" ; then
-+ MOZ_ENABLE_SKIA_GPU=1
-+ AC_DEFINE(USE_SKIA_GPU)
-+ AC_SUBST(MOZ_ENABLE_SKIA_GPU)
-+fi
-
- dnl ========================================================
- dnl Check for nss-shared-helper
- dnl ========================================================
-
- PKG_CHECK_MODULES(NSSHELPER, nss-shared-helper,
- [MOZ_ENABLE_NSSHELPER=1],
- [MOZ_ENABLE_NSSHELPER=])
-diff --git a/gfx/2d/moz.build b/gfx/2d/moz.build
---- a/gfx/2d/moz.build
-+++ b/gfx/2d/moz.build
-@@ -59,49 +59,44 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
- 'ScaledFontDWrite.cpp',
- 'ScaledFontWin.cpp',
- 'SourceSurfaceD2D.cpp',
- 'SourceSurfaceD2D1.cpp',
- 'SourceSurfaceD2DTarget.cpp',
- ]
- DEFINES['WIN32'] = True
-
--if CONFIG['MOZ_ENABLE_SKIA']:
-- UNIFIED_SOURCES += [
-- 'convolver.cpp',
-- 'DrawTargetSkia.cpp',
-- 'PathSkia.cpp',
-- 'SourceSurfaceSkia.cpp',
-- ]
-- SOURCES += [
-- 'image_operations.cpp', # Uses _USE_MATH_DEFINES
-- ]
-- EXPORTS.mozilla.gfx += [
-- 'HelpersSkia.h',
-- ]
-+UNIFIED_SOURCES += [
-+ 'convolver.cpp',
-+ 'DrawTargetSkia.cpp',
-+ 'PathSkia.cpp',
-+ 'SourceSurfaceSkia.cpp',
-+]
-+SOURCES += [
-+ 'image_operations.cpp', # Uses _USE_MATH_DEFINES
-+]
-+EXPORTS.mozilla.gfx += [
-+ 'HelpersSkia.h',
-+]
-
- # Are we targeting x86 or x64? If so, build SSE2 files.
- if CONFIG['INTEL_ARCHITECTURE']:
- SOURCES += [
- 'BlurSSE2.cpp',
-+ 'convolverSSE2.cpp',
- 'FilterProcessingSSE2.cpp',
- 'ImageScalingSSE2.cpp',
- ]
-- if CONFIG['MOZ_ENABLE_SKIA']:
-- SOURCES += [
-- 'convolverSSE2.cpp',
-- ]
- DEFINES['USE_SSE2'] = True
- # The file uses SSE2 intrinsics, so it needs special compile flags on some
- # compilers.
- SOURCES['BlurSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
- SOURCES['FilterProcessingSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
- SOURCES['ImageScalingSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
-- if CONFIG['MOZ_ENABLE_SKIA']:
-- SOURCES['convolverSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
-+ SOURCES['convolverSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
-
- UNIFIED_SOURCES += [
- 'Blur.cpp',
- 'DataSourceSurface.cpp',
- 'DataSurfaceHelpers.cpp',
- 'DrawEventRecorder.cpp',
- 'DrawTarget.cpp',
- 'DrawTargetCairo.cpp',
-diff --git a/gfx/moz.build b/gfx/moz.build
---- a/gfx/moz.build
-+++ b/gfx/moz.build
-@@ -17,16 +17,15 @@ DIRS += [
- 'layers',
- 'graphite2/src',
- 'harfbuzz/src',
- 'ots/src',
- 'thebes',
- 'ipc',
- ]
-
--if CONFIG['MOZ_ENABLE_SKIA']:
-- DIRS += ['skia']
-+DIRS += ['skia']
-
- if CONFIG['ENABLE_TESTS']:
- DIRS += ['tests/gtest']
-
- TEST_DIRS += ['tests']
-
-diff --git a/gfx/skia/generate_mozbuild.py b/gfx/skia/generate_mozbuild.py
---- a/gfx/skia/generate_mozbuild.py
-+++ b/gfx/skia/generate_mozbuild.py
-@@ -1,13 +1,14 @@
- #!/usr/bin/env python
-
- import os
-
- import locale
-+from collections import defaultdict
- locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
+diff --git a/gfx/layers/basic/BasicCompositor.cpp b/gfx/layers/basic/BasicCompositor.cpp
+index 0bef076..000b591 100644
+--- a/gfx/layers/basic/BasicCompositor.cpp
++++ b/gfx/layers/basic/BasicCompositor.cpp
+@@ -17,8 +17,13 @@
+ #include <algorithm>
+ #include "ImageContainer.h"
+ #include "gfxPrefs.h"
++#ifdef MOZ_ENABLE_SKIA
+ #include "skia/SkCanvas.h" // for SkCanvas
+ #include "skia/SkBitmapDevice.h" // for SkBitmapDevice
++#else
++#define PIXMAN_DONT_DEFINE_STDINT
++#include "pixman.h" // for pixman_f_transform, etc
++#endif
- header = """
- #
- # ##### ####### # # # # # #
- # ## # # # # # # # # # # # #
- # ## # # # # # # # # # # #
- # ## #### # # # # # # # # # #
-@@ -187,17 +188,17 @@ def generate_platform_sources():
-
- for plat in platforms:
- if os.system("cd trunk && GYP_GENERATORS=dump_mozbuild ./gyp_skia -D OS=%s gyp/skia_lib.gyp" % plat) != 0:
- print 'Failed to generate sources for ' + plat
- continue
-
-
- f = open('trunk/sources.json');
-- sources[plat] = set(json.load(f));
-+ sources[plat] = set(v.replace('../', 'trunk/') for v in json.load(f));
- f.close()
-
- return dict(sources.items() + generate_opt_sources().items())
-
-
- def generate_separated_sources(platform_sources):
- blacklist = [
- 'ChromeUtils',
-@@ -232,17 +233,17 @@ def generate_separated_sources(platform_
-
- def isblacklisted(value):
- for item in blacklist:
- if value.find(item) >= 0:
- return True
-
- return False
-
-- separated = {
-+ separated = defaultdict(set, {
- 'common': {
- #'trunk/src/effects/gradients/SkGradientTileProc.cpp',
- 'trunk/src/gpu/gl/GrGLCreateNativeInterface_none.cpp',
- 'trunk/src/ports/SkDiscardableMemory_none.cpp',
- 'trunk/src/ports/SkImageDecoder_empty.cpp',
- 'trunk/src/ports/SkMemory_mozalloc.cpp',
- # 'trunk/src/images/SkImages.cpp',
- # 'trunk/src/images/SkImageRef.cpp',
-@@ -277,69 +278,55 @@ def generate_separated_sources(platform_
- 'trunk/src/core/SkUtilsArm.cpp',
- },
- 'neon': {
- 'trunk/src/opts/SkBitmapProcState_arm_neon.cpp',
- },
- 'none': {
- 'trunk/src/opts/SkUtils_opts_none.cpp',
- }
-- }
-+ })
-
- for plat in platform_sources.keys():
-- if not separated.has_key(plat):
-- separated[plat] = set()
--
- for value in platform_sources[plat]:
- if isblacklisted(value):
- continue
-
-- if value.find('_SSE') > 0 or value.find('_SSSE') > 0 or value.find('_SSE4') > 0 : #lol
-- separated['intel'].add(value)
-+ if value in separated['common']:
- continue
-
-- if value.find('_neon') > 0:
-- separated['neon'].add(value)
-- continue
-+ key = plat
-
-- if value.find('_arm') > 0:
-- separated['arm'].add(value)
-- continue
-+ if '_SSE' in value or '_SSSE' in value:
-+ key = 'intel'
-+ elif '_neon' in value:
-+ key = 'neon'
-+ elif '_arm' in value:
-+ key = 'arm'
-+ elif '_none' in value:
-+ key = 'none'
-+ elif all(value in platform_sources.get(p, {})
-+ for p in platforms if p != plat):
-+ key = 'common'
+ namespace mozilla {
+ using namespace mozilla::gfx;
+@@ -168,6 +173,7 @@ DrawSurfaceWithTextureCoords(DrawTarget *aDest,
+ mode, aMask, aMaskTransform, &matrix);
+ }
-- if value.find('_none') > 0:
-- separated['none'].add(value)
-- continue
--
-- found = True
-- for other in platforms:
-- if other == plat or not platform_sources.has_key(other):
-- continue
--
-- if not value in platform_sources[other]:
-- found = False
-- break;
--
-- if found:
-- separated['common'].add(value)
-- else:
-- separated[plat].add(value)
-+ separated[key].add(value)
-
- return separated
-
- def uniq(seq):
- seen = set()
- seen_add = seen.add
- return [ x for x in seq if x not in seen and not seen_add(x)]
-
- def write_cflags(f, values, subsearch, cflag, indent):
- def write_indent(indent):
- for _ in range(indent):
- f.write(' ')
-
-- val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower()))
-+ val_list = uniq(sorted(values, key=lambda x: x.lower()))
-
- if len(val_list) == 0:
- return
-
- for val in val_list:
- if val.find(subsearch) > 0:
- write_indent(indent)
- f.write("SOURCES[\'" + val + "\'].flags += [\'" + cflag + "\']\n")
-@@ -391,17 +378,17 @@ def write_sources(f, values, indent):
- write_list(f, "UNIFIED_SOURCES", sources['unified'], indent)
- write_list(f, "SOURCES", sources['nonunified'], indent)
-
- def write_list(f, name, values, indent):
- def write_indent(indent):
- for _ in range(indent):
- f.write(' ')
-
-- val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower()))
-+ val_list = uniq(sorted(values, key=lambda x: x.lower()))
-
- if len(val_list) == 0:
- return
-
- write_indent(indent)
- f.write(name + ' += [\n')
- for val in val_list:
- write_indent(indent + 4)
-diff --git a/gfx/skia/moz.build b/gfx/skia/moz.build
---- a/gfx/skia/moz.build
-+++ b/gfx/skia/moz.build
-@@ -847,17 +847,16 @@ else:
- 'trunk/src/opts/SkBitmapProcState_opts_none.cpp',
- 'trunk/src/opts/SkBlitMask_opts_none.cpp',
- 'trunk/src/opts/SkBlitRow_opts_none.cpp',
- 'trunk/src/opts/SkBlurImage_opts_none.cpp',
- 'trunk/src/opts/SkMorphology_opts_none.cpp',
- 'trunk/src/opts/SkTextureCompression_opts_none.cpp',
- 'trunk/src/opts/SkUtils_opts_none.cpp',
- 'trunk/src/opts/SkXfermode_opts_none.cpp',
-- 'trunk/src/ports/SkDiscardableMemory_none.cpp',
- ]
-
-
- # can we find a better way of dealing with asm sources?
-
- # left out of UNIFIED_SOURCES for now; that's not C++ anyway, nothing else to unify it with
- if not CONFIG['INTEL_ARCHITECTURE'] and CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']:
- SOURCES += [
-diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp
---- a/image/src/RasterImage.cpp
-+++ b/image/src/RasterImage.cpp
-@@ -313,21 +313,16 @@ RasterImage::Init(const char* aMimeType,
-
- // Store initialization data
- mSourceDataMimeType.Assign(aMimeType);
- mDiscardable = !!(aFlags & INIT_FLAG_DISCARDABLE);
- mDecodeOnDraw = !!(aFlags & INIT_FLAG_DECODE_ON_DRAW);
- mTransient = !!(aFlags & INIT_FLAG_TRANSIENT);
- mDownscaleDuringDecode = !!(aFlags & INIT_FLAG_DOWNSCALE_DURING_DECODE);
-
--#ifndef MOZ_ENABLE_SKIA
-- // Downscale-during-decode requires Skia.
-- mDownscaleDuringDecode = false;
--#endif
--
- // Lock this image's surfaces in the SurfaceCache if we're not discardable.
- if (!mDiscardable) {
- SurfaceCache::LockImage(ImageKey(this));
- }
-
- // Create the initial size decoder.
- nsresult rv = Decode(Nothing(), DECODE_FLAGS_DEFAULT);
- if (NS_FAILED(rv)) {
-@@ -1556,20 +1551,16 @@ RasterImage::RecoverFromLossOfFrames(con
- Decode(Some(aSize), aFlags);
++#ifdef MOZ_ENABLE_SKIA
+ static SkMatrix
+ Matrix3DToSkia(const gfx3DMatrix& aMatrix)
+ {
+@@ -186,10 +192,10 @@ Matrix3DToSkia(const gfx3DMatrix& aMatrix)
}
- bool
- RasterImage::CanScale(GraphicsFilter aFilter,
- const nsIntSize& aSize,
- uint32_t aFlags)
+ static void
+-SkiaTransform(DataSourceSurface* aDest,
+- DataSourceSurface* aSource,
+- const gfx3DMatrix& aTransform,
+- const Point& aDestOffset)
++Transform(DataSourceSurface* aDest,
++ DataSourceSurface* aSource,
++ const gfx3DMatrix& aTransform,
++ const Point& aDestOffset)
{
--#ifndef MOZ_ENABLE_SKIA
-- // The high-quality scaler requires Skia.
-- return false;
--#else
- // Check basic requirements: HQ downscaling is enabled, we have all the source
- // data and know our size, the flags allow us to do it, and a 'good' filter is
- // being used. The flags may ask us not to scale because the caller isn't
- // drawing to the window. If we're drawing to something else (e.g. a canvas)
- // we usually have no way of updating what we've drawn, so HQ scaling is
- // useless.
- if (!gfxPrefs::ImageHQDownscalingEnabled() || !mHasSize || !mHasSourceData ||
- !(aFlags & imgIContainer::FLAG_HIGH_QUALITY_SCALING) ||
-@@ -1609,17 +1600,16 @@ RasterImage::CanScale(GraphicsFilter aFi
- // XXX(seth): It's not clear what this check buys us over
- // gfxPrefs::ImageHQUpscalingMaxSize().
- // The default value of this pref is 1000, which means that we never upscale.
- // If that's all it's getting us, I'd rather we just forbid that explicitly.
- gfx::Size scale(double(aSize.width) / mSize.width,
- double(aSize.height) / mSize.height);
- gfxFloat minFactor = gfxPrefs::ImageHQDownscalingMinFactor() / 1000.0;
- return (scale.width < minFactor || scale.height < minFactor);
--#endif
+ if (aTransform.IsSingular()) {
+ return;
+@@ -225,6 +231,78 @@ SkiaTransform(DataSourceSurface* aDest,
+ SkRect destRect = SkRect::MakeXYWH(0, 0, srcSize.width, srcSize.height);
+ destCanvas.drawBitmapRectToRect(src, nullptr, destRect, &paint);
+ }
++#else
++static pixman_transform
++Matrix3DToPixman(const gfx3DMatrix& aMatrix)
++{
++ pixman_f_transform transform;
++
++ transform.m[0][0] = aMatrix._11;
++ transform.m[0][1] = aMatrix._21;
++ transform.m[0][2] = aMatrix._41;
++ transform.m[1][0] = aMatrix._12;
++ transform.m[1][1] = aMatrix._22;
++ transform.m[1][2] = aMatrix._42;
++ transform.m[2][0] = aMatrix._14;
++ transform.m[2][1] = aMatrix._24;
++ transform.m[2][2] = aMatrix._44;
++
++ pixman_transform result;
++ pixman_transform_from_pixman_f_transform(&result, &transform);
++
++ return result;
++}
++
++static void
++Transform(DataSourceSurface* aDest,
++ DataSourceSurface* aSource,
++ const gfx3DMatrix& aTransform,
++ const Point& aDestOffset)
++{
++ IntSize destSize = aDest->GetSize();
++ pixman_image_t* dest = pixman_image_create_bits(PIXMAN_a8r8g8b8,
++ destSize.width,
++ destSize.height,
++ (uint32_t*)aDest->GetData(),
++ aDest->Stride());
++
++ IntSize srcSize = aSource->GetSize();
++ pixman_image_t* src = pixman_image_create_bits(PIXMAN_a8r8g8b8,
++ srcSize.width,
++ srcSize.height,
++ (uint32_t*)aSource->GetData(),
++ aSource->Stride());
++
++ NS_ABORT_IF_FALSE(src && dest, "Failed to create pixman images?");
++
++ pixman_transform pixTransform = Matrix3DToPixman(aTransform);
++ pixman_transform pixTransformInverted;
++
++ // If the transform is singular then nothing would be drawn anyway, return here
++ if (!pixman_transform_invert(&pixTransformInverted, &pixTransform)) {
++ pixman_image_unref(dest);
++ pixman_image_unref(src);
++ return;
++ }
++ pixman_image_set_transform(src, &pixTransformInverted);
++
++ pixman_image_composite32(PIXMAN_OP_SRC,
++ src,
++ nullptr,
++ dest,
++ aDestOffset.x,
++ aDestOffset.y,
++ 0,
++ 0,
++ 0,
++ 0,
++ destSize.width,
++ destSize.height);
++
++ pixman_image_unref(dest);
++ pixman_image_unref(src);
++}
++#endif
+
+ static inline IntRect
+ RoundOut(Rect r)
+@@ -364,12 +442,16 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
+ RefPtr<SourceSurface> snapshot = dest->Snapshot();
+ RefPtr<DataSourceSurface> source = snapshot->GetDataSurface();
+ RefPtr<DataSourceSurface> temp =
+- Factory::CreateDataSourceSurface(RoundOut(transformBounds).Size(), SurfaceFormat::B8G8R8A8, true);
++ Factory::CreateDataSourceSurface(RoundOut(transformBounds).Size(), SurfaceFormat::B8G8R8A8
++#ifdef MOZ_ENABLE_SKIA
++ , true
++#endif
++ );
+ if (NS_WARN_IF(!temp)) {
+ return;
+ }
+
+- SkiaTransform(temp, source, new3DTransform, transformBounds.TopLeft());
++ Transform(temp, source, new3DTransform, transformBounds.TopLeft());
+
+ transformBounds.MoveTo(0, 0);
+ buffer->DrawSurface(temp, transformBounds, transformBounds);
+diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp
+index f4ec9e4..c849c27 100644
+--- a/gfx/layers/basic/BasicLayerManager.cpp
++++ b/gfx/layers/basic/BasicLayerManager.cpp
+@@ -46,8 +46,13 @@
+ #include "nsRect.h" // for nsIntRect
+ #include "nsRegion.h" // for nsIntRegion, etc
+ #include "nsTArray.h" // for nsAutoTArray
++#ifdef MOZ_ENABLE_SKIA
+ #include "skia/SkCanvas.h" // for SkCanvas
+ #include "skia/SkBitmapDevice.h" // for SkBitmapDevice
++#else
++#define PIXMAN_DONT_DEFINE_STDINT
++#include "pixman.h" // for pixman_f_transform, etc
++#endif
+ class nsIWidget;
+
+ namespace mozilla {
+@@ -601,6 +606,7 @@ BasicLayerManager::SetRoot(Layer* aLayer)
+ mRoot = aLayer;
}
- bool
- RasterImage::CanDownscaleDuringDecode(const nsIntSize& aSize, uint32_t aFlags)
++#ifdef MOZ_ENABLE_SKIA
+ static SkMatrix
+ BasicLayerManager_Matrix3DToSkia(const gfx3DMatrix& aMatrix)
+ {
+@@ -619,10 +625,10 @@ BasicLayerManager_Matrix3DToSkia(const gfx3DMatrix& aMatrix)
+ }
+
+ static void
+-SkiaTransform(const gfxImageSurface* aDest,
+- RefPtr<DataSourceSurface> aSrc,
+- const gfx3DMatrix& aTransform,
+- gfxPoint aDestOffset)
++Transform(const gfxImageSurface* aDest,
++ RefPtr<DataSourceSurface> aSrc,
++ const gfx3DMatrix& aTransform,
++ gfxPoint aDestOffset)
{
- // Check basic requirements: downscale-during-decode is enabled for this
- // image, we have all the source data and know our size, the flags allow us to
- // do it, and a 'good' filter is being used.
+ if (aTransform.IsSingular()) {
+ return;
+@@ -658,6 +664,78 @@ SkiaTransform(const gfxImageSurface* aDest,
+ SkRect destRect = SkRect::MakeXYWH(0, 0, srcSize.width, srcSize.height);
+ destCanvas.drawBitmapRectToRect(src, nullptr, destRect, &paint);
+ }
++#else
++static pixman_transform
++BasicLayerManager_Matrix3DToPixman(const gfx3DMatrix& aMatrix)
++{
++ pixman_f_transform transform;
++
++ transform.m[0][0] = aMatrix._11;
++ transform.m[0][1] = aMatrix._21;
++ transform.m[0][2] = aMatrix._41;
++ transform.m[1][0] = aMatrix._12;
++ transform.m[1][1] = aMatrix._22;
++ transform.m[1][2] = aMatrix._42;
++ transform.m[2][0] = aMatrix._14;
++ transform.m[2][1] = aMatrix._24;
++ transform.m[2][2] = aMatrix._44;
++
++ pixman_transform result;
++ pixman_transform_from_pixman_f_transform(&result, &transform);
++
++ return result;
++}
++
++static void
++Transform(const gfxImageSurface* aDest,
++ RefPtr<DataSourceSurface> aSrc,
++ const gfx3DMatrix& aTransform,
++ gfxPoint aDestOffset)
++{
++ IntSize destSize = ToIntSize(aDest->GetSize());
++ pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == gfxImageFormat::ARGB32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
++ destSize.width,
++ destSize.height,
++ (uint32_t*)aDest->Data(),
++ aDest->Stride());
++
++ IntSize srcSize = aSrc->GetSize();
++ pixman_image_t* src = pixman_image_create_bits(aSrc->GetFormat() == SurfaceFormat::B8G8R8A8 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
++ srcSize.width,
++ srcSize.height,
++ (uint32_t*)aSrc->GetData(),
++ aSrc->Stride());
++
++ NS_ABORT_IF_FALSE(src && dest, "Failed to create pixman images?");
++
++ pixman_transform pixTransform = BasicLayerManager_Matrix3DToPixman(aTransform);
++ pixman_transform pixTransformInverted;
++
++ // If the transform is singular then nothing would be drawn anyway, return here
++ if (!pixman_transform_invert(&pixTransformInverted, &pixTransform)) {
++ pixman_image_unref(dest);
++ pixman_image_unref(src);
++ return;
++ }
++ pixman_image_set_transform(src, &pixTransformInverted);
++
++ pixman_image_composite32(PIXMAN_OP_SRC,
++ src,
++ nullptr,
++ dest,
++ aDestOffset.x,
++ aDestOffset.y,
++ 0,
++ 0,
++ 0,
++ 0,
++ destSize.width,
++ destSize.height);
++
++ pixman_image_unref(dest);
++ pixman_image_unref(src);
++}
++#endif
+
+ /**
+ * Transform a surface using a gfx3DMatrix and blit to the destination if
+@@ -699,7 +777,7 @@ Transform3D(RefPtr<SourceSurface> aSource,
+ gfx3DMatrix translation = gfx3DMatrix::Translation(aBounds.x, aBounds.y, 0);
+
+ // Transform the content and offset it such that the content begins at the origin.
+- SkiaTransform(destImage, aSource->GetDataSurface(), translation * aTransform, offset);
++ Transform(destImage, aSource->GetDataSurface(), translation * aTransform, offset);
+
+ // If we haven't actually drawn to aDest then return our temporary image so
+ // that the caller can do this.
+--
+2.3.0.4.g34b1174
+