Bug 929513 Part 5: Use LayerIntSize for CanUseCanvasLayerForSize r=nical
authorDavid Zbarsky <dzbarsky@gmail.com>
Sun, 27 Oct 2013 17:53:27 -0400
changeset 166238 51130b50a7dfe1d91fd8113df9f9cfe121e29817
parent 166237 0fbcde0e9bbdd70b93afed9392c3beb36cf6faa5
child 166239 381baaf48bd26ba8df7887fd2f8c11aba664c400
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs929513
milestone27.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 929513 Part 5: Use LayerIntSize for CanUseCanvasLayerForSize r=nical
content/canvas/src/CanvasRenderingContext2D.cpp
gfx/layers/Compositor.h
gfx/layers/Layers.h
gfx/layers/basic/BasicCompositor.h
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
gfx/layers/d3d10/LayerManagerD3D10.h
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/CompositorD3D11.h
gfx/layers/d3d9/CompositorD3D9.cpp
gfx/layers/d3d9/CompositorD3D9.h
gfx/layers/d3d9/LayerManagerD3D9.h
gfx/layers/opengl/CompositorOGL.h
gfx/layers/opengl/LayerManagerOGL.h
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -3974,13 +3974,13 @@ CanvasRenderingContext2D::MarkContextCle
   mIsEntireFrameInvalid = false;
   mInvalidateCount = 0;
 }
 
 
 bool
 CanvasRenderingContext2D::ShouldForceInactiveLayer(LayerManager *aManager)
 {
-  return !aManager->CanUseCanvasLayerForSize(gfxIntSize(mWidth, mHeight));
+  return !aManager->CanUseCanvasLayerForSize(LayerIntSize(mWidth, mHeight));
 }
 
 }
 }
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -205,17 +205,17 @@ public:
    * across process or thread boundaries that are compatible with this
    * compositor.
    */
   virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() = 0;
 
   /**
    * Properties of the compositor.
    */
-  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) = 0;
+  virtual bool CanUseCanvasLayerForSize(const LayerIntSize& aSize) = 0;
   virtual int32_t GetMaxTextureSize() const = 0;
 
   /**
    * Set the target for rendering. Results will have been written to aTarget by
    * the time that EndFrame returns.
    *
    * If this method is not used, or we pass in nullptr, we target the compositor's
    * usual swap chain and render to the screen.
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -410,17 +410,17 @@ public:
   /**
    * Creates a DrawTarget for use with canvas which is optimized for
    * inter-operating with this layermanager.
    */
   virtual TemporaryRef<mozilla::gfx::DrawTarget>
     CreateDrawTarget(const mozilla::gfx::IntSize &aSize,
                      mozilla::gfx::SurfaceFormat aFormat);
 
-  virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) { return true; }
+  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) { return true; }
 
   /**
    * Returns a TextureFactoryIdentifier which describes properties of the backend
    * used to decide what kind of texture and buffer clients to create
    */
   virtual TextureFactoryIdentifier GetTextureFactoryIdentifier();
 
   /**
--- a/gfx/layers/basic/BasicCompositor.h
+++ b/gfx/layers/basic/BasicCompositor.h
@@ -89,17 +89,17 @@ public:
   virtual void EndFrame() MOZ_OVERRIDE;
   virtual void EndFrameForExternalComposition(const gfxMatrix& aTransform) MOZ_OVERRIDE
   {
     NS_RUNTIMEABORT("We shouldn't ever hit this");
   }
   virtual void AbortFrame() MOZ_OVERRIDE;
 
   virtual bool SupportsPartialTextureUpdate() { return true; }
-  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE { return true; }
+  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) MOZ_OVERRIDE { return true; }
   virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE { return INT32_MAX; }
   virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) MOZ_OVERRIDE { }
   virtual void SetTargetContext(gfx::DrawTarget* aTarget) MOZ_OVERRIDE
   {
     mCopyTarget = aTarget;
   }
   
   virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) MOZ_OVERRIDE {
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -762,20 +762,19 @@ LayerManagerComposite::SetCompositorID(u
 
 void
 LayerManagerComposite::NotifyShadowTreeTransaction()
 {
   mCompositor->NotifyLayersTransaction();
 }
 
 bool
-LayerManagerComposite::CanUseCanvasLayerForSize(const gfxIntSize &aSize)
+LayerManagerComposite::CanUseCanvasLayerForSize(const LayerIntSize &aSize)
 {
-  return mCompositor->CanUseCanvasLayerForSize(gfx::IntSize(aSize.width,
-                                                            aSize.height));
+  return mCompositor->CanUseCanvasLayerForSize(aSize);
 }
 
 TextureFactoryIdentifier
 LayerManagerComposite::GetTextureFactoryIdentifier()
 {
   return mCompositor->GetTextureFactoryIdentifier();
 }
 
--- a/gfx/layers/composite/LayerManagerComposite.h
+++ b/gfx/layers/composite/LayerManagerComposite.h
@@ -113,17 +113,17 @@ public:
 
   virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) MOZ_OVERRIDE;
   virtual void EndTransaction(DrawThebesLayerCallback aCallback,
                               void* aCallbackData,
                               EndTransactionFlags aFlags = END_DEFAULT) MOZ_OVERRIDE;
 
   virtual void SetRoot(Layer* aLayer) MOZ_OVERRIDE { mRoot = aLayer; }
 
-  virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) MOZ_OVERRIDE;
+  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) MOZ_OVERRIDE;
 
   virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() MOZ_OVERRIDE;
 
   virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE;
 
   virtual void ClearCachedResources(Layer* aSubtree = nullptr) MOZ_OVERRIDE;
 
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer() MOZ_OVERRIDE;
--- a/gfx/layers/d3d10/LayerManagerD3D10.h
+++ b/gfx/layers/d3d10/LayerManagerD3D10.h
@@ -87,19 +87,19 @@ public:
                               EndTransactionFlags aFlags = END_DEFAULT);
 
   const CallbackInfo &GetCallbackInfo() { return mCurrentCallbackInfo; }
 
   // D3D10 guarantees textures can be at least this size
   enum {
     MAX_TEXTURE_SIZE = 8192
   };
-  virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize)
+  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize)
   {
-    return aSize <= gfxIntSize(MAX_TEXTURE_SIZE, MAX_TEXTURE_SIZE);
+    return aSize <= LayerIntSize(MAX_TEXTURE_SIZE, MAX_TEXTURE_SIZE);
   }
 
   virtual int32_t GetMaxTextureSize() const
   {
     return MAX_TEXTURE_SIZE;
   }
 
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -344,25 +344,20 @@ CompositorD3D11::GetTextureFactoryIdenti
   TextureFactoryIdentifier ident;
   ident.mMaxTextureSize = GetMaxTextureSize();
   ident.mParentProcessId = XRE_GetProcessType();
   ident.mParentBackend = LAYERS_D3D11;
   return ident;
 }
 
 bool
-CompositorD3D11::CanUseCanvasLayerForSize(const gfx::IntSize& aSize)
+CompositorD3D11::CanUseCanvasLayerForSize(const LayerIntSize& aSize)
 {
   int32_t maxTextureSize = GetMaxTextureSize();
-
-  if (aSize.width > maxTextureSize || aSize.height > maxTextureSize) {
-    return false;
-  }
-
-  return true;
+  return aSize < LayerIntSize(maxTextureSize, maxTextureSize);
 }
 
 int32_t
 CompositorD3D11::GetMaxTextureSize() const
 {
   return GetMaxTextureSizeForFeatureLevel(mFeatureLevel);
 }
 
--- a/gfx/layers/d3d11/CompositorD3D11.h
+++ b/gfx/layers/d3d11/CompositorD3D11.h
@@ -46,17 +46,17 @@ public:
   virtual void Destroy() MOZ_OVERRIDE {}
 
   virtual TextureFactoryIdentifier
     GetTextureFactoryIdentifier() MOZ_OVERRIDE;
 
   virtual TemporaryRef<DataTextureSource>
     CreateDataTextureSource(TextureFlags aFlags = 0) MOZ_OVERRIDE { return nullptr; }
 
-  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) MOZ_OVERRIDE;
+  virtual bool CanUseCanvasLayerForSize(const LayerIntSize& aSize) MOZ_OVERRIDE;
   virtual int32_t GetMaxTextureSize() const MOZ_FINAL;
 
   virtual void SetTargetContext(gfx::DrawTarget* aTarget)  MOZ_OVERRIDE
   {
     mTarget = aTarget;
   }
 
   virtual void MakeCurrent(MakeCurrentFlags aFlags = 0)  MOZ_OVERRIDE {}
--- a/gfx/layers/d3d9/CompositorD3D9.cpp
+++ b/gfx/layers/d3d9/CompositorD3D9.cpp
@@ -60,25 +60,20 @@ CompositorD3D9::GetTextureFactoryIdentif
   TextureFactoryIdentifier ident;
   ident.mMaxTextureSize = GetMaxTextureSize();
   ident.mParentBackend = LAYERS_D3D9;
   ident.mParentProcessId = XRE_GetProcessType();
   return ident;
 }
 
 bool
-CompositorD3D9::CanUseCanvasLayerForSize(const IntSize &aSize)
+CompositorD3D9::CanUseCanvasLayerForSize(const LayerIntSize &aSize)
 {
   int32_t maxTextureSize = GetMaxTextureSize();
-
-  if (aSize.width > maxTextureSize || aSize.height > maxTextureSize) {
-    return false;
-  }
-
-  return true;
+  return aSize < LayerIntSize(maxTextureSize, maxTextureSize);
 }
 
 int32_t
 CompositorD3D9::GetMaxTextureSize() const
 {
   return mDeviceManager->GetMaxTextureSize();
 }
 
--- a/gfx/layers/d3d9/CompositorD3D9.h
+++ b/gfx/layers/d3d9/CompositorD3D9.h
@@ -23,17 +23,17 @@ public:
   ~CompositorD3D9();
 
   virtual bool Initialize() MOZ_OVERRIDE;
   virtual void Destroy() MOZ_OVERRIDE {}
 
   virtual TextureFactoryIdentifier
     GetTextureFactoryIdentifier() MOZ_OVERRIDE;
 
-  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE;
+  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) MOZ_OVERRIDE;
   virtual int32_t GetMaxTextureSize() const MOZ_FINAL;
 
   virtual void SetTargetContext(gfx::DrawTarget *aTarget) MOZ_OVERRIDE
   {
     mTarget = aTarget;
   }
 
   virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE {}
--- a/gfx/layers/d3d9/LayerManagerD3D9.h
+++ b/gfx/layers/d3d9/LayerManagerD3D9.h
@@ -73,22 +73,22 @@ public:
   virtual void EndTransaction(DrawThebesLayerCallback aCallback,
                               void* aCallbackData,
                               EndTransactionFlags aFlags = END_DEFAULT);
 
   const CallbackInfo &GetCallbackInfo() { return mCurrentCallbackInfo; }
 
   void SetRoot(Layer* aLayer);
 
-  virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize)
+  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize)
   {
     if (!mDeviceManager)
       return false;
     int32_t maxSize = mDeviceManager->GetMaxTextureSize();
-    return aSize <= gfxIntSize(maxSize, maxSize);
+    return aSize <= LayerIntSize(maxSize, maxSize);
   }
 
   virtual int32_t GetMaxTextureSize() const
   {
     return mDeviceManager->GetMaxTextureSize();
   }
 
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
--- a/gfx/layers/opengl/CompositorOGL.h
+++ b/gfx/layers/opengl/CompositorOGL.h
@@ -99,22 +99,22 @@ public:
                         const gfx::Point& aOffset) MOZ_OVERRIDE;
 
   virtual void EndFrame() MOZ_OVERRIDE;
   virtual void EndFrameForExternalComposition(const gfxMatrix& aTransform) MOZ_OVERRIDE;
   virtual void AbortFrame() MOZ_OVERRIDE;
 
   virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE;
 
-  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE
+  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) MOZ_OVERRIDE
   {
     if (!mGLContext)
       return false;
     int32_t maxSize = GetMaxTextureSize();
-    return aSize <= gfx::IntSize(maxSize, maxSize);
+    return aSize <= LayerIntSize(maxSize, maxSize);
   }
 
   virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE;
 
   /**
    * Set the size of the EGL surface we're rendering to, if we're rendering to
    * an EGL surface.
    */
--- a/gfx/layers/opengl/LayerManagerOGL.h
+++ b/gfx/layers/opengl/LayerManagerOGL.h
@@ -106,21 +106,21 @@ public:
 
   virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT);
   virtual void EndTransaction(DrawThebesLayerCallback aCallback,
                               void* aCallbackData,
                               EndTransactionFlags aFlags = END_DEFAULT);
 
   virtual void SetRoot(Layer* aLayer) { mRoot = aLayer; }
 
-  virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) {
+  virtual bool CanUseCanvasLayerForSize(const LayerIntSize &aSize) {
     if (!mGLContext)
       return false;
     int32_t maxSize = GetMaxTextureSize();
-    return aSize <= gfxIntSize(maxSize, maxSize);
+    return aSize <= LayerIntSize(maxSize, maxSize);
   }
 
   virtual int32_t GetMaxTextureSize() const;
 
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
 
   virtual already_AddRefed<ContainerLayer> CreateContainerLayer();