# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.

with Files('apz/**'):
    BUG_COMPONENT = ('Core', 'Panning and Zooming')

EXPORTS += [
    'basic/BasicCanvasLayer.h',
    'basic/BasicImplData.h',
    'basic/BasicLayers.h',
    'basic/BasicLayersImpl.h',
    'basic/BasicPaintedLayer.h',
    'client/ClientCanvasLayer.h',
    'client/ClientContainerLayer.h',
    'client/ClientLayerManager.h',
    'client/ClientPaintedLayer.h',
    'client/ClientTiledPaintedLayer.h',
    'composite/CompositableHost.h',
    'composite/ImageHost.h',
    'CompositorTypes.h',
    'CopyableCanvasLayer.h',
    'D3D9SurfaceImage.h',
    'FrameMetrics.h',
    'GLImages.h',
    'GPUVideoImage.h',
    'ImageContainer.h',
    'ImageLayers.h',
    'ImageTypes.h',
    'IMFYCbCrImage.h',
    'ipc/ThreadSafeRefcountingWithMainThreadDestruction.h',
    'Layers.h',
    'LayerScope.h',
    'LayersLogging.h',
    'LayerSorter.h',
    'LayersTypes.h',
    'LayerTreeInvalidation.h',
    'LayerUserData.h',
    'opengl/Composer2D.h',
    'opengl/OGLShaderProgram.h',
    'opengl/TexturePoolOGL.h',
    'protobuf/LayerScopePacket.pb.h',
    'ReadbackLayer.h',
    'TiledLayerBuffer.h',
]

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
    SOURCES += [
        'D3D11ShareHandleImage.cpp',
    ]
    UNIFIED_SOURCES += [
        'D3D9SurfaceImage.cpp',
        'IMFYCbCrImage.cpp',
        'TextureDIB.cpp',
    ]
    EXPORTS.mozilla.layers += [
        'TextureDIB.h',
    ]
    if CONFIG['MOZ_ENABLE_D3D9_LAYER']:
        EXPORTS += [
            'd3d9/DeviceManagerD3D9.h',
        ]
        EXPORTS.mozilla.layers += [
            'd3d9/CompositorD3D9.h',
            'd3d9/TextureD3D9.h',
        ]
        UNIFIED_SOURCES += [
            'd3d9/TextureD3D9.cpp',
        ]
        SOURCES += [
            'd3d9/CompositorD3D9.cpp',
            'd3d9/DeviceManagerD3D9.cpp',
            'd3d9/Nv3DVUtils.cpp',
        ]
    if CONFIG['MOZ_ENABLE_D3D10_LAYER']:
        EXPORTS.mozilla.layers += [
            'd3d11/CompositorD3D11.h',
            'd3d11/ReadbackManagerD3D11.h',
            'd3d11/TextureD3D11.h',
        ]
        UNIFIED_SOURCES += [
            'd3d11/TextureD3D11.cpp',
        ]
        SOURCES += [
            'd3d11/CompositorD3D11.cpp',
            'd3d11/ReadbackManagerD3D11.cpp',
        ]

EXPORTS.gfxipc += [
    'ipc/ShadowLayerUtils.h',
]

EXPORTS.mozilla.dom += [
    'apz/util/CheckerboardReportService.h',
]

EXPORTS.mozilla.layers += [
    'apz/public/CompositorController.h',
    'apz/public/GeckoContentController.h',
    'apz/public/IAPZCTreeManager.h',
    'apz/public/MetricsSharingController.h',
    # exporting things from apz/src is temporary until we extract a
    # proper interface for the code there
    'apz/src/APZCTreeManager.h',
    'apz/src/APZUtils.h',
    'apz/src/AsyncDragMetrics.h',
    'apz/src/AsyncPanZoomAnimation.h',
    'apz/src/TouchCounter.h',
    'apz/testutil/APZTestData.h',
    'apz/util/ActiveElementManager.h',
    'apz/util/APZCCallbackHelper.h',
    'apz/util/APZEventState.h',
    'apz/util/APZThreadUtils.h',
    'apz/util/ChromeProcessController.h',
    'apz/util/ContentProcessController.h',
    'apz/util/DoubleTapToZoom.h',
    'apz/util/InputAPZContext.h',
    'apz/util/ScrollInputMethods.h',
    'apz/util/ScrollLinkedEffectDetector.h',
    'apz/util/TouchActionHelper.h',
    'AsyncCanvasRenderer.h',
    'AtomicRefCountedWithFinalize.h',
    'AxisPhysicsModel.h',
    'AxisPhysicsMSDModel.h',
    'basic/BasicCompositor.h',
    'basic/MacIOSurfaceTextureHostBasic.h',
    'basic/TextureHostBasic.h',
    'BSPTree.h',
    'BufferTexture.h',
    'client/CanvasClient.h',
    'client/CompositableChild.h',
    'client/CompositableClient.h',
    'client/ContentClient.h',
    'client/GPUVideoTextureClient.h',
    'client/ImageClient.h',
    'client/SingleTiledContentClient.h',
    'client/TextureClient.h',
    'client/TextureClientPool.h',
    'client/TextureClientRecycleAllocator.h',
    'client/TextureClientSharedSurface.h',
    'client/TiledContentClient.h',
    'composite/AsyncCompositionManager.h',
    'composite/CanvasLayerComposite.h',
    'composite/ColorLayerComposite.h',
    'composite/ContainerLayerComposite.h',
    'composite/ContentHost.h',
    'composite/FrameUniformityData.h',
    'composite/GPUVideoTextureHost.h',
    'composite/ImageHost.h',
    'composite/ImageLayerComposite.h',
    'composite/LayerManagerComposite.h',
    'composite/PaintedLayerComposite.h',
    'composite/TextureHost.h',
    'composite/TiledContentHost.h',
    'Compositor.h',
    'CompositorTypes.h',
    'D3D11ShareHandleImage.h',
    'D3D9SurfaceImage.h',
    'Effects.h',
    'ImageDataSerializer.h',
    'ipc/APZChild.h',
    'ipc/APZCTreeManagerChild.h',
    'ipc/APZCTreeManagerParent.h',
    'ipc/CompositableForwarder.h',
    'ipc/CompositableTransactionParent.h',
    'ipc/CompositorBridgeChild.h',
    'ipc/CompositorBridgeParent.h',
    'ipc/CompositorThread.h',
    'ipc/CrossProcessCompositorBridgeParent.h',
    'ipc/GonkNativeHandle.h',
    'ipc/GonkNativeHandleUtils.h',
    'ipc/ImageBridgeChild.h',
    'ipc/ImageBridgeParent.h',
    'ipc/ImageContainerChild.h',
    'ipc/ImageContainerParent.h',
    'ipc/ISurfaceAllocator.h',
    'ipc/KnowsCompositor.h',
    'ipc/LayerAnimationUtils.h',
    'ipc/LayerTransactionChild.h',
    'ipc/LayerTransactionParent.h',
    'ipc/LayerTreeOwnerTracker.h',
    'ipc/RemoteContentController.h',
    'ipc/ShadowLayerChild.h',
    'ipc/ShadowLayers.h',
    'ipc/SharedPlanarYCbCrImage.h',
    'ipc/SharedRGBImage.h',
    'ipc/SynchronousTask.h',
    'ipc/TextureForwarder.h',
    'ipc/VideoBridgeChild.h',
    'ipc/VideoBridgeParent.h',
    'LayerMetricsWrapper.h',
    'LayersTypes.h',
    'opengl/CompositingRenderTargetOGL.h',
    'opengl/CompositorOGL.h',
    'opengl/MacIOSurfaceTextureClientOGL.h',
    'opengl/MacIOSurfaceTextureHostOGL.h',
    'opengl/TextureClientOGL.h',
    'opengl/TextureHostOGL.h',
    'PersistentBufferProvider.h',
    'RenderTrace.h',
    'TextureWrapperImage.h',
    'TransactionIdAllocator.h',
]

if CONFIG['MOZ_X11']:
    EXPORTS.mozilla.layers += [
        'basic/TextureClientX11.h',
        'basic/X11TextureSourceBasic.h',
        'composite/X11TextureHost.h',
        'ipc/ShadowLayerUtilsX11.h',
        'opengl/X11TextureSourceOGL.h',
    ]
    SOURCES += [
        'basic/TextureClientX11.cpp',
        'basic/X11BasicCompositor.cpp',
        'basic/X11TextureSourceBasic.cpp',
        'composite/X11TextureHost.cpp',
        'ipc/ShadowLayerUtilsX11.cpp',
        'opengl/X11TextureSourceOGL.cpp',
    ]

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
    EXPORTS.mozilla.layers += [
        'opengl/GLManager.h',
    ]
    EXPORTS += [
        'MacIOSurfaceHelpers.h',
        'MacIOSurfaceImage.h',
    ]
    UNIFIED_SOURCES += [
        'opengl/GLManager.cpp',
    ]
    SOURCES += [
        'ipc/ShadowLayerUtilsMac.cpp',
        'MacIOSurfaceHelpers.cpp',
        'MacIOSurfaceImage.cpp',
    ]

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
    UNIFIED_SOURCES += [
        'apz/src/AndroidAPZ.cpp',
    ]

UNIFIED_SOURCES += [
    'apz/public/IAPZCTreeManager.cpp',
    'apz/src/APZCTreeManager.cpp',
    'apz/src/AsyncPanZoomController.cpp',
    'apz/src/Axis.cpp',
    'apz/src/CheckerboardEvent.cpp',
    'apz/src/DragTracker.cpp',
    'apz/src/GestureEventListener.cpp',
    'apz/src/HitTestingTreeNode.cpp',
    'apz/src/InputBlockState.cpp',
    'apz/src/InputQueue.cpp',
    'apz/src/OverscrollHandoffState.cpp',
    'apz/src/PotentialCheckerboardDurationTracker.cpp',
    'apz/src/QueuedInput.cpp',
    'apz/src/TouchCounter.cpp',
    'apz/src/WheelScrollAnimation.cpp',
    'apz/testutil/APZTestData.cpp',
    'apz/util/ActiveElementManager.cpp',
    'apz/util/APZCCallbackHelper.cpp',
    'apz/util/APZEventState.cpp',
    'apz/util/APZThreadUtils.cpp',
    'apz/util/CheckerboardReportService.cpp',
    'apz/util/ChromeProcessController.cpp',
    'apz/util/ContentProcessController.cpp',
    'apz/util/DoubleTapToZoom.cpp',
    'apz/util/InputAPZContext.cpp',
    'apz/util/ScrollLinkedEffectDetector.cpp',
    'apz/util/TouchActionHelper.cpp',
    'AsyncCanvasRenderer.cpp',
    'AxisPhysicsModel.cpp',
    'AxisPhysicsMSDModel.cpp',
    'basic/BasicCanvasLayer.cpp',
    'basic/BasicColorLayer.cpp',
    'basic/BasicCompositor.cpp',
    'basic/BasicContainerLayer.cpp',
    'basic/BasicImages.cpp',
    'basic/BasicLayerManager.cpp',
    'basic/BasicLayersImpl.cpp',
    'basic/BasicPaintedLayer.cpp',
    'basic/TextureHostBasic.cpp',
    'BSPTree.cpp',
    'BufferTexture.cpp',
    'BufferUnrotate.cpp',
    'client/CanvasClient.cpp',
    'client/ClientCanvasLayer.cpp',
    'client/ClientColorLayer.cpp',
    'client/ClientContainerLayer.cpp',
    'client/ClientImageLayer.cpp',
    'client/ClientLayerManager.cpp',
    'client/ClientPaintedLayer.cpp',
    'client/ClientTiledPaintedLayer.cpp',
    'client/CompositableChild.cpp',
    'client/CompositableClient.cpp',
    'client/ContentClient.cpp',
    'client/GPUVideoTextureClient.cpp',
    'client/ImageClient.cpp',
    'client/SingleTiledContentClient.cpp',
    'client/TextureClient.cpp',
    'client/TextureClientPool.cpp',
    'client/TextureClientRecycleAllocator.cpp',
    'client/TextureClientSharedSurface.cpp',
    'client/TiledContentClient.cpp',
    'composite/AsyncCompositionManager.cpp',
    'composite/CanvasLayerComposite.cpp',
    'composite/ColorLayerComposite.cpp',
    'composite/CompositableHost.cpp',
    'composite/ContainerLayerComposite.cpp',
    'composite/ContentHost.cpp',
    'composite/FPSCounter.cpp',
    'composite/FrameUniformityData.cpp',
    'composite/GPUVideoTextureHost.cpp',
    'composite/ImageHost.cpp',
    'composite/ImageLayerComposite.cpp',
    'composite/LayerManagerComposite.cpp',
    'composite/PaintedLayerComposite.cpp',
    'composite/TextRenderer.cpp',
    'composite/TextureHost.cpp',
    'composite/TiledContentHost.cpp',
    'Compositor.cpp',
    'CopyableCanvasLayer.cpp',
    'Effects.cpp',
    'FrameMetrics.cpp',
    'GLImages.cpp',
    'ImageDataSerializer.cpp',
    'ImageLayers.cpp',
    'ipc/APZChild.cpp',
    'ipc/APZCTreeManagerChild.cpp',
    'ipc/APZCTreeManagerParent.cpp',
    'ipc/CompositableForwarder.cpp',
    'ipc/CompositableTransactionParent.cpp',
    'ipc/CompositorBench.cpp',
    'ipc/CompositorBridgeChild.cpp',
    'ipc/CompositorBridgeParent.cpp',
    'ipc/CompositorThread.cpp',
    'ipc/CrossProcessCompositorBridgeParent.cpp',
    'ipc/ImageBridgeChild.cpp',
    'ipc/ImageBridgeParent.cpp',
    'ipc/ImageContainerChild.cpp',
    'ipc/ImageContainerParent.cpp',
    'ipc/ISurfaceAllocator.cpp',
    'ipc/LayerAnimationUtils.cpp',
    'ipc/LayerTransactionChild.cpp',
    'ipc/LayerTransactionParent.cpp',
    'ipc/LayerTreeOwnerTracker.cpp',
    'ipc/RemoteContentController.cpp',
    'ipc/ShadowLayerChild.cpp',
    'ipc/ShadowLayerParent.cpp',
    'ipc/ShadowLayers.cpp',
    'ipc/SharedPlanarYCbCrImage.cpp',
    'ipc/SharedRGBImage.cpp',
    'ipc/VideoBridgeChild.cpp',
    'ipc/VideoBridgeParent.cpp',
    'LayerScope.cpp',
    'LayersLogging.cpp',
    'LayerSorter.cpp',
    'LayersTypes.cpp',
    'opengl/CompositingRenderTargetOGL.cpp',
    'opengl/CompositorOGL.cpp',
    'opengl/GLBlitTextureImageHelper.cpp',
    'opengl/OGLShaderProgram.cpp',
    'opengl/TextureClientOGL.cpp',
    'opengl/TextureHostOGL.cpp',
    'opengl/TexturePoolOGL.cpp',
    'protobuf/LayerScopePacket.pb.cc',
    'ReadbackProcessor.cpp',
    'RenderTrace.cpp',
    'RotatedBuffer.cpp',
    'TextureWrapperImage.cpp',
]

SOURCES += [
    'basic/BasicImageLayer.cpp',
    'ImageContainer.cpp',
    'Layers.cpp',
    'LayerTreeInvalidation.cpp',
    'PersistentBufferProvider.cpp',
]

# Disable RTTI in google protocol buffer
DEFINES['GOOGLE_PROTOBUF_NO_RTTI'] = True

# Workaround compiler bug (Bug 795594)
if CONFIG['_MSC_VER'] and CONFIG['CPU_ARCH'] == 'x86_64':
    for src in [
        'Layers.cpp',
        'LayerTreeInvalidation.cpp',
    ]:
        SOURCES[src].no_pgo = True

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
    SOURCES += [
        'basic/MacIOSurfaceTextureHostBasic.cpp',
        'opengl/MacIOSurfaceTextureClientOGL.cpp',
        'opengl/MacIOSurfaceTextureHostOGL.cpp',
    ]

IPDL_SOURCES = [
    'ipc/LayersMessages.ipdlh',
    'ipc/LayersSurfaces.ipdlh',
    'ipc/PAPZ.ipdl',
    'ipc/PAPZCTreeManager.ipdl',
    'ipc/PCompositable.ipdl',
    'ipc/PCompositorBridge.ipdl',
    'ipc/PImageBridge.ipdl',
    'ipc/PImageContainer.ipdl',
    'ipc/PLayer.ipdl',
    'ipc/PLayerTransaction.ipdl',
    'ipc/PTexture.ipdl',
    'ipc/PVideoBridge.ipdl',
]

include('/ipc/chromium/chromium-config.mozbuild')

LOCAL_INCLUDES += [
    '/docshell/base',  # for nsDocShell.h
    '/layout/base',    # for TouchManager.h
    '/layout/generic', # for nsTextFrame.h
    '/media/libyuv/include', # for libyuv.h
]

FINAL_LIBRARY = 'xul'

if CONFIG['MOZ_DEBUG']:
    DEFINES['D3D_DEBUG_INFO'] = True

if CONFIG['MOZ_ENABLE_D3D10_LAYER']:
    DEFINES['MOZ_ENABLE_D3D10_LAYER'] = True

if CONFIG['ENABLE_TESTS']:
    DIRS += ['apz/test/gtest']

MOCHITEST_MANIFESTS += ['apz/test/mochitest/mochitest.ini']
MOCHITEST_CHROME_MANIFESTS += ['apz/test/mochitest/chrome.ini']

CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
CXXFLAGS += CONFIG['TK_CFLAGS']

LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']

if CONFIG['GNU_CXX']:
    CXXFLAGS += ['-Wno-error=shadow']

if CONFIG['MOZ_ENABLE_SKIA']:
  UNIFIED_SOURCES += [
    'composite/PaintCounter.cpp',
  ]