From 70703f7b42fa17c123a2a6b6c438b438fe45d115 Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Thu, 26 Aug 2021 19:00:10 +0000 Subject: [PATCH] Bug 1727807 - Remove unused gfxASurface::CreateSimilarSurface. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D123789 --- gfx/thebes/gfxASurface.cpp | 18 ----------- gfx/thebes/gfxASurface.h | 8 ----- gfx/thebes/gfxWindowsSurface.cpp | 36 --------------------- gfx/thebes/gfxWindowsSurface.h | 3 -- gfx/thebes/gfxXlibSurface.cpp | 54 -------------------------------- gfx/thebes/gfxXlibSurface.h | 5 --- 6 files changed, 124 deletions(-) diff --git a/gfx/thebes/gfxASurface.cpp b/gfx/thebes/gfxASurface.cpp index 5923ed060eb9..f0ff2334bd5d 100644 --- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -249,24 +249,6 @@ void gfxASurface::Finish() { cairo_surface_finish(mSurface); } -already_AddRefed gfxASurface::CreateSimilarSurface( - gfxContentType aContent, const IntSize& aSize) { - if (!mSurface || !mSurfaceValid) { - return nullptr; - } - - cairo_surface_t* surface = cairo_surface_create_similar( - mSurface, cairo_content_t(int(aContent)), aSize.width, aSize.height); - if (cairo_surface_status(surface)) { - cairo_surface_destroy(surface); - return nullptr; - } - - RefPtr result = Wrap(surface, aSize); - cairo_surface_destroy(surface); - return result.forget(); -} - already_AddRefed gfxASurface::CopyToARGB32ImageSurface() { if (!mSurface || !mSurfaceValid) { return nullptr; diff --git a/gfx/thebes/gfxASurface.h b/gfx/thebes/gfxASurface.h index 4968c6b19e32..d2e6daf77145 100644 --- a/gfx/thebes/gfxASurface.h +++ b/gfx/thebes/gfxASurface.h @@ -73,14 +73,6 @@ class gfxASurface { virtual void Finish(); - /** - * Create an offscreen surface that can be efficiently copied into - * this surface (at least if tiling is not involved). - * Returns null on error. - */ - virtual already_AddRefed CreateSimilarSurface( - gfxContentType aType, const mozilla::gfx::IntSize& aSize); - /** * Returns an image surface for this surface, or nullptr if not supported. * This will not copy image data, just wraps an image surface around diff --git a/gfx/thebes/gfxWindowsSurface.cpp b/gfx/thebes/gfxWindowsSurface.cpp index 35483ce16550..419c9ee696ab 100644 --- a/gfx/thebes/gfxWindowsSurface.cpp +++ b/gfx/thebes/gfxWindowsSurface.cpp @@ -65,42 +65,6 @@ void gfxWindowsSurface::InitWithDC(uint32_t flags) { } } -already_AddRefed gfxWindowsSurface::CreateSimilarSurface( - gfxContentType aContent, const mozilla::gfx::IntSize& aSize) { - if (!mSurface || !mSurfaceValid) { - return nullptr; - } - - cairo_surface_t* surface; - if (GetContentType() == gfxContentType::COLOR_ALPHA) { - // When creating a similar surface to a transparent surface, ensure - // the new surface uses a DIB. cairo_surface_create_similar won't - // use a DIB for a gfxContentType::COLOR surface if this surface doesn't - // have a DIB (e.g. if we're a transparent window surface). But - // we need a DIB to perform well if the new surface is composited into - // a surface that's the result of - // create_similar(gfxContentType::COLOR_ALPHA) (e.g. a backbuffer for the - // window) --- that new surface *would* have a DIB. - gfxImageFormat gformat = - gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent); - cairo_format_t cformat = GfxFormatToCairoFormat(gformat); - surface = - cairo_win32_surface_create_with_dib(cformat, aSize.width, aSize.height); - } else { - surface = cairo_surface_create_similar( - mSurface, (cairo_content_t)(int)aContent, aSize.width, aSize.height); - } - - if (cairo_surface_status(surface)) { - cairo_surface_destroy(surface); - return nullptr; - } - - RefPtr result = Wrap(surface, aSize); - cairo_surface_destroy(surface); - return result.forget(); -} - gfxWindowsSurface::~gfxWindowsSurface() { if (mOwnsDC) { if (mWnd) diff --git a/gfx/thebes/gfxWindowsSurface.h b/gfx/thebes/gfxWindowsSurface.h index 10a9b19ebb3d..3659cab37c9a 100644 --- a/gfx/thebes/gfxWindowsSurface.h +++ b/gfx/thebes/gfxWindowsSurface.h @@ -32,9 +32,6 @@ class gfxWindowsSurface : public gfxASurface { explicit gfxWindowsSurface(cairo_surface_t* csurf); - virtual already_AddRefed CreateSimilarSurface( - gfxContentType aType, const mozilla::gfx::IntSize& aSize); - void InitWithDC(uint32_t flags); virtual ~gfxWindowsSurface(); diff --git a/gfx/thebes/gfxXlibSurface.cpp b/gfx/thebes/gfxXlibSurface.cpp index f9173b0c6a96..f2ff6d9617f2 100644 --- a/gfx/thebes/gfxXlibSurface.cpp +++ b/gfx/thebes/gfxXlibSurface.cpp @@ -199,60 +199,6 @@ already_AddRefed gfxXlibSurface::Create( return result.forget(); } -/* static */ -already_AddRefed gfxXlibSurface::Create( - Screen* screen, XRenderPictFormat* format, const gfx::IntSize& size, - Drawable relatedDrawable) { - Drawable drawable = - CreatePixmap(screen, size, format->depth, relatedDrawable); - if (!drawable) return nullptr; - - RefPtr result = - new gfxXlibSurface(screen, drawable, format, size); - result->TakePixmap(); - - if (result->CairoStatus() != 0) return nullptr; - - return result.forget(); -} - -static bool GetForce24bppPref() { - return Preferences::GetBool("mozilla.widget.force-24bpp", false); -} - -already_AddRefed gfxXlibSurface::CreateSimilarSurface( - gfxContentType aContent, const gfx::IntSize& aSize) { - if (!mSurface || !mSurfaceValid) { - return nullptr; - } - - if (aContent == gfxContentType::COLOR) { - // cairo_surface_create_similar will use a matching visual if it can. - // However, systems with 16-bit or indexed default visuals may benefit - // from rendering with 24-bit formats. - static bool force24bpp = GetForce24bppPref(); - if (force24bpp && cairo_xlib_surface_get_depth(CairoSurface()) != 24) { - XRenderPictFormat* format = - XRenderFindStandardFormat(*mDisplay, PictStandardRGB24); - if (format) { - // Cairo only performs simple self-copies as desired if it - // knows that this is a Pixmap surface. It only knows that - // surfaces are pixmap surfaces if it creates the Pixmap - // itself, so we use cairo_surface_create_similar with a - // temporary reference surface to indicate the format. - Screen* screen = cairo_xlib_surface_get_screen(CairoSurface()); - RefPtr depth24reference = gfxXlibSurface::Create( - screen, format, gfx::IntSize(1, 1), mDrawable); - if (depth24reference) - return depth24reference->gfxASurface::CreateSimilarSurface(aContent, - aSize); - } - } - } - - return gfxASurface::CreateSimilarSurface(aContent, aSize); -} - void gfxXlibSurface::Finish() { if (mPixmapTaken && mGLXPixmap) { gl::sGLXLibrary.DestroyPixmap(*mDisplay, mGLXPixmap); diff --git a/gfx/thebes/gfxXlibSurface.h b/gfx/thebes/gfxXlibSurface.h index 902e9d4f9f01..97d0a5df37d1 100644 --- a/gfx/thebes/gfxXlibSurface.h +++ b/gfx/thebes/gfxXlibSurface.h @@ -57,14 +57,9 @@ class gfxXlibSurface final : public gfxASurface { static cairo_surface_t* CreateCairoSurface( ::Screen* screen, Visual* visual, const mozilla::gfx::IntSize& size, Drawable relatedDrawable = X11None); - static already_AddRefed Create( - ::Screen* screen, XRenderPictFormat* format, - const mozilla::gfx::IntSize& size, Drawable relatedDrawable = X11None); virtual ~gfxXlibSurface(); - already_AddRefed CreateSimilarSurface( - gfxContentType aType, const mozilla::gfx::IntSize& aSize) override; void Finish() override; const mozilla::gfx::IntSize GetSize() const override;