From 012417f2af96c98d12ff83effa371071cb4d3721 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Sun, 17 Nov 2013 21:07:08 -0500 Subject: [PATCH] Bug 938970 - 5/5. Switch gfx/layers to UNIFIED_SOURCES - r=ehsan,mattwoodrow --- gfx/layers/ImageDataSerializer.cpp | 2 +- gfx/layers/Layers.cpp | 33 +++++++++++++++++++++ gfx/layers/Layers.h | 3 ++ gfx/layers/ThebesLayerBuffer.cpp | 4 +-- gfx/layers/basic/BasicLayerManager.cpp | 4 +-- gfx/layers/basic/BasicThebesLayer.cpp | 33 --------------------- gfx/layers/client/ClientThebesLayer.cpp | 33 --------------------- gfx/layers/ipc/AsyncPanZoomController.cpp | 2 -- gfx/layers/ipc/Axis.cpp | 2 -- gfx/layers/ipc/Axis.h | 2 ++ gfx/layers/ipc/ImageBridgeParent.h | 4 +++ gfx/layers/ipc/SharedPlanarYCbCrImage.cpp | 3 +- gfx/layers/moz.build | 35 +++++++++++++++-------- gfx/layers/opengl/FPSCounter.h | 5 ++++ gfx/layers/opengl/LayerManagerOGL.cpp | 4 +-- gfx/layers/opengl/ThebesLayerOGL.cpp | 24 ---------------- 16 files changed, 79 insertions(+), 114 deletions(-) diff --git a/gfx/layers/ImageDataSerializer.cpp b/gfx/layers/ImageDataSerializer.cpp index 04e6aa495f6..afda33aac7e 100644 --- a/gfx/layers/ImageDataSerializer.cpp +++ b/gfx/layers/ImageDataSerializer.cpp @@ -137,7 +137,7 @@ ImageDataSerializerBase::GetAsDrawTarget() GetFormat()); } -TemporaryRef +TemporaryRef ImageDataSerializerBase::GetAsSurface() { MOZ_ASSERT(IsValid()); diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 0fb1906eb36..709750bcd96 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -1506,6 +1506,39 @@ PrintInfo(nsACString& aTo, LayerComposite* aLayerComposite) return aTo; } +void +SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget) +{ + if (!aTarget->IsCairo()) { + RefPtr dt = aTarget->GetDrawTarget(); + + if (dt->GetFormat() != FORMAT_B8G8R8A8) { + return; + } + + const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds(); + gfx::Rect transformedBounds = dt->GetTransform().TransformBounds(gfx::Rect(Float(bounds.x), Float(bounds.y), + Float(bounds.width), Float(bounds.height))); + transformedBounds.RoundOut(); + IntRect intTransformedBounds; + transformedBounds.ToIntRect(&intTransformedBounds); + dt->SetPermitSubpixelAA(!(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) || + dt->GetOpaqueRect().Contains(intTransformedBounds)); + } else { + nsRefPtr surface = aTarget->CurrentSurface(); + if (surface->GetContentType() != GFX_CONTENT_COLOR_ALPHA) { + // Destination doesn't have alpha channel; no need to set any special flags + return; + } + + const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds(); + surface->SetSubpixelAntialiasingEnabled( + !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) || + surface->GetOpaqueRect().Contains( + aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)))); + } +} + PRLogModuleInfo* LayerManager::sLog; } // namespace layers diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 07a4d34ae22..66890aa27da 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -1954,6 +1954,9 @@ protected: uint64_t mId; }; +void +SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget); + #ifdef MOZ_DUMP_PAINTING void WriteSnapshotToDumpFile(Layer* aLayer, gfxASurface* aSurf); void WriteSnapshotToDumpFile(LayerManager* aManager, gfxASurface* aSurf); diff --git a/gfx/layers/ThebesLayerBuffer.cpp b/gfx/layers/ThebesLayerBuffer.cpp index d080e87aeb3..727624d4d88 100644 --- a/gfx/layers/ThebesLayerBuffer.cpp +++ b/gfx/layers/ThebesLayerBuffer.cpp @@ -212,7 +212,7 @@ RotatedBuffer::DrawBufferQuadrant(gfx::DrawTarget* aTarget, } } - RefPtr snapshot; + RefPtr snapshot; if (aSource == BUFFER_BLACK) { snapshot = mDTBuffer->Snapshot(); } else { @@ -353,7 +353,7 @@ ThebesLayerBuffer::DrawTo(ThebesLayer* aLayer, clipped = true; } - RefPtr mask; + RefPtr mask; if (aMask) { mask = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aMask); } diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp index 92d7bbeae38..f61cd287fa4 100644 --- a/gfx/layers/basic/BasicLayerManager.cpp +++ b/gfx/layers/basic/BasicLayerManager.cpp @@ -693,7 +693,7 @@ BasicLayerManager::SetRoot(Layer* aLayer) } static pixman_transform -Matrix3DToPixman(const gfx3DMatrix& aMatrix) +BasicLayerManager_Matrix3DToPixman(const gfx3DMatrix& aMatrix) { pixman_f_transform transform; @@ -735,7 +735,7 @@ PixmanTransform(const gfxImageSurface *aDest, NS_ABORT_IF_FALSE(src && dest, "Failed to create pixman images?"); - pixman_transform pixTransform = Matrix3DToPixman(aTransform); + pixman_transform pixTransform = BasicLayerManager_Matrix3DToPixman(aTransform); pixman_transform pixTransformInverted; // If the transform is singular then nothing would be drawn anyway, return here diff --git a/gfx/layers/basic/BasicThebesLayer.cpp b/gfx/layers/basic/BasicThebesLayer.cpp index a739debebfc..272f336489f 100644 --- a/gfx/layers/basic/BasicThebesLayer.cpp +++ b/gfx/layers/basic/BasicThebesLayer.cpp @@ -46,39 +46,6 @@ IntersectWithClip(const nsIntRegion& aRegion, gfxContext* aContext) return result; } -static void -SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget) -{ - if (!aTarget->IsCairo()) { - RefPtr dt = aTarget->GetDrawTarget(); - - if (dt->GetFormat() != FORMAT_B8G8R8A8) { - return; - } - - const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds(); - gfx::Rect transformedBounds = dt->GetTransform().TransformBounds(gfx::Rect(Float(bounds.x), Float(bounds.y), - Float(bounds.width), Float(bounds.height))); - transformedBounds.RoundOut(); - IntRect intTransformedBounds; - transformedBounds.ToIntRect(&intTransformedBounds); - dt->SetPermitSubpixelAA(!(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) || - dt->GetOpaqueRect().Contains(intTransformedBounds)); - } else { - nsRefPtr surface = aTarget->CurrentSurface(); - if (surface->GetContentType() != GFX_CONTENT_COLOR_ALPHA) { - // Destination doesn't have alpha channel; no need to set any special flags - return; - } - - const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds(); - surface->SetSubpixelAntialiasingEnabled( - !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) || - surface->GetOpaqueRect().Contains( - aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)))); - } -} - void BasicThebesLayer::PaintThebes(gfxContext* aContext, Layer* aMaskLayer, diff --git a/gfx/layers/client/ClientThebesLayer.cpp b/gfx/layers/client/ClientThebesLayer.cpp index 95d4496827e..cb398f51bcf 100644 --- a/gfx/layers/client/ClientThebesLayer.cpp +++ b/gfx/layers/client/ClientThebesLayer.cpp @@ -28,39 +28,6 @@ using namespace mozilla::gfx; namespace mozilla { namespace layers { -static void -SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget) -{ - if (!aTarget->IsCairo()) { - RefPtr dt = aTarget->GetDrawTarget(); - - if (dt->GetFormat() != FORMAT_B8G8R8A8) { - return; - } - - const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds(); - gfx::Rect transformedBounds = dt->GetTransform().TransformBounds(gfx::Rect(Float(bounds.x), Float(bounds.y), - Float(bounds.width), Float(bounds.height))); - transformedBounds.RoundOut(); - IntRect intTransformedBounds; - transformedBounds.ToIntRect(&intTransformedBounds); - dt->SetPermitSubpixelAA(!(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) || - dt->GetOpaqueRect().Contains(intTransformedBounds)); - } else { - nsRefPtr surface = aTarget->CurrentSurface(); - if (surface->GetContentType() != GFX_CONTENT_COLOR_ALPHA) { - // Destination doesn't have alpha channel; no need to set any special flags - return; - } - - const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds(); - surface->SetSubpixelAntialiasingEnabled( - !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) || - surface->GetOpaqueRect().Contains( - aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)))); - } -} - void ClientThebesLayer::PaintThebes() { diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index 02d60172ba3..0e22ec33202 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -82,8 +82,6 @@ namespace layers { */ static float gTouchStartTolerance = 1.0f/16.0f; -static const float EPSILON = 0.0001f; - /** * Angle from axis within which we stay axis-locked */ diff --git a/gfx/layers/ipc/Axis.cpp b/gfx/layers/ipc/Axis.cpp index 6c20a0f751e..b8badb0e3b1 100644 --- a/gfx/layers/ipc/Axis.cpp +++ b/gfx/layers/ipc/Axis.cpp @@ -20,8 +20,6 @@ namespace mozilla { namespace layers { -static const float EPSILON = 0.0001f; - /** * Maximum acceleration that can happen between two frames. Velocity is * throttled if it's above this. This may happen if a time delta is very low, diff --git a/gfx/layers/ipc/Axis.h b/gfx/layers/ipc/Axis.h index 752ee6650a8..fe2db824ebe 100644 --- a/gfx/layers/ipc/Axis.h +++ b/gfx/layers/ipc/Axis.h @@ -15,6 +15,8 @@ namespace mozilla { namespace layers { +const float EPSILON = 0.0001f; + class AsyncPanZoomController; /** diff --git a/gfx/layers/ipc/ImageBridgeParent.h b/gfx/layers/ipc/ImageBridgeParent.h index 30ab44cd20b..f14ca06c883 100644 --- a/gfx/layers/ipc/ImageBridgeParent.h +++ b/gfx/layers/ipc/ImageBridgeParent.h @@ -3,6 +3,9 @@ * 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/. */ +#ifndef gfx_layers_ipc_ImageBridgeParent_h_ +#define gfx_layers_ipc_ImageBridgeParent_h_ + #include // for size_t #include // for uint32_t, uint64_t #include "CompositableTransactionParent.h" @@ -107,3 +110,4 @@ private: } // layers } // mozilla +#endif // gfx_layers_ipc_ImageBridgeParent_h_ diff --git a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp index c32a4631c25..7fc85750ac1 100644 --- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp +++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp @@ -18,6 +18,7 @@ #include "mozilla/layers/ImageBridgeChild.h" // for ImageBridgeChild #include "mozilla/mozalloc.h" // for operator delete #include "nsISupportsImpl.h" // for Image::AddRef +#include "mozilla/ipc/Shmem.h" class gfxASurface; @@ -339,7 +340,7 @@ DeprecatedSharedPlanarYCbCrImage::DropToSurfaceDescriptor(SurfaceDescriptor& aDe return false; } aDesc = YCbCrImage(mShmem, 0); - mShmem = Shmem(); + mShmem = mozilla::ipc::Shmem(); mAllocated = false; return true; } diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 76525e5b13b..8542633f254 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -44,7 +44,7 @@ EXPORTS += [ ] if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': - SOURCES += [ + UNIFIED_SOURCES += [ 'D3D9SurfaceImage.cpp', ] if CONFIG['MOZ_ENABLE_D3D9_LAYER']: @@ -56,18 +56,20 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': 'd3d9/CompositorD3D9.h', 'd3d9/TextureD3D9.h', ] - SOURCES += [ + UNIFIED_SOURCES += [ 'd3d9/CanvasLayerD3D9.cpp', 'd3d9/ColorLayerD3D9.cpp', - 'd3d9/CompositorD3D9.cpp', 'd3d9/ContainerLayerD3D9.cpp', - 'd3d9/DeviceManagerD3D9.cpp', 'd3d9/ImageLayerD3D9.cpp', 'd3d9/LayerManagerD3D9.cpp', 'd3d9/Nv3DVUtils.cpp', 'd3d9/TextureD3D9.cpp', 'd3d9/ThebesLayerD3D9.cpp', ] + SOURCES += [ + 'd3d9/CompositorD3D9.cpp', + 'd3d9/DeviceManagerD3D9.cpp', + ] if CONFIG['MOZ_ENABLE_D3D10_LAYER']: EXPORTS += [ 'd3d10/LayerManagerD3D10.h', @@ -78,7 +80,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': 'd3d11/TextureD3D11.h', 'ipc/ShadowLayerUtilsD3D10.h', ] - SOURCES += [ + UNIFIED_SOURCES += [ 'd3d10/CanvasLayerD3D10.cpp', 'd3d10/ColorLayerD3D10.cpp', 'd3d10/ContainerLayerD3D10.cpp', @@ -86,10 +88,12 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': 'd3d10/LayerManagerD3D10.cpp', 'd3d10/ReadbackManagerD3D10.cpp', 'd3d10/ThebesLayerD3D10.cpp', - 'd3d11/CompositorD3D11.cpp', 'd3d11/TextureD3D11.cpp', 'ipc/ShadowLayerUtilsD3D10.cpp', ] + SOURCES += [ + 'd3d11/CompositorD3D11.cpp', + ] EXPORTS.gfxipc += [ 'ipc/ShadowLayerUtils.h', @@ -166,10 +170,12 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': EXPORTS += [ 'MacIOSurfaceImage.h', ] + UNIFIED_SOURCES += [ + 'opengl/GLManager.cpp', + ] SOURCES += [ 'ipc/ShadowLayerUtilsMac.cpp', 'MacIOSurfaceImage.cpp', - 'opengl/GLManager.cpp', ] # NB: Gralloc is available on other platforms that use the android GL @@ -179,19 +185,20 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': EXPORTS.mozilla.layers += [ 'ipc/ShadowLayerUtilsGralloc.h', ] - SOURCES += [ + UNIFIED_SOURCES += [ 'GrallocImages.cpp', - 'ipc/ShadowLayerUtilsGralloc.cpp', 'opengl/GrallocTextureClient.cpp', 'opengl/GrallocTextureHost.cpp', ] + SOURCES += [ + 'ipc/ShadowLayerUtilsGralloc.cpp', + ] -SOURCES += [ +UNIFIED_SOURCES += [ 'basic/BasicCanvasLayer.cpp', 'basic/BasicColorLayer.cpp', 'basic/BasicCompositor.cpp', 'basic/BasicContainerLayer.cpp', - 'basic/BasicImageLayer.cpp', 'basic/BasicImages.cpp', 'basic/BasicLayerManager.cpp', 'basic/BasicLayersImpl.cpp', @@ -226,7 +233,6 @@ SOURCES += [ 'Compositor.cpp', 'CopyableCanvasLayer.cpp', 'Effects.cpp', - 'ImageContainer.cpp', 'ImageDataSerializer.cpp', 'ImageLayers.cpp', 'ipc/AsyncPanZoomController.cpp', @@ -269,6 +275,11 @@ SOURCES += [ 'YCbCrImageDataSerializer.cpp', ] +SOURCES += [ + 'basic/BasicImageLayer.cpp', + 'ImageContainer.cpp', +] + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': SOURCES += [ 'opengl/MacIOSurfaceTextureClientOGL.cpp', diff --git a/gfx/layers/opengl/FPSCounter.h b/gfx/layers/opengl/FPSCounter.h index e49bf192cb8..257b29b4c2f 100644 --- a/gfx/layers/opengl/FPSCounter.h +++ b/gfx/layers/opengl/FPSCounter.h @@ -3,6 +3,9 @@ * 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/. */ +#ifndef mozilla_layers_opengl_FPSCounter_h_ +#define mozilla_layers_opengl_FPSCounter_h_ + #include // for size_t #include // for min #include "GLDefs.h" // for GLuint @@ -84,3 +87,5 @@ struct FPSState { } } + +#endif // mozilla_layers_opengl_FPSCounter_h_ diff --git a/gfx/layers/opengl/LayerManagerOGL.cpp b/gfx/layers/opengl/LayerManagerOGL.cpp index cc0d62fccfd..94029105ec5 100644 --- a/gfx/layers/opengl/LayerManagerOGL.cpp +++ b/gfx/layers/opengl/LayerManagerOGL.cpp @@ -1171,7 +1171,7 @@ LayerManagerOGL::SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix) } static GLenum -GetFrameBufferInternalFormat(GLContext* gl, +LayerManagerOGL_GetFrameBufferInternalFormat(GLContext* gl, GLuint aCurrentFrameBuffer, nsIWidget* aWidget) { @@ -1199,7 +1199,7 @@ LayerManagerOGL::CreateFBOWithTexture(const nsIntRect& aRect, InitMode aInit, // check the format of the framebuffer here and take a slow path // if it's incompatible. GLenum format = - GetFrameBufferInternalFormat(gl(), aCurrentFrameBuffer, mWidget); + LayerManagerOGL_GetFrameBufferInternalFormat(gl(), aCurrentFrameBuffer, mWidget); bool isFormatCompatibleWithRGBA = gl()->IsGLES2() ? (format == LOCAL_GL_RGBA) diff --git a/gfx/layers/opengl/ThebesLayerOGL.cpp b/gfx/layers/opengl/ThebesLayerOGL.cpp index 85fb106af71..c94c0eddacb 100644 --- a/gfx/layers/opengl/ThebesLayerOGL.cpp +++ b/gfx/layers/opengl/ThebesLayerOGL.cpp @@ -74,30 +74,6 @@ CreateClampOrRepeatTextureImage(GLContext *aGl, return aGl->CreateTextureImage(aSize, aContentType, WrapMode(aGl, aFlags)); } -static void -SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget) -{ - if (aTarget->IsCairo()) { - nsRefPtr surface = aTarget->CurrentSurface(); - if (surface->GetContentType() != GFX_CONTENT_COLOR_ALPHA) { - // Destination doesn't have alpha channel; no need to set any special flags - return; - } - - surface->SetSubpixelAntialiasingEnabled( - !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA)); - } else { - RefPtr dt = aTarget->GetDrawTarget(); - - if (dt->GetFormat() != FORMAT_B8G8R8A8) { - return; - } - - dt->SetPermitSubpixelAA( - !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA)); - } -} - class ThebesLayerBufferOGL { NS_INLINE_DECL_REFCOUNTING(ThebesLayerBufferOGL)