mozilla-disable-skia-be.patch
branchfirefox51
changeset 940 f63a4ac0fe06
equal deleted inserted replaced
939:3604ed712e16 940:f63a4ac0fe06
       
     1 
       
     2 # HG changeset patch
       
     3 # User Lee Salzman <lsalzman@mozilla.com>
       
     4 # Date 1484854371 18000
       
     5 # Node ID 42afdb8f7e6b3e8a465042f64c6c49782f231af4
       
     6 # Parent  dfadd79c97458f898d542461033a61dd34d3a5f0
       
     7 Bug 1319374 - Wrap PaintCounter with ifdef USE_SKIA. r=mchang, a=jcristau
       
     8 
       
     9 diff --git a/gfx/2d/BorrowedContext.h b/gfx/2d/BorrowedContext.h
       
    10 --- a/gfx/2d/BorrowedContext.h
       
    11 +++ b/gfx/2d/BorrowedContext.h
       
    12 @@ -190,18 +190,28 @@ public:
       
    13    }
       
    14  
       
    15    ~BorrowedCGContext() {
       
    16      MOZ_ASSERT(!cg);
       
    17    }
       
    18  
       
    19    CGContextRef cg;
       
    20  private:
       
    21 +#ifdef USE_SKIA
       
    22    static CGContextRef BorrowCGContextFromDrawTarget(DrawTarget *aDT);
       
    23    static void ReturnCGContextToDrawTarget(DrawTarget *aDT, CGContextRef cg);
       
    24 +#else
       
    25 +  static CGContextRef BorrowCGContextFromDrawTarget(DrawTarget *aDT) {
       
    26 +    MOZ_CRASH("Not supported without Skia");
       
    27 +  }
       
    28 +
       
    29 +  static void ReturnCGContextToDrawTarget(DrawTarget *aDT, CGContextRef cg) {
       
    30 +    MOZ_CRASH("not supported without Skia");
       
    31 +  }
       
    32 +#endif
       
    33    DrawTarget *mDT;
       
    34  };
       
    35  #endif
       
    36  
       
    37  } // namespace gfx
       
    38  } // namespace mozilla
       
    39  
       
    40  #endif // _MOZILLA_GFX_BORROWED_CONTEXT_H
       
    41 diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp
       
    42 --- a/gfx/layers/composite/LayerManagerComposite.cpp
       
    43 +++ b/gfx/layers/composite/LayerManagerComposite.cpp
       
    44 @@ -7,17 +7,16 @@
       
    45  #include <stddef.h>                     // for size_t
       
    46  #include <stdint.h>                     // for uint16_t, uint32_t
       
    47  #include "CanvasLayerComposite.h"       // for CanvasLayerComposite
       
    48  #include "ColorLayerComposite.h"        // for ColorLayerComposite
       
    49  #include "Composer2D.h"                 // for Composer2D
       
    50  #include "CompositableHost.h"           // for CompositableHost
       
    51  #include "ContainerLayerComposite.h"    // for ContainerLayerComposite, etc
       
    52  #include "FPSCounter.h"                 // for FPSState, FPSCounter
       
    53 -#include "PaintCounter.h"               // For PaintCounter
       
    54  #include "FrameMetrics.h"               // for FrameMetrics
       
    55  #include "GeckoProfiler.h"              // for profiler_set_frame_number, etc
       
    56  #include "ImageLayerComposite.h"        // for ImageLayerComposite
       
    57  #include "Layers.h"                     // for Layer, ContainerLayer, etc
       
    58  #include "LayerScope.h"                 // for LayerScope Tool
       
    59  #include "protobuf/LayerScopePacket.pb.h" // for protobuf (LayerScope)
       
    60  #include "PaintedLayerComposite.h"      // for PaintedLayerComposite
       
    61  #include "TiledContentHost.h"
       
    62 @@ -68,16 +67,20 @@
       
    63  #include "nsScreenManagerGonk.h"
       
    64  #include "nsWindow.h"
       
    65  #endif
       
    66  #include "GeckoProfiler.h"
       
    67  #include "TextRenderer.h"               // for TextRenderer
       
    68  #include "mozilla/layers/CompositorBridgeParent.h"
       
    69  #include "TreeTraversal.h"              // for ForEachNode
       
    70  
       
    71 +#ifdef USE_SKIA
       
    72 +#include "PaintCounter.h"               // For PaintCounter
       
    73 +#endif
       
    74 +
       
    75  class gfxContext;
       
    76  
       
    77  namespace mozilla {
       
    78  namespace layers {
       
    79  
       
    80  class ImageLayer;
       
    81  
       
    82  using namespace mozilla::gfx;
       
    83 @@ -128,16 +131,20 @@ LayerManagerComposite::LayerManagerCompo
       
    84  , mGeometryChanged(true)
       
    85  , mLastFrameMissedHWC(false)
       
    86  , mWindowOverlayChanged(false)
       
    87  , mLastPaintTime(TimeDuration::Forever())
       
    88  , mRenderStartTime(TimeStamp::Now())
       
    89  {
       
    90    mTextRenderer = new TextRenderer(aCompositor);
       
    91    MOZ_ASSERT(aCompositor);
       
    92 +
       
    93 +#ifdef USE_SKIA
       
    94 +  mPaintCounter = nullptr;
       
    95 +#endif
       
    96  }
       
    97  
       
    98  LayerManagerComposite::~LayerManagerComposite()
       
    99  {
       
   100    Destroy();
       
   101  }
       
   102  
       
   103  
       
   104 @@ -146,18 +153,21 @@ LayerManagerComposite::Destroy()
       
   105  {
       
   106    if (!mDestroyed) {
       
   107      mCompositor->GetWidget()->CleanupWindowEffects();
       
   108      if (mRoot) {
       
   109        RootLayer()->Destroy();
       
   110      }
       
   111      mRoot = nullptr;
       
   112      mClonedLayerTreeProperties = nullptr;
       
   113 +    mDestroyed = true;
       
   114 +
       
   115 +#ifdef USE_SKIA
       
   116      mPaintCounter = nullptr;
       
   117 -    mDestroyed = true;
       
   118 +#endif
       
   119    }
       
   120  }
       
   121  
       
   122  void
       
   123  LayerManagerComposite::UpdateRenderBounds(const IntRect& aRect)
       
   124  {
       
   125    mRenderBounds = aRect;
       
   126  }
       
   127 @@ -559,48 +569,52 @@ LayerManagerComposite::RootLayer() const
       
   128  #endif
       
   129  
       
   130  void
       
   131  LayerManagerComposite::InvalidateDebugOverlay(nsIntRegion& aInvalidRegion, const IntRect& aBounds)
       
   132  {
       
   133    bool drawFps = gfxPrefs::LayersDrawFPS();
       
   134    bool drawFrameCounter = gfxPrefs::DrawFrameCounter();
       
   135    bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars();
       
   136 -  bool drawPaintTimes = gfxPrefs::AlwaysPaint();
       
   137  
       
   138    if (drawFps || drawFrameCounter) {
       
   139      aInvalidRegion.Or(aInvalidRegion, nsIntRect(0, 0, 256, 256));
       
   140    }
       
   141    if (drawFrameColorBars) {
       
   142      aInvalidRegion.Or(aInvalidRegion, nsIntRect(0, 0, 10, aBounds.height));
       
   143    }
       
   144 +
       
   145 +#ifdef USE_SKIA
       
   146 +  bool drawPaintTimes = gfxPrefs::AlwaysPaint();
       
   147    if (drawPaintTimes) {
       
   148      aInvalidRegion.Or(aInvalidRegion, nsIntRect(PaintCounter::GetPaintRect()));
       
   149    }
       
   150 +#endif
       
   151  }
       
   152  
       
   153 +#ifdef USE_SKIA
       
   154  void
       
   155  LayerManagerComposite::DrawPaintTimes(Compositor* aCompositor)
       
   156  {
       
   157    if (!mPaintCounter) {
       
   158      mPaintCounter = new PaintCounter();
       
   159    }
       
   160  
       
   161    TimeDuration compositeTime = TimeStamp::Now() - mRenderStartTime;
       
   162    mPaintCounter->Draw(aCompositor, mLastPaintTime, compositeTime);
       
   163  }
       
   164 +#endif
       
   165  
       
   166  static uint16_t sFrameCount = 0;
       
   167  void
       
   168  LayerManagerComposite::RenderDebugOverlay(const IntRect& aBounds)
       
   169  {
       
   170    bool drawFps = gfxPrefs::LayersDrawFPS();
       
   171    bool drawFrameCounter = gfxPrefs::DrawFrameCounter();
       
   172    bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars();
       
   173 -  bool drawPaintTimes = gfxPrefs::AlwaysPaint();
       
   174  
       
   175    TimeStamp now = TimeStamp::Now();
       
   176  
       
   177    if (drawFps) {
       
   178      if (!mFPS) {
       
   179        mFPS = MakeUnique<FPSState>();
       
   180      }
       
   181  
       
   182 @@ -731,19 +745,22 @@ LayerManagerComposite::RenderDebugOverla
       
   183    }
       
   184  #endif
       
   185  
       
   186    if (drawFrameColorBars || drawFrameCounter) {
       
   187      // We intentionally overflow at 2^16.
       
   188      sFrameCount++;
       
   189    }
       
   190  
       
   191 +#ifdef USE_SKIA
       
   192 +  bool drawPaintTimes = gfxPrefs::AlwaysPaint();
       
   193    if (drawPaintTimes) {
       
   194      DrawPaintTimes(mCompositor);
       
   195    }
       
   196 +#endif
       
   197  }
       
   198  
       
   199  RefPtr<CompositingRenderTarget>
       
   200  LayerManagerComposite::PushGroupForLayerEffects()
       
   201  {
       
   202    // This is currently true, so just making sure that any new use of this
       
   203    // method is flagged for investigation
       
   204    MOZ_ASSERT(gfxPrefs::LayersEffectInvert() ||
       
   205 diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h
       
   206 --- a/gfx/layers/composite/LayerManagerComposite.h
       
   207 +++ b/gfx/layers/composite/LayerManagerComposite.h
       
   208 @@ -326,21 +326,16 @@ private:
       
   209     * Render the current layer tree to the active target.
       
   210     */
       
   211    void Render(const nsIntRegion& aInvalidRegion, const nsIntRegion& aOpaqueRegion);
       
   212  #if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
       
   213    void RenderToPresentationSurface();
       
   214  #endif
       
   215  
       
   216    /**
       
   217 -   * Render paint and composite times above the frame.
       
   218 -   */
       
   219 -  void DrawPaintTimes(Compositor* aCompositor);
       
   220 -
       
   221 -  /**
       
   222     * We need to know our invalid region before we're ready to render.
       
   223     */
       
   224    void InvalidateDebugOverlay(nsIntRegion& aInvalidRegion, const gfx::IntRect& aBounds);
       
   225  
       
   226    /**
       
   227     * Render debug overlays such as the FPS/FrameCounter above the frame.
       
   228     */
       
   229    void RenderDebugOverlay(const gfx::IntRect& aBounds);
       
   230 @@ -386,19 +381,26 @@ private:
       
   231    RefPtr<TextRenderer> mTextRenderer;
       
   232    bool mGeometryChanged;
       
   233  
       
   234    // Testing property. If hardware composer is supported, this will return
       
   235    // true if the last frame was deemed 'too complicated' to be rendered.
       
   236    bool mLastFrameMissedHWC;
       
   237  
       
   238    bool mWindowOverlayChanged;
       
   239 -  RefPtr<PaintCounter> mPaintCounter;
       
   240    TimeDuration mLastPaintTime;
       
   241    TimeStamp mRenderStartTime;
       
   242 +
       
   243 +#ifdef USE_SKIA
       
   244 +  /**
       
   245 +   * Render paint and composite times above the frame.
       
   246 +   */
       
   247 +  void DrawPaintTimes(Compositor* aCompositor);
       
   248 +  RefPtr<PaintCounter> mPaintCounter;
       
   249 +#endif
       
   250  };
       
   251  
       
   252  /**
       
   253   * Composite layers are for use with OMTC on the compositor thread only. There
       
   254   * must be corresponding Basic layers on the content thread. For composite
       
   255   * layers, the layer manager only maintains the layer tree, all rendering is
       
   256   * done by a Compositor (see Compositor.h). As such, composite layers are
       
   257   * platform-independent and can be used on any platform for which there is a
       
   258 diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build
       
   259 --- a/gfx/layers/moz.build
       
   260 +++ b/gfx/layers/moz.build
       
   261 @@ -335,17 +335,16 @@ UNIFIED_SOURCES += [
       
   262      'composite/CompositableHost.cpp',
       
   263      'composite/ContainerLayerComposite.cpp',
       
   264      'composite/ContentHost.cpp',
       
   265      'composite/FPSCounter.cpp',
       
   266      'composite/FrameUniformityData.cpp',
       
   267      'composite/ImageHost.cpp',
       
   268      'composite/ImageLayerComposite.cpp',
       
   269      'composite/LayerManagerComposite.cpp',
       
   270 -    'composite/PaintCounter.cpp',
       
   271      'composite/PaintedLayerComposite.cpp',
       
   272      'composite/TextRenderer.cpp',
       
   273      'composite/TextureHost.cpp',
       
   274      'composite/TiledContentHost.cpp',
       
   275      'Compositor.cpp',
       
   276      'CopyableCanvasLayer.cpp',
       
   277      'Effects.cpp',
       
   278      'FrameMetrics.cpp',
       
   279 @@ -480,8 +479,13 @@ MOCHITEST_CHROME_MANIFESTS += ['apz/test
       
   280  
       
   281  CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
       
   282  CXXFLAGS += CONFIG['TK_CFLAGS']
       
   283  
       
   284  LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
       
   285  
       
   286  if CONFIG['GNU_CXX']:
       
   287      CXXFLAGS += ['-Wno-error=shadow']
       
   288 +
       
   289 +if CONFIG['MOZ_ENABLE_SKIA']:
       
   290 +  UNIFIED_SOURCES += [
       
   291 +    'composite/PaintCounter.cpp',
       
   292 +  ]