Bug 849253 - Make SkiaGL a build-time option independent of Skia, and disable it on PPC[64] r=mattwoodrow
authorGeorge Wright <gwright@mozilla.com>
Wed, 13 Mar 2013 19:29:47 -0400
changeset 136352 ee2bfeaaecaaf8f1ac25d180c0c74ed2e3401730
parent 136351 e513c5d3b41637dae0beebe415edc6e1809886a2
child 136353 0f6a7422810308bbe69b13c7782005c06f31d0f6
push id2452
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 16:59:38 +0000
treeherdermozilla-beta@d4b152d29d8d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs849253
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 849253 - Make SkiaGL a build-time option independent of Skia, and disable it on PPC[64] r=mattwoodrow
configure.in
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/CanvasRenderingContext2D.h
gfx/2d/2D.h
gfx/2d/DrawTargetSkia.cpp
gfx/2d/DrawTargetSkia.h
gfx/2d/Factory.cpp
gfx/gl/Makefile.in
gfx/skia/Makefile.in
gfx/skia/include/config/SkUserConfig.h
gfx/thebes/gfxPlatform.cpp
--- a/configure.in
+++ b/configure.in
@@ -8319,16 +8319,22 @@ 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)
   elif test "$OS_ARCH" = "WINNT"; then
     AC_DEFINE(SKIA_DLL)
     AC_DEFINE(GR_DLL)
   fi
+
+  if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64"; then
+    MOZ_ENABLE_SKIA_GPU=1
+    AC_DEFINE(USE_SKIA_GPU)
+    AC_SUBST(MOZ_ENABLE_SKIA_GPU)
+  fi
 else
   MOZ_SKIA_LIBS=
 fi
 AC_SUBST(MOZ_ENABLE_SKIA)
 AC_SUBST(MOZ_SKIA_LIBS)
 
 dnl ========================================================
 dnl disable xul
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -91,17 +91,17 @@
 #include "nsWrapperCacheInlines.h"
 #include "nsJSUtils.h"
 #include "XPCQuickStubs.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/HTMLImageElement.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "mozilla/dom/CanvasRenderingContext2DBinding.h"
 
-#ifdef USE_SKIA
+#ifdef USE_SKIA_GPU
 #include "GLContext.h"
 #include "GLContextProvider.h"
 #include "SurfaceTypes.h"
 #endif
 
 #ifdef XP_WIN
 #include "gfxWindowsPlatform.h"
 #endif
@@ -462,17 +462,17 @@ public:
   }
   ~CanvasRenderingContext2DUserData()
   {
     if (mContext) {
       mContext->mUserDatas.RemoveElement(this);
     }
   }
 
-#ifdef USE_SKIA
+#ifdef USE_SKIA_GPU
   static void PreTransactionCallback(void* aData)
   {
     CanvasRenderingContext2DUserData* self =
       static_cast<CanvasRenderingContext2DUserData*>(aData);
     CanvasRenderingContext2D* context = self->mContext;
     if (self->mContext && context->mGLContext) {
       context->mGLContext->MakeCurrent();
       context->mGLContext->PublishFrame();
@@ -794,17 +794,17 @@ CanvasRenderingContext2D::EnsureTarget()
     nsRefPtr<LayerManager> layerManager = nullptr;
 
     if (ownerDoc) {
       layerManager =
         nsContentUtils::PersistentLayerManagerForDocument(ownerDoc);
     }
 
      if (layerManager) {
-#ifdef USE_SKIA
+#ifdef USE_SKIA_GPU
        if (gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas()) {
          mGLContext = mozilla::gl::GLContextProvider::CreateOffscreen(gfxIntSize(size.width,
                                                                                  size.height),
                                                                       SurfaceCaps::ForRGBA(),
                                                                       mozilla::gl::GLContext::ContextFlagsNone);
          mTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForFBO(0, mGLContext, size, format);
        } else
 #endif
@@ -3781,17 +3781,17 @@ CanvasRenderingContext2D::GetCanvasLayer
   // The userData will receive DidTransactionCallbacks, which flush the
   // the invalidation state to indicate that the canvas is up to date.
   userData = new CanvasRenderingContext2DUserData(this);
   canvasLayer->SetDidTransactionCallback(
           CanvasRenderingContext2DUserData::DidTransactionCallback, userData);
   canvasLayer->SetUserData(&g2DContextLayerUserData, userData);
 
   CanvasLayer::Data data;
-#ifdef USE_SKIA
+#ifdef USE_SKIA_GPU
   if (mGLContext) {
     canvasLayer->SetPreTransactionCallback(
             CanvasRenderingContext2DUserData::PreTransactionCallback, userData);
     data.mGLContext = mGLContext;
   } else
 #endif
   {
     data.mDrawTarget = mTarget;
--- a/content/canvas/src/CanvasRenderingContext2D.h
+++ b/content/canvas/src/CanvasRenderingContext2D.h
@@ -711,17 +711,17 @@ protected:
 
   /**
     * Number of times we've invalidated before calling redraw
     */
   uint32_t mInvalidateCount;
   static const uint32_t kCanvasMaxInvalidateCount = 100;
 
 
-#ifdef USE_SKIA
+#ifdef USE_SKIA_GPU
   nsRefPtr<gl::GLContext> mGLContext;
 #endif
 
   /**
     * Returns true if a shadow should be drawn along with a
     * drawing operation.
     */
   bool NeedToDrawShadow()
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -914,17 +914,17 @@ public:
     CreateWrappingDataSourceSurface(uint8_t *aData, int32_t aStride,
                                     const IntSize &aSize, SurfaceFormat aFormat);
 
   static TemporaryRef<DrawEventRecorder>
     CreateEventRecorderForFile(const char *aFilename);
 
   static void SetGlobalEventRecorder(DrawEventRecorder *aRecorder);
 
-#ifdef USE_SKIA
+#ifdef USE_SKIA_GPU
   static TemporaryRef<DrawTarget>
     CreateSkiaDrawTargetForFBO(unsigned int aFBOID, GrContext *aContext, const IntSize &aSize, SurfaceFormat aFormat);
 #endif
 
 #ifdef WIN32
   static TemporaryRef<DrawTarget> CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
   static TemporaryRef<DrawTarget>
     CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA,
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -2,17 +2,21 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DrawTargetSkia.h"
 #include "SourceSurfaceSkia.h"
 #include "ScaledFontBase.h"
 #include "skia/SkDevice.h"
+
+#ifdef USE_SKIA_GPU
 #include "skia/SkGpuDevice.h"
+#endif
+
 #include "skia/SkTypeface.h"
 #include "skia/SkGradientShader.h"
 #include "skia/SkBlurDrawLooper.h"
 #include "skia/SkBlurMaskFilter.h"
 #include "skia/SkColorFilter.h"
 #include "skia/SkLayerRasterizer.h"
 #include "skia/SkLayerDrawLooper.h"
 #include "skia/SkDashPathEffect.h"
@@ -589,16 +593,17 @@ DrawTargetSkia::Init(const IntSize &aSiz
   mSize = aSize;
 
   mDevice = device.get();
   mCanvas = canvas.get();
   mFormat = aFormat;
   return true;
 }
 
+#ifdef USE_SKIA_GPU
 void
 DrawTargetSkia::InitWithFBO(unsigned int aFBOID, GrContext* aGrContext, const IntSize &aSize, SurfaceFormat aFormat)
 {
   GrPlatformRenderTargetDesc targetDescriptor;
 
   targetDescriptor.fWidth = aSize.width;
   targetDescriptor.fHeight = aSize.height;
   targetDescriptor.fConfig = GfxFormatToGrConfig(aFormat);
@@ -610,16 +615,17 @@ DrawTargetSkia::InitWithFBO(unsigned int
   SkAutoTUnref<SkDevice> device(new SkGpuDevice(aGrContext, target.get()));
   SkAutoTUnref<SkCanvas> canvas(new SkCanvas(device.get()));
   mSize = aSize;
 
   mDevice = device.get();
   mCanvas = canvas.get();
   mFormat = aFormat;
 }
+#endif
 
 void
 DrawTargetSkia::Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat)
 {
   if (aFormat == FORMAT_B8G8R8X8) {
     // We have to manually set the A channel to be 255 as Skia doesn't understand BGRX
     ConvertBGRXToBGRA(aData, aSize, aStride);
     mBitmap.setIsOpaque(true);
--- a/gfx/2d/DrawTargetSkia.h
+++ b/gfx/2d/DrawTargetSkia.h
@@ -1,19 +1,22 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #pragma once
 
-#include "skia/GrContext.h"
-#include "skia/SkCanvas.h"
+#ifdef USE_SKIA_GPU
 #include "skia/GrContext.h"
 #include "skia/GrGLInterface.h"
+#endif
+
+#include "skia/SkCanvas.h"
+
 #include "2D.h"
 #include "Rect.h"
 #include "PathSkia.h"
 #include <sstream>
 #include <vector>
 
 namespace mozilla {
 namespace gfx {
@@ -85,17 +88,19 @@ public:
   virtual TemporaryRef<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
   virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FILL_WINDING) const;
   virtual TemporaryRef<GradientStops> CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, ExtendMode aExtendMode = EXTEND_CLAMP) const;
   virtual void SetTransform(const Matrix &aTransform);
 
   bool Init(const IntSize &aSize, SurfaceFormat aFormat);
   void Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat);
+#ifdef USE_SKIA_GPU
   void InitWithFBO(unsigned int aFBOID, GrContext* aGrContext, const IntSize &aSize, SurfaceFormat aFormat);
+#endif
   
   operator std::string() const {
     std::stringstream stream;
     stream << "DrawTargetSkia(" << this << ")";
     return stream.str();
   }
 private:
   friend class SourceSurfaceSkia;
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -444,25 +444,25 @@ Factory::GetD2DVRAMUsageSourceSurface()
 void
 Factory::D2DCleanup()
 {
   DrawTargetD2D::CleanupD2D();
 }
 
 #endif // XP_WIN
 
-#ifdef USE_SKIA
+#ifdef USE_SKIA_GPU
 TemporaryRef<DrawTarget>
 Factory::CreateSkiaDrawTargetForFBO(unsigned int aFBOID, GrContext *aGrContext, const IntSize &aSize, SurfaceFormat aFormat)
 {
   RefPtr<DrawTargetSkia> newTarget = new DrawTargetSkia();
   newTarget->InitWithFBO(aFBOID, aGrContext, aSize, aFormat);
   return newTarget;
 }
-#endif // USE_SKIA
+#endif // USE_SKIA_GPU
 
 TemporaryRef<DrawTarget>
 Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize)
 {
   RefPtr<DrawTarget> retVal;
 
 #ifdef USE_CAIRO
   RefPtr<DrawTargetCairo> newTarget = new DrawTargetCairo();
--- a/gfx/gl/Makefile.in
+++ b/gfx/gl/Makefile.in
@@ -131,17 +131,17 @@ CPPSRCS += \
   SharedSurfaceANGLE.cpp \
   $(NULL)
 endif
 
 ifdef MOZ_ANDROID_OMTC
 DEFINES += -DMOZ_ANDROID_OMTC
 endif
 
-ifdef MOZ_ENABLE_SKIA
+ifdef MOZ_ENABLE_SKIA_GPU
 CPPSRCS += GLContextSkia.cpp
 EXPORTS += GLContextSkia.h
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES := $(filter-out -DUNICODE,$(DEFINES))
 
--- a/gfx/skia/Makefile.in
+++ b/gfx/skia/Makefile.in
@@ -423,19 +423,24 @@ CPPSRCS = \
 	SkTwoPointConicalGradient.cpp \
 	SkTwoPointRadialGradient.cpp \
 	SkTypeface.cpp \
 	SkTypefaceCache.cpp \
 	SkUnPreMultiply.cpp \
 	SkUtils.cpp \
 	SkWriter32.cpp \
 	SkXfermode.cpp \
+	$(NULL)
+
+ifdef MOZ_ENABLE_SKIA_GPU
+CPPSRCS += \
 	$(GPU_CPPSRCS) \
 	$(GPU_GL_CPPSRCS) \
 	$(NULL)
+endif
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXPORTS_skia += \
 	include/ports/SkTypeface_mac.h \
 	$(NULL)
 CPPSRCS += \
 	SkFontHost_mac_coretext.cpp \
 	SkStream_mac.cpp \
--- a/gfx/skia/include/config/SkUserConfig.h
+++ b/gfx/skia/include/config/SkUserConfig.h
@@ -179,17 +179,21 @@
 
 /* Determines whether to build code that supports the GPU backend. Some classes
    that are not GPU-specific, such as SkShader subclasses, have optional code
    that is used allows them to interact with the GPU backend. If you'd like to
    omit this code set SK_SUPPORT_GPU to 0. This also allows you to omit the gpu
    directories from your include search path when you're not building the GPU
    backend. Defaults to 1 (build the GPU code).
  */
-#define SK_SUPPORT_GPU 1
+#ifdef USE_SKIA_GPU
+    #define SK_SUPPORT_GPU 1
+#else
+    #define SK_SUPPORT_GPU 0
+#endif
 
 /*  Don't dither 32bit gradients, to match what the canvas test suite expects.
  */
 #define SK_DISABLE_DITHER_32BIT_GRADIENT
 
 /*  Don't include stdint.h on windows as it conflicts with our build system.
  */
 #ifdef SK_BUILD_FOR_WIN32 
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -58,17 +58,17 @@
 #include "nsCRT.h"
 #include "GLContext.h"
 #include "GLContextProvider.h"
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "TexturePoolOGL.h"
 #endif
 
-#ifdef USE_SKIA
+#ifdef USE_SKIA_GPU
 #include "skia/GrContext.h"
 #include "skia/GrGLInterface.h"
 #include "GLContextSkia.h"
 #endif
 
 #include "mozilla/Preferences.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
@@ -784,17 +784,17 @@ gfxPlatform::CreateDrawTargetForData(uns
   NS_ASSERTION(mPreferredCanvasBackend, "No backend.");
   return Factory::CreateDrawTargetForData(mPreferredCanvasBackend, aData, aSize, aStride, aFormat);
 }
 
 RefPtr<DrawTarget>
 gfxPlatform::CreateDrawTargetForFBO(unsigned int aFBOID, mozilla::gl::GLContext* aGLContext, const IntSize& aSize, SurfaceFormat aFormat)
 {
   NS_ASSERTION(mPreferredCanvasBackend, "No backend.");
-#ifdef USE_SKIA
+#ifdef USE_SKIA_GPU
   if (mPreferredCanvasBackend == BACKEND_SKIA) {
     static uint8_t sGrContextKey;
     GrContext* ctx = reinterpret_cast<GrContext*>(aGLContext->GetUserData(&sGrContextKey));
     if (!ctx) {
       GrGLInterface* grInterface = CreateGrInterfaceFromGLContext(aGLContext);
       ctx = GrContext::Create(kOpenGL_Shaders_GrEngine, (GrPlatform3DContext)grInterface);
       aGLContext->SetUserData(&sGrContextKey, ctx);
     }