Commit d002b869 authored by Jonathan Kew's avatar Jonathan Kew
Browse files

Bug 1779202 - Disable use of CGLayer-backed cairo quartz surfaces to work...

Bug 1779202 - Disable use of CGLayer-backed cairo quartz surfaces to work around scaling bug affecting XObject images in pdf.js output. r=dholbert

This avoids the apparent Core Graphics bug whereby the PDF output it generates will mis-render
when subsequently processed again by Core Graphics (although it renders OK in Adobe products).
Unfortunately, this will regress bug 1772225, so that pdf.js documents will be rasterized when
printed or in Save to PDF output on macOS.

(Setting the pref gfx.cairo_quartz_cg_layer.enabled to true will restore "good" (vector-based)
output, but embedded XObject bitmap images may be mis-scaled.)

Differential Revision: https://phabricator.services.mozilla.com/D156570
parent 09e004e7
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include "mozilla/Scoped.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/Vector.h"
#include "mozilla/StaticPrefs_gfx.h"
#include "mozilla/StaticPrefs_print.h"
#include "nsPrintfCString.h"

@@ -1757,10 +1758,13 @@ already_AddRefed<DrawTarget> DrawTargetCairo::CreateSimilarDrawTarget(
#endif
#ifdef CAIRO_HAS_QUARTZ_SURFACE
    case CAIRO_SURFACE_TYPE_QUARTZ:
      if (StaticPrefs::gfx_cairo_quartz_cg_layer_enabled()) {
        similar = cairo_quartz_surface_create_cg_layer(
            mSurface, GfxFormatToCairoContent(aFormat), aSize.width,
            aSize.height);
        break;
      }
      [[fallthrough]];
#endif
    default:
      similar = cairo_surface_create_similar(mSurface,
+8 −4
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/StaticPrefs_gfx.h"
#include "nsReadableUtils.h"
#include "nsString.h"
#include "nsUTF8Utils.h"
@@ -107,10 +108,13 @@ already_AddRefed<DrawTarget> PrintTarget::GetReferenceDrawTarget() {
#endif
#ifdef CAIRO_HAS_QUARTZ_SURFACE
      case CAIRO_SURFACE_TYPE_QUARTZ:
        if (StaticPrefs::gfx_cairo_quartz_cg_layer_enabled()) {
          similar = cairo_quartz_surface_create_cg_layer(
            mCairoSurface, cairo_surface_get_content(mCairoSurface), size.width,
            size.height);
              mCairoSurface, cairo_surface_get_content(mCairoSurface),
              size.width, size.height);
          break;
        }
        [[fallthrough]];
#endif
      default:
        similar = cairo_surface_create_similar(
+7 −0
Original line number Diff line number Diff line
@@ -5352,6 +5352,13 @@
  value: 0
  mirror: once

#if defined(XP_MACOSX)
- name: gfx.cairo_quartz_cg_layer.enabled
  type: bool
  value: false
  mirror: always
#endif

- name: gfx.canvas.accelerated
  type: RelaxedAtomicBool
#if defined(XP_MACOSX) || defined(XP_LINUX) && !defined(ANDROID)